Chromium Code Reviews| 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 54a70948c5dc48ef31bc798cb48c1506cb9023cd..e6c186568bd81c8166621e6181ed908445657083 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,20 @@ 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() { |
| + int position = mLayoutManager.findFirstVisibleItemPosition(); |
| + if (position == NO_POSITION) position = 0; |
|
Bernhard Bauer
2016/09/16 15:02:50
Actually, we could probably return NO_POSITION in
Michael van Ouwerkerk
2016/09/16 16:35:05
Done.
|
| + return position; |
| + } |
| + |
| + /** |
| * Finds the view holder for the first header. |
| * @return The {@code ViewHolder} of the header, or null if it is not present. |
| */ |