Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4799)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/NewTabPageAdapter.java

Issue 2230303003: Remove Error cards for content suggestions, error case refine behavior (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@allowmoreflag
Patch Set: Rebase (should be no change) Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/StatusListItem.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/NewTabPageAdapter.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/NewTabPageAdapter.java b/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/NewTabPageAdapter.java
index 853dcae6e7e29d3b9464603d0eb19a748fd0b03b..5f34f59a898c294713da8650ea71be5f3410f2be 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/NewTabPageAdapter.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/NewTabPageAdapter.java
@@ -126,8 +126,14 @@ public class NewTabPageAdapter extends Adapter<NewTabPageViewHolder>
mUiConfig = uiConfig;
for (int category : mSuggestionsSource.getCategories()) {
+ int categoryStatus = suggestionsSource.getCategoryStatus(category);
+ assert categoryStatus != CategoryStatus.NOT_PROVIDED;
+ if (categoryStatus == CategoryStatus.LOADING_ERROR
+ || categoryStatus == CategoryStatus.CATEGORY_EXPLICITLY_DISABLED)
+ continue;
+
setSuggestions(category, suggestionsSource.getSuggestionsForCategory(category),
- suggestionsSource.getCategoryStatus(category));
+ categoryStatus);
}
suggestionsSource.setObserver(this);
updateGroups();
@@ -172,13 +178,27 @@ public class NewTabPageAdapter extends Adapter<NewTabPageViewHolder>
// If there is no section for this category there is nothing to do.
if (!mSections.containsKey(category)) return;
+ // The section provider has gone away. Keep open UIs as they are.
+ if (status == CategoryStatus.NOT_PROVIDED) return;
+
SuggestionsSection section = mSections.get(category);
// The section already has suggestions but we just got notified about the provider being
// enabled. Nothing to do.
if (SnippetsBridge.isCategoryStatusAvailable(status) && section.hasSuggestions()) return;
- setSuggestions(category, Collections.<SnippetArticleListItem>emptyList(), status);
+ if (status == CategoryStatus.CATEGORY_EXPLICITLY_DISABLED
+ || status == CategoryStatus.LOADING_ERROR) {
+ // Need to remove the entire section from the UI immediately.
+ mSections.remove(category);
+ } else {
+ // Two cases, in both we just want to update the status:
+ // - status is one of the AVAILABLE statuses, but we didn't have suggestions before and
+ // we're also not getting them now (but probably right after in OnNewSuggestions).
+ // - status is non-AVAILABLE, but also none of the serious ones above, so this will
+ // show a status card and remove the current content.
+ setSuggestions(category, Collections.<SnippetArticleListItem>emptyList(), status);
+ }
updateGroups();
}
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/StatusListItem.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698