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

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

Issue 2618893003: 📰 Tweak the suggestion ranks for UMA to handle fetchMore (Closed)
Patch Set: Fix action item reported position 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
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 088ee0ac5b9c8190e1ce233fe6a6d697bf86370b..0abe2543ad8b9dfbfaa43a920f0e9aeff4dc03b7 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
@@ -9,6 +9,7 @@
import org.chromium.base.VisibleForTesting;
import org.chromium.chrome.browser.ntp.NewTabPage.DestructionObserver;
import org.chromium.chrome.browser.ntp.NewTabPageView.NewTabPageManager;
+import org.chromium.chrome.browser.ntp.cards.SectionList.SuggestionRanker;
import org.chromium.chrome.browser.ntp.snippets.CategoryInt;
import org.chromium.chrome.browser.ntp.snippets.CategoryStatus.CategoryStatusEnum;
import org.chromium.chrome.browser.ntp.snippets.SectionHeader;
@@ -34,6 +35,7 @@
private final Delegate mDelegate;
private final SuggestionsCategoryInfo mCategoryInfo;
private final OfflinePageBridge mOfflinePageBridge;
+ private final SuggestionRanker mSuggestionRanker;
// Children
private final SectionHeader mHeader;
@@ -59,11 +61,12 @@
void dismissSection(SuggestionsSection section);
}
- public SuggestionsSection(Delegate delegate, NewTabPageManager manager,
+ public SuggestionsSection(Delegate delegate, NewTabPageManager manager, SuggestionRanker ranker,
OfflinePageBridge offlinePageBridge, SuggestionsCategoryInfo info) {
mDelegate = delegate;
mCategoryInfo = info;
mOfflinePageBridge = offlinePageBridge;
+ mSuggestionRanker = ranker;
mHeader = new SectionHeader(info.getTitle());
mSuggestionsList = new SuggestionsList(manager, info);
@@ -248,8 +251,14 @@ public void onItemRangeRemoved(TreeNode child, int index, int count) {
@Override
public void onBindViewHolder(NewTabPageViewHolder holder, int position, List<Object> payloads) {
+ @ItemViewType
+ int viewType = getItemViewType(position);
+ if (viewType == ItemViewType.SNIPPET) {
+ childSeen(position);
+ } else if (viewType == ItemViewType.ACTION) {
+ mSuggestionRanker.rankItem((ActionItem) getChildForPosition(position), this);
Bernhard Bauer 2017/01/17 17:42:31 Could we have the ActionItem itself call this?
dgn 2017/01/17 18:46:24 Done.
+ }
super.onBindViewHolder(holder, position, payloads);
- childSeen(position);
}
/**
@@ -261,14 +270,14 @@ public void onBindViewHolder(NewTabPageViewHolder holder, int position, List<Obj
public void childSeen(int position) {
Bernhard Bauer 2017/01/17 17:42:31 If this is only called for suggestions now, rename
dgn 2017/01/17 18:46:24 Reverted since actionItem calls its ranker itself.
Log.d(TAG, "childSeen: position %d in category %d", position, mCategoryInfo.getCategory());
assert getStartingOffsetForChild(mSuggestionsList) == 1;
- if (getItemViewType(position) == ItemViewType.SNIPPET) {
- // We assume all non-snippet cards come after all cards of type SNIPPET.
- int positionAmongSuggestions = position - 1;
- if (positionAmongSuggestions == 0) {
- mFirstSuggestionSeen = true;
- } else if (positionAmongSuggestions > 0) {
- mSubsequentSuggestionsSeen = true;
- }
+ assert getItemViewType(position) == ItemViewType.SNIPPET;
+
+ // We assume all non-snippet cards come after all cards of type SNIPPET.
+ int positionAmongSuggestions = position - 1;
+ if (positionAmongSuggestions == 0) {
+ mFirstSuggestionSeen = true;
+ } else if (positionAmongSuggestions > 0) {
+ mSubsequentSuggestionsSeen = true;
}
}
@@ -349,6 +358,7 @@ public void setSuggestions(List<SnippetArticle> suggestions, @CategoryStatusEnum
mSuggestionsList.addAll(suggestions);
for (SnippetArticle article : suggestions) {
+ mSuggestionRanker.rankItem(article);
if (!article.requiresExactOfflinePage()) {
updateSnippetOfflineAvailability(article);
}

Powered by Google App Engine
This is Rietveld 408576698