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

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

Issue 2249903003: 📰 Empty state handling for the Bookmarks section (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix tests 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
Index: chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/SuggestionsSection.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/SuggestionsSection.java b/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/SuggestionsSection.java
index 6fea61f11cbd63d33edad7f9d79920ffaf99f54d..e50a6867e6f8c5e0a69561196b44a71ebeff0145 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/SuggestionsSection.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/SuggestionsSection.java
@@ -5,6 +5,7 @@
package org.chromium.chrome.browser.ntp.cards;
import org.chromium.chrome.browser.ChromeFeatureList;
+import org.chromium.chrome.browser.ntp.cards.StatusItem.StatusActionDelegate;
import org.chromium.chrome.browser.ntp.snippets.CategoryStatus.CategoryStatusEnum;
import org.chromium.chrome.browser.ntp.snippets.KnownCategories;
import org.chromium.chrome.browser.ntp.snippets.SectionHeader;
@@ -23,12 +24,12 @@
private final SectionHeader mHeader;
private StatusItem mStatus;
private final ProgressItem mProgressIndicator = new ProgressItem();
+ private final StatusActionDelegate mStatusActionDelegate;
private final ActionItem mMoreButton;
public SuggestionsSection(int category, List<SnippetArticle> suggestions,
@CategoryStatusEnum int status, SuggestionsCategoryInfo info,
- NewTabPageAdapter adapter) {
-
+ final NewTabPageAdapter adapter) {
mHeader = new SectionHeader(info.getTitle());
// TODO(pke): Replace the condition with "info.hasMoreButton()" once all other categories
// are supported by the C++ backend, too.
@@ -40,7 +41,20 @@ public SuggestionsSection(int category, List<SnippetArticle> suggestions,
showMoreButton = ChromeFeatureList.isEnabled("DownloadsUi");
}
mMoreButton = showMoreButton ? new ActionItem(category) : null;
- setSuggestions(suggestions, status, adapter);
+
+ // TODO(dgn): Properly define strings, actions, etc. for each section and category type.
+ if (showMoreButton) {
+ mStatusActionDelegate = null;
+ } else {
+ mStatusActionDelegate = new StatusActionDelegate() {
+ @Override
+ public void onButtonTapped() {
+ adapter.reloadSnippets();
+ }
+ };
+ }
+
+ setSuggestions(suggestions, status);
}
@Override
@@ -48,12 +62,11 @@ public SuggestionsSection(int category, List<SnippetArticle> suggestions,
List<NewTabPageItem> items = new ArrayList<>();
items.add(mHeader);
items.addAll(mSuggestions);
- if (mSuggestions.isEmpty()) {
- items.add(mStatus);
- items.add(mProgressIndicator);
- } else if (mMoreButton != null) {
- items.add(mMoreButton);
- }
+
+ if (mSuggestions.isEmpty()) items.add(mStatus);
+ if (mMoreButton != null) items.add(mMoreButton);
+ if (mSuggestions.isEmpty()) items.add(mProgressIndicator);
+
return Collections.unmodifiableList(items);
}
@@ -65,11 +78,11 @@ public boolean hasSuggestions() {
return !mSuggestions.isEmpty();
}
- public void setSuggestions(List<SnippetArticle> suggestions,
- @CategoryStatusEnum int status, NewTabPageAdapter adapter) {
+ public void setSuggestions(List<SnippetArticle> suggestions, @CategoryStatusEnum int status) {
copyThumbnails(suggestions);
- mStatus = StatusItem.create(status, adapter);
+ mStatus = StatusItem.create(status, mStatusActionDelegate);
+
mProgressIndicator.setVisible(SnippetsBridge.isCategoryLoading(status));
mSuggestions.clear();

Powered by Google App Engine
This is Rietveld 408576698