| 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 0b0ed0ec58ec9a4dce1b61cb4dfe394f1aa607f7..68c846edd288becd7bd243c4eac93fff84df3f88 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
|
| @@ -114,7 +114,7 @@ public void offlinePageDeleted(long offlineId, ClientId clientId) {
|
| };
|
| mOfflinePageBridge.addObserver(mOfflinePageObserver);
|
|
|
| - refreshChildrenVisibility();
|
| + mStatus.setVisible(!hasSuggestions());
|
| }
|
|
|
| private static class SuggestionsList extends ChildNode implements Iterable<SnippetArticle> {
|
| @@ -240,8 +240,15 @@ public void detach() {
|
| super.detach();
|
| }
|
|
|
| - private void refreshChildrenVisibility() {
|
| - mStatus.setVisible(!hasSuggestions());
|
| + private void onSuggestionsListCountChanged(int oldSuggestionsCount) {
|
| + int newSuggestionsCount = getSuggestionsCount();
|
| + if ((newSuggestionsCount == 0) == (oldSuggestionsCount == 0)) return;
|
| +
|
| + mStatus.setVisible(newSuggestionsCount == 0);
|
| +
|
| + // When the ActionItem stops being dismissable, it is possible that it was being interacted
|
| + // with. We need to reset the view's related property changes.
|
| + mMoreButton.notifyItemChanged(0, NewTabPageRecyclerView.RESET_FOR_DISMISS_CALLBACK);
|
| }
|
|
|
| @Override
|
| @@ -258,7 +265,13 @@ public void dismissItem(int position, Callback<String> itemRemovedCallback) {
|
| @Override
|
| public void onItemRangeRemoved(TreeNode child, int index, int count) {
|
| super.onItemRangeRemoved(child, index, count);
|
| - if (child == mSuggestionsList) refreshChildrenVisibility();
|
| + if (child == mSuggestionsList) onSuggestionsListCountChanged(getSuggestionsCount() + count);
|
| + }
|
| +
|
| + @Override
|
| + public void onItemRangeInserted(TreeNode child, int index, int count) {
|
| + super.onItemRangeInserted(child, index, count);
|
| + if (child == mSuggestionsList) onSuggestionsListCountChanged(getSuggestionsCount() - count);
|
| }
|
|
|
| @Override
|
| @@ -407,8 +420,6 @@ public void setSuggestions(List<SnippetArticle> suggestions, @CategoryStatusEnum
|
| updateSnippetOfflineAvailability(article);
|
| }
|
| }
|
| -
|
| - refreshChildrenVisibility();
|
| }
|
|
|
| private void updateSnippetOfflineAvailability(final SnippetArticle article) {
|
| @@ -447,7 +458,6 @@ public void onFetchStarted() {
|
| public void setStatus(@CategoryStatusEnum int status) {
|
| if (!SnippetsBridge.isCategoryStatusAvailable(status)) mSuggestionsList.clear();
|
| mProgressIndicator.setVisible(SnippetsBridge.isCategoryLoading(status));
|
| - refreshChildrenVisibility();
|
| }
|
|
|
| @CategoryInt
|
|
|