Implementing support for item diffing instead of creating out the

complete UI on every update

Bug: 229860311
Test: Verified locally
Change-Id: I5712b5d76878a0ed72cc1392ede59b3778b7a1dc
This commit is contained in:
Sunny Goyal
2022-05-01 12:18:14 -07:00
parent e73c3075c1
commit 3c5a08ada1
11 changed files with 149 additions and 170 deletions

View File

@@ -71,6 +71,26 @@ public class AllAppsRecyclerView extends BaseRecyclerView {
public void onChanged() {
mCachedScrollPositions.clear();
}
@Override
public void onItemRangeChanged(int positionStart, int itemCount) {
onChanged();
}
@Override
public void onItemRangeInserted(int positionStart, int itemCount) {
onChanged();
}
@Override
public void onItemRangeRemoved(int positionStart, int itemCount) {
onChanged();
}
@Override
public void onItemRangeMoved(int fromPosition, int toPosition, int itemCount) {
onChanged();
}
};
// The empty-search result background
@@ -241,17 +261,14 @@ public class AllAppsRecyclerView extends BaseRecyclerView {
// Find the fastscroll section that maps to this touch fraction
List<AlphabeticalAppsList.FastScrollSectionInfo> fastScrollSections =
mApps.getFastScrollerSections();
AlphabeticalAppsList.FastScrollSectionInfo lastInfo = fastScrollSections.get(0);
for (int i = 1; i < fastScrollSections.size(); i++) {
AlphabeticalAppsList.FastScrollSectionInfo info = fastScrollSections.get(i);
if (info.touchFraction > touchFraction) {
break;
}
lastInfo = info;
int count = fastScrollSections.size();
if (count == 0) {
return "";
}
mFastScrollHelper.smoothScrollToSection(lastInfo);
return lastInfo.sectionName;
int index = Utilities.boundToRange((int) (touchFraction * count), 0, count - 1);
AlphabeticalAppsList.FastScrollSectionInfo section = fastScrollSections.get(index);
mFastScrollHelper.smoothScrollToSection(section);
return section.sectionName;
}
@Override