Moving load of suggestions from onViewCreated to onCategoriesChanged.

- This is required when a suggestion is completed and it needs to be
removed from the list immediately.

Test: RunSettingsRoboTests
Fixes: b/35657186

Change-Id: I731bd1d4ef4a23a74cb4022513d0824ff5f74b2a
This commit is contained in:
Soroosh Mariooryad
2017-02-22 14:28:38 -08:00
parent fc19e30d4d
commit 9ca41dd89a
2 changed files with 29 additions and 16 deletions

View File

@@ -70,6 +70,7 @@ public class DashboardSummary extends InstrumentedFragment
private SuggestionsChecks mSuggestionsChecks;
private DashboardFeatureProvider mDashboardFeatureProvider;
private SuggestionFeatureProvider mSuggestionFeatureProvider;
private boolean isOnCategoriesChangedCalled;
@Override
public int getMetricsCategory() {
@@ -204,25 +205,27 @@ public class DashboardSummary extends InstrumentedFragment
Log.d(TAG, "onViewCreated took "
+ (System.currentTimeMillis() - startTime) + " ms");
}
rebuildUI(true /* rebuildSuggestions */);
rebuildUI();
}
private void rebuildUI(boolean rebuildSuggestions) {
if (rebuildSuggestions) {
// recheck to see if any suggestions have been changed.
new SuggestionLoader().execute();
// Set categories on their own if loading suggestions takes too long.
mHandler.postDelayed(() -> {
updateCategoryAndSuggestion(null /* tiles */);
}, MAX_WAIT_MILLIS);
} else {
@VisibleForTesting
void rebuildUI() {
new SuggestionLoader().execute();
// Set categories on their own if loading suggestions takes too long.
mHandler.postDelayed(() -> {
updateCategoryAndSuggestion(null /* tiles */);
}
}, MAX_WAIT_MILLIS);
}
@Override
public void onCategoriesChanged() {
rebuildUI(false /* rebuildSuggestions */);
// Bypass rebuildUI() on the first call of onCategoriesChanged, since rebuildUI() happens
// in onViewCreated as well when app starts. But, on the subsequent calls we need to
// rebuildUI() because there might be some changes to suggestions and categories.
if (isOnCategoriesChangedCalled) {
rebuildUI();
}
isOnCategoriesChangedCalled = true;
}
@Override