Merge "Fix missing finish callback to fix running animation leak" into rvc-dev am: 526632d15f am: d49d6f502c
Change-Id: I915a2c072e7f0638d2d81d737bd34c222c2d03f2
This commit is contained in:
@@ -140,7 +140,12 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setInsetsAndAlpha(Insets insets, float alpha, float fraction) {
|
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(
|
throw new IllegalStateException(
|
||||||
"Can't change insets on an animation that is finished.");
|
"Can't change insets on an animation that is finished.");
|
||||||
}
|
}
|
||||||
@@ -201,8 +206,9 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mShownOnFinish = shown;
|
mShownOnFinish = shown;
|
||||||
setInsetsAndAlpha(shown ? mShownInsets : mHiddenInsets, 1f /* alpha */, 1f /* fraction */);
|
|
||||||
mFinished = true;
|
mFinished = true;
|
||||||
|
setInsetsAndAlpha(shown ? mShownInsets : mHiddenInsets, 1f /* alpha */, 1f /* fraction */,
|
||||||
|
true /* allowWhenFinished */);
|
||||||
mListener.onFinished(this);
|
mListener.onFinished(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import static org.mockito.ArgumentMatchers.any;
|
|||||||
import static org.mockito.ArgumentMatchers.anyBoolean;
|
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||||
import static org.mockito.ArgumentMatchers.anyInt;
|
import static org.mockito.ArgumentMatchers.anyInt;
|
||||||
import static org.mockito.ArgumentMatchers.eq;
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
|
import static org.mockito.Mockito.doAnswer;
|
||||||
import static org.mockito.Mockito.doNothing;
|
import static org.mockito.Mockito.doNothing;
|
||||||
import static org.mockito.Mockito.never;
|
import static org.mockito.Mockito.never;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
@@ -222,6 +223,22 @@ public class InsetsAnimationControlImplTest {
|
|||||||
verify(mMockListener, never()).onFinished(any());
|
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) {
|
private void assertPosition(Matrix m, Rect original, Rect transformed) {
|
||||||
RectF rect = new RectF(original);
|
RectF rect = new RectF(original);
|
||||||
rect.offsetTo(0, 0);
|
rect.offsetTo(0, 0);
|
||||||
|
|||||||
@@ -367,7 +367,6 @@ class InsetsPolicy {
|
|||||||
@Override
|
@Override
|
||||||
protected void onAnimationFinish() {
|
protected void onAnimationFinish() {
|
||||||
super.onAnimationFinish();
|
super.onAnimationFinish();
|
||||||
mControlCallbacks.mAnimationControl.finish(mAnimatingShown);
|
|
||||||
DisplayThread.getHandler().post(mFinishCallback);
|
DisplayThread.getHandler().post(mFinishCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user