summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Joshua Tsuji <tsuji@google.com> 2019-04-05 14:21:53 -0400
committer Josh Tsuji <tsuji@google.com> 2019-04-05 18:27:27 +0000
commitd54e8e044ff3efa34843d6274c17fa0272cd3603 (patch)
treed292922832c3526bdfcaa83f88892fedc0659761
parent7cefe09ec7e0fc297428639630fc982b9724961b (diff)
Run end actions immediately if there are no children to animate.
This fixes several issues around dismissing the last bubble while in the expanded state, since end actions passed to collapseToStack were never run. Test: atest SystemUITests Fixes: 128603791 Fixes: 129359745 Change-Id: I6840c6b0f417c96f7927e96261c9d9436b13c426
-rw-r--r--packages/SystemUI/src/com/android/systemui/bubbles/animation/PhysicsAnimationLayout.java18
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/bubbles/animation/PhysicsAnimationLayoutTest.java13
2 files changed, 26 insertions, 5 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/animation/PhysicsAnimationLayout.java b/packages/SystemUI/src/com/android/systemui/bubbles/animation/PhysicsAnimationLayout.java
index 0f659c338ce8..460652612593 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/animation/PhysicsAnimationLayout.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/animation/PhysicsAnimationLayout.java
@@ -202,13 +202,21 @@ public class PhysicsAnimationLayout extends FrameLayout {
// add a multiple property end listener to the layout that will call the end action
// provided to startAll() once all animations on the animated properties complete.
return (endActions) -> {
+ final Runnable runAllEndActions = () -> {
+ for (Runnable action : endActions) {
+ action.run();
+ }
+ };
+
+ // If there aren't any children to animate, just run the end actions.
+ if (mLayout.getChildCount() == 0) {
+ runAllEndActions.run();
+ return;
+ }
+
if (endActions != null) {
mLayout.setEndActionForMultipleProperties(
- () -> {
- for (Runnable action : endActions) {
- action.run();
- }
- },
+ runAllEndActions,
allAnimatedProperties.toArray(
new DynamicAnimation.ViewProperty[0]));
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/bubbles/animation/PhysicsAnimationLayoutTest.java b/packages/SystemUI/tests/src/com/android/systemui/bubbles/animation/PhysicsAnimationLayoutTest.java
index 38a90f7a52d2..eef6ddcf6d6b 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/bubbles/animation/PhysicsAnimationLayoutTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/bubbles/animation/PhysicsAnimationLayoutTest.java
@@ -25,6 +25,7 @@ import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
import android.os.SystemClock;
import android.testing.AndroidTestingRunner;
@@ -449,6 +450,18 @@ public class PhysicsAnimationLayoutTest extends PhysicsAnimationLayoutTestCase {
Mockito.verify(allEnd, times(1)).run();
}
+ @Test
+ public void testAnimationsForChildrenFromIndex_noChildren() {
+ mLayout.setController(mTestableController);
+
+ final Runnable after = Mockito.mock(Runnable.class);
+ mTestableController
+ .animationsForChildrenFromIndex(0, (index, animation) -> { })
+ .startAll(after);
+
+ verify(after, Mockito.times(1)).run();
+ }
+
/**
* Animation controller with configuration methods whose return values can be set by individual
* tests.