summaryrefslogtreecommitdiffstats
path: root/graphics
diff options
context:
space:
mode:
authorAlan Viverette <alanv@google.com>2014-12-04 12:54:46 -0800
committerAlan Viverette <alanv@google.com>2014-12-04 12:54:46 -0800
commitebc9f2e773c3ebb4d4af3025fc6770844cc8fdef (patch)
tree3890c36416c7691646209f95555c64b8285d718a /graphics
parent70941f203c13bbd475f2434b69155123cf5ae863 (diff)
downloadframeworks_base-ebc9f2e773c3ebb4d4af3025fc6770844cc8fdef.zip
frameworks_base-ebc9f2e773c3ebb4d4af3025fc6770844cc8fdef.tar.gz
frameworks_base-ebc9f2e773c3ebb4d4af3025fc6770844cc8fdef.tar.bz2
Update locally cached drawables when constant state changes
Previously we were failing to update references to drawables that had been pulled from constant state, so we were drawing the wrong ones. Also fixes button Z translation on press, which was WAY too high. BUG: 18542282 Change-Id: Ifde7d64e31d31737854cfcbe75777e5b07a06e3a
Diffstat (limited to 'graphics')
-rw-r--r--graphics/java/android/graphics/drawable/DrawableContainer.java15
-rw-r--r--graphics/java/android/graphics/drawable/RippleDrawable.java4
2 files changed, 18 insertions, 1 deletions
diff --git a/graphics/java/android/graphics/drawable/DrawableContainer.java b/graphics/java/android/graphics/drawable/DrawableContainer.java
index 68fd296..2748030 100644
--- a/graphics/java/android/graphics/drawable/DrawableContainer.java
+++ b/graphics/java/android/graphics/drawable/DrawableContainer.java
@@ -54,19 +54,20 @@ public class DrawableContainer extends Drawable implements Drawable.Callback {
private DrawableContainerState mDrawableContainerState;
private Rect mHotspotBounds;
private Drawable mCurrDrawable;
+ private Drawable mLastDrawable;
private int mAlpha = 0xFF;
/** Whether setAlpha() has been called at least once. */
private boolean mHasAlpha;
private int mCurIndex = -1;
+ private int mLastIndex = -1;
private boolean mMutated;
// Animations.
private Runnable mAnimationRunnable;
private long mEnterAnimationEnd;
private long mExitAnimationEnd;
- private Drawable mLastDrawable;
// overrides from Drawable
@@ -255,6 +256,7 @@ public class DrawableContainer extends Drawable implements Drawable.Callback {
if (mLastDrawable != null) {
mLastDrawable.jumpToCurrentState();
mLastDrawable = null;
+ mLastIndex = -1;
changed = true;
}
if (mCurrDrawable != null) {
@@ -426,9 +428,11 @@ public class DrawableContainer extends Drawable implements Drawable.Callback {
}
if (mCurrDrawable != null) {
mLastDrawable = mCurrDrawable;
+ mLastIndex = mCurIndex;
mExitAnimationEnd = now + mDrawableContainerState.mExitFadeDuration;
} else {
mLastDrawable = null;
+ mLastIndex = -1;
mExitAnimationEnd = 0;
}
} else if (mCurrDrawable != null) {
@@ -522,6 +526,7 @@ public class DrawableContainer extends Drawable implements Drawable.Callback {
if (mExitAnimationEnd <= now) {
mLastDrawable.setVisible(false, false);
mLastDrawable = null;
+ mLastIndex = -1;
mExitAnimationEnd = 0;
} else {
int animAlpha = (int)((mExitAnimationEnd-now)*255)
@@ -1103,5 +1108,13 @@ public class DrawableContainer extends Drawable implements Drawable.Callback {
protected void setConstantState(DrawableContainerState state) {
mDrawableContainerState = state;
+
+ // The locally cached drawables may have changed.
+ if (mCurIndex >= 0) {
+ mCurrDrawable = state.getChild(mCurIndex);
+ }
+ if (mLastIndex >= 0) {
+ mLastDrawable = state.getChild(mLastIndex);
+ }
}
}
diff --git a/graphics/java/android/graphics/drawable/RippleDrawable.java b/graphics/java/android/graphics/drawable/RippleDrawable.java
index 8cbc239..d5d5d51 100644
--- a/graphics/java/android/graphics/drawable/RippleDrawable.java
+++ b/graphics/java/android/graphics/drawable/RippleDrawable.java
@@ -832,6 +832,10 @@ public class RippleDrawable extends LayerDrawable {
// LayerDrawable creates a new state using createConstantState, so
// this should always be a safe cast.
mState = (RippleState) mLayerState;
+
+ // The locally cached drawable may have changed.
+ mMask = findDrawableByLayerId(R.id.mask);
+
return this;
}