| 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();
|
|
|