Merge "Fix missing finish callback to fix running animation leak" into rvc-dev
This commit is contained in:
@@ -140,7 +140,12 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll
|
||||
|
||||
@Override
|
||||
public void setInsetsAndAlpha(Insets insets, float alpha, float fraction) {
|
||||
if (mFinished) {
|
||||
setInsetsAndAlpha(insets, alpha, fraction, false /* allowWhenFinished */);
|
||||
}
|
||||
|
||||
private void setInsetsAndAlpha(Insets insets, float alpha, float fraction,
|
||||
boolean allowWhenFinished) {
|
||||
if (!allowWhenFinished && mFinished) {
|
||||
throw new IllegalStateException(
|
||||
"Can't change insets on an animation that is finished.");
|
||||
}
|
||||
@@ -201,8 +206,9 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll
|
||||
return;
|
||||
}
|
||||
mShownOnFinish = shown;
|
||||
setInsetsAndAlpha(shown ? mShownInsets : mHiddenInsets, 1f /* alpha */, 1f /* fraction */);
|
||||
mFinished = true;
|
||||
setInsetsAndAlpha(shown ? mShownInsets : mHiddenInsets, 1f /* alpha */, 1f /* fraction */,
|
||||
true /* allowWhenFinished */);
|
||||
mListener.onFinished(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.doAnswer;
|
||||
import static org.mockito.Mockito.doNothing;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
@@ -222,6 +223,22 @@ public class InsetsAnimationControlImplTest {
|
||||
verify(mMockListener, never()).onFinished(any());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFinish_immediately() {
|
||||
when(mMockController.getState()).thenReturn(mInsetsState);
|
||||
doAnswer(invocation -> {
|
||||
mController.applyChangeInsets(mInsetsState);
|
||||
return null;
|
||||
}).when(mMockController).scheduleApplyChangeInsets();
|
||||
mController.finish(true /* shown */);
|
||||
assertEquals(Insets.of(0, 100, 100, 0), mController.getCurrentInsets());
|
||||
verify(mMockController).notifyFinished(eq(mController), eq(true /* shown */));
|
||||
assertFalse(mController.isReady());
|
||||
assertTrue(mController.isFinished());
|
||||
assertFalse(mController.isCancelled());
|
||||
verify(mMockListener).onFinished(mController);
|
||||
}
|
||||
|
||||
private void assertPosition(Matrix m, Rect original, Rect transformed) {
|
||||
RectF rect = new RectF(original);
|
||||
rect.offsetTo(0, 0);
|
||||
|
||||
@@ -367,7 +367,6 @@ class InsetsPolicy {
|
||||
@Override
|
||||
protected void onAnimationFinish() {
|
||||
super.onAnimationFinish();
|
||||
mControlCallbacks.mAnimationControl.finish(mAnimatingShown);
|
||||
DisplayThread.getHandler().post(mFinishCallback);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user