Merge "Only calling finishedwhen all the animations have finished" into qt-qpr1-dev

This commit is contained in:
Selim Cinek
2019-09-30 20:12:54 +00:00
committed by Android (Google) Code Review
2 changed files with 19 additions and 0 deletions

View File

@@ -754,6 +754,16 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, OnCo
}
private void onFinished(Callback callback) {
if (!hasReachedFinalState(mScrimBehind)
|| !hasReachedFinalState(mScrimInFront)
|| !hasReachedFinalState(mScrimForBubble)) {
if (callback != null && callback != mCallback) {
// Since we only notify the callback that we're finished once everything has
// finished, we need to make sure that any changing callbacks are also invoked
callback.onFinished();
}
return;
}
if (mWakeLockHeld) {
mWakeLock.release(TAG);
mWakeLockHeld = false;
@@ -773,9 +783,17 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, OnCo
mInFrontTint = Color.TRANSPARENT;
mBehindTint = Color.TRANSPARENT;
mBubbleTint = Color.TRANSPARENT;
updateScrimColor(mScrimInFront, mInFrontAlpha, mInFrontTint);
updateScrimColor(mScrimBehind, mBehindAlpha, mBehindTint);
updateScrimColor(mScrimForBubble, mBubbleAlpha, mBubbleTint);
}
}
private boolean hasReachedFinalState(ScrimView scrim) {
return scrim.getViewAlpha() == getCurrentScrimAlpha(scrim)
&& scrim.getTint() == getCurrentScrimTint(scrim);
}
private boolean isAnimating(View scrim) {
return scrim.getTag(TAG_KEY_ANIM) != null;
}

View File

@@ -431,6 +431,7 @@ public class ScrimControllerTest extends SysuiTestCase {
TRANSPARENT /* behind */,
TRANSPARENT /* bubble */);
// Make sure at the very end of the animation, we're reset to transparent
assertScrimTint(false /* front */,
false /* behind */,
false /* bubble */);