summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorWinson Chung <winsonc@google.com>2015-03-30 14:25:04 -0700
committerWinson Chung <winsonc@google.com>2015-03-30 15:28:43 -0700
commit24cf70092b8b0281df071891573642f56e34f9e5 (patch)
tree64626a533bf4574793c06619746c9ece4c8db143 /src
parentb272ca83f0904ed7256de42e3ec8cfb7738a9372 (diff)
downloadandroid_packages_apps_Trebuchet-24cf70092b8b0281df071891573642f56e34f9e5.tar.gz
android_packages_apps_Trebuchet-24cf70092b8b0281df071891573642f56e34f9e5.tar.bz2
android_packages_apps_Trebuchet-24cf70092b8b0281df071891573642f56e34f9e5.zip
Ensuring that we fast-scroll to the first section app.
Bug: 19992026 Change-Id: Ia015b870f80fa598fa68087f90236c59b0ad7e6d
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher3/AppsContainerRecyclerView.java14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/com/android/launcher3/AppsContainerRecyclerView.java b/src/com/android/launcher3/AppsContainerRecyclerView.java
index 0cc651417..b942ea451 100644
--- a/src/com/android/launcher3/AppsContainerRecyclerView.java
+++ b/src/com/android/launcher3/AppsContainerRecyclerView.java
@@ -23,6 +23,7 @@ import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
+import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.view.MotionEvent;
@@ -290,14 +291,14 @@ public class AppsContainerRecyclerView extends RecyclerView
// Get the total number of rows
int rowCount = getNumRows();
- // Find the index of the first app in that row and scroll to that position
+ // Find the position of the first application in the section that contains the row at the
+ // current progress
int rowAtProgress = (int) (progress * rowCount);
int appIndex = 0;
rowCount = 0;
for (AlphabeticalAppsList.SectionInfo info : sections) {
int numRowsInSection = (int) Math.ceil((float) info.numAppsInSection / mNumAppsPerRow);
if (rowCount + numRowsInSection > rowAtProgress) {
- appIndex += (rowAtProgress - rowCount) * mNumAppsPerRow;
break;
}
rowCount += numRowsInSection;
@@ -306,9 +307,14 @@ public class AppsContainerRecyclerView extends RecyclerView
appIndex = Math.max(0, Math.min(mApps.getAppsWithoutSectionBreaks().size() - 1, appIndex));
AppInfo appInfo = mApps.getAppsWithoutSectionBreaks().get(appIndex);
int sectionedAppIndex = mApps.getApps().indexOf(appInfo);
- scrollToPosition(sectionedAppIndex);
- // Returns the section name of the row
+ // Scroll the position into view, anchored at the top of the screen if possible. We call the
+ // scroll method on the LayoutManager directly since it is not exposed by RecyclerView.
+ LinearLayoutManager layoutManager = (LinearLayoutManager) getLayoutManager();
+ stopScroll();
+ layoutManager.scrollToPositionWithOffset(sectionedAppIndex, 0);
+
+ // Return the section name of the row
return mApps.getSectionNameForApp(appInfo);
}