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

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

Issue 2663313002: 📰 Merge the has_fetch_more and has_reload actions (Closed)
Patch Set: rebase Created 3 years, 11 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/SuggestionsCategoryInfo.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/ActionItem.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/ActionItem.java b/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/ActionItem.java
index 3e6922451d613e60c0a0956f48809d0e15298c52..ddcb2e39c31511cd87f43811ee618b27b1b0cf46 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/ActionItem.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/ActionItem.java
@@ -20,24 +20,22 @@
/**
* Item that allows the user to perform an action on the NTP.
- * Note: Use {@link #refreshVisibility()} to update the visibility of the button instead of calling
- * {@link #setVisible(boolean)} directly.
*/
public class ActionItem extends OptionalLeaf {
- @IntDef({ACTION_NONE, ACTION_VIEW_ALL, ACTION_FETCH_MORE, ACTION_RELOAD})
+ @IntDef({ACTION_NONE, ACTION_VIEW_ALL, ACTION_FETCH})
@Retention(RetentionPolicy.SOURCE)
public @interface Action {}
public static final int ACTION_NONE = 0;
public static final int ACTION_VIEW_ALL = 1;
- public static final int ACTION_FETCH_MORE = 2;
- public static final int ACTION_RELOAD = 3;
+ public static final int ACTION_FETCH = 2;
private final SuggestionsCategoryInfo mCategoryInfo;
private final SuggestionsSection mParentSection;
private final SuggestionsRanker mSuggestionsRanker;
@Action
- private int mCurrentAction = ACTION_NONE;
+ private final int mCurrentAction;
+
private boolean mImpressionTracked;
private int mPerSectionRank = -1;
@@ -45,10 +43,6 @@ public ActionItem(SuggestionsSection section, SuggestionsRanker ranker) {
mCategoryInfo = section.getCategoryInfo();
mParentSection = section;
mSuggestionsRanker = ranker;
- }
-
- /** Call this instead of {@link #setVisible(boolean)} to update the visibility. */
- public void refreshVisibility() {
mCurrentAction = findAppropriateAction();
setVisible(mCurrentAction != ACTION_NONE);
}
@@ -86,8 +80,7 @@ void performAction(SuggestionsUiDelegate uiDelegate) {
case ACTION_VIEW_ALL:
mCategoryInfo.performViewAllAction(uiDelegate.getNavigationDelegate());
return;
- case ACTION_FETCH_MORE:
- case ACTION_RELOAD:
+ case ACTION_FETCH:
uiDelegate.getSuggestionsSource().fetchSuggestions(
mCategoryInfo.getCategory(), mParentSection.getDisplayedSuggestionIds());
mParentSection.onFetchStarted();
@@ -101,10 +94,8 @@ void performAction(SuggestionsUiDelegate uiDelegate) {
@Action
private int findAppropriateAction() {
- boolean hasSuggestions = mParentSection.hasSuggestions();
if (mCategoryInfo.hasViewAllAction()) return ACTION_VIEW_ALL;
- if (hasSuggestions && mCategoryInfo.hasFetchMoreAction()) return ACTION_FETCH_MORE;
- if (!hasSuggestions && mCategoryInfo.hasReloadAction()) return ACTION_RELOAD;
+ if (mCategoryInfo.hasFetchAction()) return ACTION_FETCH;
return ACTION_NONE;
}
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/SuggestionsCategoryInfo.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698