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

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

Issue 2365313002: Reland: Ntp: restore scroll position. (Closed)
Patch Set: Rebase. Created 4 years, 3 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/NewTabPageRecyclerView.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/NewTabPageRecyclerView.java b/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/NewTabPageRecyclerView.java
index d9f4470a5eb28af3edd95a0305c919af43bca071..99b19a5cd123b66aab5292c3b1639aa883630f86 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/NewTabPageRecyclerView.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/NewTabPageRecyclerView.java
@@ -257,6 +257,18 @@ public class NewTabPageRecyclerView extends RecyclerView {
}
/**
+ * Returns the approximate adapter position that the user has scrolled to. The purpose of this
+ * value is that it can be stored and later retrieved to restore a scroll position that is
+ * familiar to the user, showing (part of) the same content the user was previously looking at.
+ * This position is valid for that purpose regardless of device orientation changes. Note that
+ * if the underlying data has changed in the meantime, different content would be shown for this
+ * position.
+ */
+ public int getScrollPosition() {
+ return mLayoutManager.findFirstVisibleItemPosition();
+ }
+
+ /**
* Finds the view holder for the first header.
* @return The {@code ViewHolder} of the header, or null if it is not present.
*/

Powered by Google App Engine
This is Rietveld 408576698