Fixes a crash in the AllAppsFastScrollHelper where on updating the activated flag
on the views it was trying to retrieve an item from the model for a non-existing
position in the model.
The fix is to check the position to the model size. It's not clear in what circumstance
the model (ArrayList) can differ to the position returned from the view-holder's
getAdapterPosition().
Bug: 36176501
Change-Id: I01b8daaad884702f9ed0e1caaa03d0ebaca69d39
diff --git a/src/com/android/launcher3/allapps/AllAppsFastScrollHelper.java b/src/com/android/launcher3/allapps/AllAppsFastScrollHelper.java
index a1ff822..7d70a3e 100644
--- a/src/com/android/launcher3/allapps/AllAppsFastScrollHelper.java
+++ b/src/com/android/launcher3/allapps/AllAppsFastScrollHelper.java
@@ -210,7 +210,9 @@
for (RecyclerView.ViewHolder viewHolder : mTrackedFastScrollViews) {
int pos = viewHolder.getAdapterPosition();
boolean isActive = false;
- if (mCurrentFastScrollSection != null && pos > -1) {
+ if (mCurrentFastScrollSection != null
+ && pos > RecyclerView.NO_POSITION
+ && pos < mApps.getAdapterItems().size()) {
AlphabeticalAppsList.AdapterItem item = mApps.getAdapterItems().get(pos);
isActive = item != null &&
mCurrentFastScrollSection.equals(item.sectionName) &&