diff options
author | Jon Miranda <jonmiranda@google.com> | 2017-06-27 08:37:14 -0700 |
---|---|---|
committer | Jon Miranda <jonmiranda@google.com> | 2017-06-27 08:37:14 -0700 |
commit | e309c6dc240be5e6e7ce84a5a8af1d31f6054bdf (patch) | |
tree | dec299231f26f0faafdee10351c7184386ebd61c /src/com/android/launcher3/allapps | |
parent | a80b18420609e1d9dab27be4d38e0c7263d4c8b0 (diff) | |
download | android_packages_apps_Trebuchet-e309c6dc240be5e6e7ce84a5a8af1d31f6054bdf.tar.gz android_packages_apps_Trebuchet-e309c6dc240be5e6e7ce84a5a8af1d31f6054bdf.tar.bz2 android_packages_apps_Trebuchet-e309c6dc240be5e6e7ce84a5a8af1d31f6054bdf.zip |
Fix getAppPosition calculation since search divider removed from RV.
The app position calculations were off by 1 since the search divider
used to be the first item in the RecyclerView.
Bug: 38349031
Change-Id: I8c161b940ec8015aab85b0aab94718e6fee8fcbd
Diffstat (limited to 'src/com/android/launcher3/allapps')
-rw-r--r-- | src/com/android/launcher3/allapps/AllAppsGridAdapter.java | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/src/com/android/launcher3/allapps/AllAppsGridAdapter.java b/src/com/android/launcher3/allapps/AllAppsGridAdapter.java index 1054a5633..ba4fbe061 100644 --- a/src/com/android/launcher3/allapps/AllAppsGridAdapter.java +++ b/src/com/android/launcher3/allapps/AllAppsGridAdapter.java @@ -481,19 +481,17 @@ public class AllAppsGridAdapter extends RecyclerView.Adapter<AllAppsGridAdapter. * 5 6 7 8 9 */ private int getAppPosition(int position, int numPredictedApps, int appsPerRow) { - int appPosition = position; - int numDividerViews = 1 + (numPredictedApps == 0 ? 0 : 1); - - int allAppsStartAt = numDividerViews + numPredictedApps; - if (numDividerViews == 1 || position < allAppsStartAt) { - appPosition -= 1; - } else { - // We cannot assume that the predicted row will always be full. - int numPredictedAppsOffset = appsPerRow - numPredictedApps; - appPosition = position + numPredictedAppsOffset - numDividerViews; + if (position < numPredictedApps) { + // Predicted apps are first in the adapter. + return position; } - return appPosition; + // There is at most 1 divider view between the predicted apps and the alphabetical apps. + int numDividerViews = numPredictedApps == 0 ? 0 : 1; + + // This offset takes into consideration an incomplete row of predicted apps. + int numPredictedAppsOffset = appsPerRow - numPredictedApps; + return position + numPredictedAppsOffset - numDividerViews; } /** |