am bab2b594: Merge "Update locally cached drawables when constant state changes" into lmp-mr1-dev
* commit 'bab2b5948a6d28f3bbe4981f2b6f172de292d456': Update locally cached drawables when constant state changes
This commit is contained in:
@@ -89,7 +89,7 @@
|
|||||||
<!-- Elevation when button is pressed -->
|
<!-- Elevation when button is pressed -->
|
||||||
<dimen name="button_elevation_material">4dp</dimen>
|
<dimen name="button_elevation_material">4dp</dimen>
|
||||||
<!-- Z translation to apply when button is pressed -->
|
<!-- Z translation to apply when button is pressed -->
|
||||||
<dimen name="button_pressed_z_material">6dp</dimen>
|
<dimen name="button_pressed_z_material">2dp</dimen>
|
||||||
<!-- Default insets (outer padding) around buttons -->
|
<!-- Default insets (outer padding) around buttons -->
|
||||||
<dimen name="button_inset_vertical_material">6dp</dimen>
|
<dimen name="button_inset_vertical_material">6dp</dimen>
|
||||||
<dimen name="button_inset_horizontal_material">@dimen/control_inset_material</dimen>
|
<dimen name="button_inset_horizontal_material">@dimen/control_inset_material</dimen>
|
||||||
|
|||||||
@@ -54,19 +54,20 @@ public class DrawableContainer extends Drawable implements Drawable.Callback {
|
|||||||
private DrawableContainerState mDrawableContainerState;
|
private DrawableContainerState mDrawableContainerState;
|
||||||
private Rect mHotspotBounds;
|
private Rect mHotspotBounds;
|
||||||
private Drawable mCurrDrawable;
|
private Drawable mCurrDrawable;
|
||||||
|
private Drawable mLastDrawable;
|
||||||
private int mAlpha = 0xFF;
|
private int mAlpha = 0xFF;
|
||||||
|
|
||||||
/** Whether setAlpha() has been called at least once. */
|
/** Whether setAlpha() has been called at least once. */
|
||||||
private boolean mHasAlpha;
|
private boolean mHasAlpha;
|
||||||
|
|
||||||
private int mCurIndex = -1;
|
private int mCurIndex = -1;
|
||||||
|
private int mLastIndex = -1;
|
||||||
private boolean mMutated;
|
private boolean mMutated;
|
||||||
|
|
||||||
// Animations.
|
// Animations.
|
||||||
private Runnable mAnimationRunnable;
|
private Runnable mAnimationRunnable;
|
||||||
private long mEnterAnimationEnd;
|
private long mEnterAnimationEnd;
|
||||||
private long mExitAnimationEnd;
|
private long mExitAnimationEnd;
|
||||||
private Drawable mLastDrawable;
|
|
||||||
|
|
||||||
// overrides from Drawable
|
// overrides from Drawable
|
||||||
|
|
||||||
@@ -255,6 +256,7 @@ public class DrawableContainer extends Drawable implements Drawable.Callback {
|
|||||||
if (mLastDrawable != null) {
|
if (mLastDrawable != null) {
|
||||||
mLastDrawable.jumpToCurrentState();
|
mLastDrawable.jumpToCurrentState();
|
||||||
mLastDrawable = null;
|
mLastDrawable = null;
|
||||||
|
mLastIndex = -1;
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
if (mCurrDrawable != null) {
|
if (mCurrDrawable != null) {
|
||||||
@@ -426,9 +428,11 @@ public class DrawableContainer extends Drawable implements Drawable.Callback {
|
|||||||
}
|
}
|
||||||
if (mCurrDrawable != null) {
|
if (mCurrDrawable != null) {
|
||||||
mLastDrawable = mCurrDrawable;
|
mLastDrawable = mCurrDrawable;
|
||||||
|
mLastIndex = mCurIndex;
|
||||||
mExitAnimationEnd = now + mDrawableContainerState.mExitFadeDuration;
|
mExitAnimationEnd = now + mDrawableContainerState.mExitFadeDuration;
|
||||||
} else {
|
} else {
|
||||||
mLastDrawable = null;
|
mLastDrawable = null;
|
||||||
|
mLastIndex = -1;
|
||||||
mExitAnimationEnd = 0;
|
mExitAnimationEnd = 0;
|
||||||
}
|
}
|
||||||
} else if (mCurrDrawable != null) {
|
} else if (mCurrDrawable != null) {
|
||||||
@@ -522,6 +526,7 @@ public class DrawableContainer extends Drawable implements Drawable.Callback {
|
|||||||
if (mExitAnimationEnd <= now) {
|
if (mExitAnimationEnd <= now) {
|
||||||
mLastDrawable.setVisible(false, false);
|
mLastDrawable.setVisible(false, false);
|
||||||
mLastDrawable = null;
|
mLastDrawable = null;
|
||||||
|
mLastIndex = -1;
|
||||||
mExitAnimationEnd = 0;
|
mExitAnimationEnd = 0;
|
||||||
} else {
|
} else {
|
||||||
int animAlpha = (int)((mExitAnimationEnd-now)*255)
|
int animAlpha = (int)((mExitAnimationEnd-now)*255)
|
||||||
@@ -1103,5 +1108,13 @@ public class DrawableContainer extends Drawable implements Drawable.Callback {
|
|||||||
|
|
||||||
protected void setConstantState(DrawableContainerState state) {
|
protected void setConstantState(DrawableContainerState state) {
|
||||||
mDrawableContainerState = state;
|
mDrawableContainerState = state;
|
||||||
|
|
||||||
|
// The locally cached drawables may have changed.
|
||||||
|
if (mCurIndex >= 0) {
|
||||||
|
mCurrDrawable = state.getChild(mCurIndex);
|
||||||
|
}
|
||||||
|
if (mLastIndex >= 0) {
|
||||||
|
mLastDrawable = state.getChild(mLastIndex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -832,6 +832,10 @@ public class RippleDrawable extends LayerDrawable {
|
|||||||
// LayerDrawable creates a new state using createConstantState, so
|
// LayerDrawable creates a new state using createConstantState, so
|
||||||
// this should always be a safe cast.
|
// this should always be a safe cast.
|
||||||
mState = (RippleState) mLayerState;
|
mState = (RippleState) mLayerState;
|
||||||
|
|
||||||
|
// The locally cached drawable may have changed.
|
||||||
|
mMask = findDrawableByLayerId(R.id.mask);
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user