Pause expensive view updates before setting hw/sw layers.
Prevents widgets from updating mid animation.
Also pauses view updates during app close animation.
Bug: 220939231
Bug: 230617085
Bug: 226171754
Test: manual
Change-Id: I0138d57e6a7b2c22fd9a029e971b3e27c7e9f22e
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 1846383..fc7432a 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -3229,11 +3229,24 @@
public void pauseExpensiveViewUpdates() {
// Pause page indicator animations as they lead to layer trashing.
getWorkspace().getPageIndicator().pauseAnimations();
+
+ getWorkspace().mapOverItems((info, view) -> {
+ if (view instanceof LauncherAppWidgetHostView) {
+ ((LauncherAppWidgetHostView) view).beginDeferringUpdates();
+ }
+ return false; // Return false to continue iterating through all the items.
+ });
}
/** Resumes view updates at the end of the app launch animation. */
public void resumeExpensiveViewUpdates() {
getWorkspace().getPageIndicator().skipAnimationsToEnd();
- }
+ getWorkspace().mapOverItems((info, view) -> {
+ if (view instanceof LauncherAppWidgetHostView) {
+ ((LauncherAppWidgetHostView) view).endDeferringUpdates();
+ }
+ return false; // Return false to continue iterating through all the items.
+ });
+ }
}
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index 93f3d9f..4903d77 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -3265,7 +3265,11 @@
}
}
- private View mapOverCellLayout(CellLayout layout, ItemOperator op) {
+ /**
+ * Perform {param operator} over all the items in a given {param layout}.
+ * @return The first item that satisfies the operator or null.
+ */
+ public View mapOverCellLayout(CellLayout layout, ItemOperator operator) {
// TODO(b/128460496) Potential race condition where layout is not yet loaded
if (layout == null) {
return null;
@@ -3275,7 +3279,7 @@
final int itemCount = container.getChildCount();
for (int itemIdx = 0; itemIdx < itemCount; itemIdx++) {
View item = container.getChildAt(itemIdx);
- if (op.evaluate((ItemInfo) item.getTag(), item)) {
+ if (operator.evaluate((ItemInfo) item.getTag(), item)) {
return item;
}
}