Deferring all app updates until the pending executor is complete.

We were only deferring full apps binds and not partial updates which could cause
the model to go out of sync with Launcher.

Bug: 72051234
Change-Id: I20db0e86aadd1e6a518237026f6dfb03e469eb87
This commit is contained in:
Sunny Goyal
2018-02-07 12:56:30 -08:00
parent 168ca694f9
commit 60180b049e
3 changed files with 68 additions and 84 deletions

View File

@@ -116,6 +116,8 @@ public class AllAppsContainerView extends RelativeLayout implements DragSource,
mAH = new AdapterHolder[2];
mAH[AdapterHolder.MAIN] = new AdapterHolder(false /* isWork */);
mAH[AdapterHolder.WORK] = new AdapterHolder(true /* isWork */);
mAllAppsStore.addUpdateListener(this::onAppsUpdated);
}
@Override
@@ -150,42 +152,24 @@ public class AllAppsContainerView extends RelativeLayout implements DragSource,
}
}
private void onAppsUpdated() {
if (FeatureFlags.ALL_APPS_TABS_ENABLED) {
boolean hasWorkApps = false;
for (AppInfo app : mAllAppsStore.getApps()) {
if (mWorkMatcher.matches(app, null)) {
hasWorkApps = true;
break;
}
}
rebindAdapters(hasWorkApps);
}
}
@Override
public void setPressedIcon(BubbleTextView icon, Bitmap background) {
mTouchFeedbackView.setPressedIcon(icon, background);
}
/**
* Sets the current set of apps.
*/
public void setApps(List<AppInfo> apps) {
boolean hasWorkProfileApp = hasWorkProfileApp(apps);
rebindAdapters(hasWorkProfileApp);
mAllAppsStore.setApps(apps);
}
/**
* Adds or updates existing apps in the list
*/
public void addOrUpdateApps(List<AppInfo> apps) {
mAllAppsStore.addOrUpdateApps(apps);
}
/**
* Removes some apps from the list.
*/
public void removeApps(List<AppInfo> apps) {
mAllAppsStore.removeApps(apps);
}
public void updatePromiseAppProgress(PromiseAppInfo app) {
mAllAppsStore.updateAllIcons((child) -> {
if (child.getTag() == app) {
child.applyProgressLevel(app.level);
}
});
}
/**
* Returns whether the view itself will handle the touch event or not.
*/
@@ -324,18 +308,6 @@ public class AllAppsContainerView extends RelativeLayout implements DragSource,
InsettableFrameLayout.dispatchInsets(this, insets);
}
public void updateIconBadges(Set<PackageUserKey> updatedBadges) {
PackageUserKey tempKey = new PackageUserKey(null, null);
mAllAppsStore.updateAllIcons((child) -> {
if (child.getTag() instanceof ItemInfo) {
ItemInfo info = (ItemInfo) child.getTag();
if (tempKey.updateFromItemInfo(info) && updatedBadges.contains(tempKey)) {
child.applyBadgeState(info, true /* animate */);
}
}
});
}
public SpringAnimationHandler getSpringAnimationHandler() {
return mUsingTabs ? null : mAH[AdapterHolder.MAIN].animationHandler;
}
@@ -371,17 +343,6 @@ public class AllAppsContainerView extends RelativeLayout implements DragSource,
applyTouchDelegate();
}
private boolean hasWorkProfileApp(List<AppInfo> apps) {
if (FeatureFlags.ALL_APPS_TABS_ENABLED) {
for (AppInfo app : apps) {
if (mWorkMatcher.matches(app, null)) {
return true;
}
}
}
return false;
}
private void replaceRVContainer(boolean showTabs) {
for (int i = 0; i < mAH.length; i++) {
if (mAH[i].recyclerView != null) {