Merge "Fix issues with TrustDrawable" into lmp-mr1-dev

This commit is contained in:
Adrian Roos
2014-10-20 15:19:13 +00:00
committed by Android (Google) Code Review

View File

@@ -133,6 +133,7 @@ public class TrustDrawable extends Drawable {
if (!mAnimating) { if (!mAnimating) {
mAnimating = true; mAnimating = true;
updateState(true); updateState(true);
invalidateSelf();
} }
} }
@@ -146,18 +147,21 @@ public class TrustDrawable extends Drawable {
mState = STATE_UNSET; mState = STATE_UNSET;
mCurAlpha = 0; mCurAlpha = 0;
mCurInnerRadius = mInnerRadiusEnter; mCurInnerRadius = mInnerRadiusEnter;
invalidateSelf();
} }
} }
public void setTrustManaged(boolean trustManaged) { public void setTrustManaged(boolean trustManaged) {
if (trustManaged == mTrustManaged && mState != STATE_UNSET) return; if (trustManaged == mTrustManaged && mState != STATE_UNSET) return;
mTrustManaged = trustManaged; mTrustManaged = trustManaged;
if (mAnimating) { updateState(true);
updateState(true);
}
} }
private void updateState(boolean animate) { private void updateState(boolean allowTransientState) {
if (!mAnimating) {
return;
}
int nextState = mState; int nextState = mState;
if (mState == STATE_UNSET) { if (mState == STATE_UNSET) {
nextState = mTrustManaged ? STATE_ENTERING : STATE_GONE; nextState = mTrustManaged ? STATE_ENTERING : STATE_GONE;
@@ -170,7 +174,7 @@ public class TrustDrawable extends Drawable {
} else if (mState == STATE_EXITING) { } else if (mState == STATE_EXITING) {
if (mTrustManaged) nextState = STATE_ENTERING; if (mTrustManaged) nextState = STATE_ENTERING;
} }
if (!animate) { if (!allowTransientState) {
if (nextState == STATE_ENTERING) nextState = STATE_VISIBLE; if (nextState == STATE_ENTERING) nextState = STATE_VISIBLE;
if (nextState == STATE_EXITING) nextState = STATE_GONE; if (nextState == STATE_EXITING) nextState = STATE_GONE;
} }
@@ -200,9 +204,8 @@ public class TrustDrawable extends Drawable {
mState = nextState; mState = nextState;
if (mCurAnimator != null) { if (mCurAnimator != null) {
mCurAnimator.start(); mCurAnimator.start();
} else {
invalidateSelf();
} }
invalidateSelf();
} }
} }