summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--graphics/java/android/graphics/drawable/AnimatedStateListDrawable.java2
-rw-r--r--graphics/java/android/graphics/drawable/DrawableContainer.java5
-rw-r--r--graphics/java/android/graphics/drawable/LayerDrawable.java14
-rw-r--r--graphics/java/android/graphics/drawable/RippleDrawable.java2
-rw-r--r--graphics/java/android/graphics/drawable/StateListDrawable.java25
5 files changed, 28 insertions, 20 deletions
diff --git a/graphics/java/android/graphics/drawable/AnimatedStateListDrawable.java b/graphics/java/android/graphics/drawable/AnimatedStateListDrawable.java
index 2c603e2..e235a99 100644
--- a/graphics/java/android/graphics/drawable/AnimatedStateListDrawable.java
+++ b/graphics/java/android/graphics/drawable/AnimatedStateListDrawable.java
@@ -575,7 +575,7 @@ public class AnimatedStateListDrawable extends StateListDrawable {
}
}
- private void mutate() {
+ void mutate() {
mTransitions = mTransitions.clone();
mStateIds = mStateIds.clone();
}
diff --git a/graphics/java/android/graphics/drawable/DrawableContainer.java b/graphics/java/android/graphics/drawable/DrawableContainer.java
index b344b86..1915dd7 100644
--- a/graphics/java/android/graphics/drawable/DrawableContainer.java
+++ b/graphics/java/android/graphics/drawable/DrawableContainer.java
@@ -730,7 +730,7 @@ public class DrawableContainer extends Drawable implements Drawable.Callback {
if (origDf != null) {
mDrawableFutures = origDf.clone();
} else {
- mDrawableFutures = new SparseArray<ConstantStateFuture>(mNumChildren);
+ mDrawableFutures = new SparseArray<>(mNumChildren);
}
// Create futures for drawables with constant states. If a
@@ -823,6 +823,9 @@ public class DrawableContainer extends Drawable implements Drawable.Callback {
final Drawable prepared = mDrawableFutures.valueAt(keyIndex).get(this);
mDrawables[index] = prepared;
mDrawableFutures.removeAt(keyIndex);
+ if (mDrawableFutures.size() == 0) {
+ mDrawableFutures = null;
+ }
return prepared;
}
}
diff --git a/graphics/java/android/graphics/drawable/LayerDrawable.java b/graphics/java/android/graphics/drawable/LayerDrawable.java
index 8373c7f..d9469d4 100644
--- a/graphics/java/android/graphics/drawable/LayerDrawable.java
+++ b/graphics/java/android/graphics/drawable/LayerDrawable.java
@@ -133,6 +133,7 @@ public class LayerDrawable extends Drawable implements Drawable.Callback {
mLayerState.mChildren = r;
ensurePadding();
+ refreshPadding();
}
LayerDrawable() {
@@ -143,6 +144,7 @@ public class LayerDrawable extends Drawable implements Drawable.Callback {
mLayerState = createConstantState(state, res);
if (mLayerState.mNum > 0) {
ensurePadding();
+ refreshPadding();
}
}
@@ -162,6 +164,7 @@ public class LayerDrawable extends Drawable implements Drawable.Callback {
inflateLayers(r, parser, attrs, theme);
ensurePadding();
+ refreshPadding();
}
/**
@@ -431,6 +434,7 @@ public class LayerDrawable extends Drawable implements Drawable.Callback {
final ChildDrawable layer = createLayer(dr);
final int index = addLayer(layer);
ensurePadding();
+ refreshChildPadding(index, layer);
return index;
}
@@ -568,6 +572,8 @@ public class LayerDrawable extends Drawable implements Drawable.Callback {
childDrawable.mDrawable = drawable;
mLayerState.invalidateCache();
+
+ refreshChildPadding(index, childDrawable);
}
/**
@@ -1623,6 +1629,14 @@ public class LayerDrawable extends Drawable implements Drawable.Callback {
mPaddingB = new int[N];
}
+ void refreshPadding() {
+ final int N = mLayerState.mNum;
+ final ChildDrawable[] array = mLayerState.mChildren;
+ for (int i = 0; i < N; i++) {
+ refreshChildPadding(i, array[i]);
+ }
+ }
+
@Override
public ConstantState getConstantState() {
if (mLayerState.canConstantState()) {
diff --git a/graphics/java/android/graphics/drawable/RippleDrawable.java b/graphics/java/android/graphics/drawable/RippleDrawable.java
index 6369833..bf069d3 100644
--- a/graphics/java/android/graphics/drawable/RippleDrawable.java
+++ b/graphics/java/android/graphics/drawable/RippleDrawable.java
@@ -198,6 +198,7 @@ public class RippleDrawable extends LayerDrawable {
setColor(color);
ensurePadding();
+ refreshPadding();
updateLocalState();
}
@@ -1013,6 +1014,7 @@ public class RippleDrawable extends LayerDrawable {
if (mState.mNum > 0) {
ensurePadding();
+ refreshPadding();
}
if (res != null) {
diff --git a/graphics/java/android/graphics/drawable/StateListDrawable.java b/graphics/java/android/graphics/drawable/StateListDrawable.java
index c83af11..758410a 100644
--- a/graphics/java/android/graphics/drawable/StateListDrawable.java
+++ b/graphics/java/android/graphics/drawable/StateListDrawable.java
@@ -59,22 +59,10 @@ import android.util.StateSet;
* @attr ref android.R.styleable#DrawableStates_state_pressed
*/
public class StateListDrawable extends DrawableContainer {
- private static final String TAG = StateListDrawable.class.getSimpleName();
+ private static final String TAG = "StateListDrawable";
private static final boolean DEBUG = false;
- /**
- * To be proper, we should have a getter for dither (and alpha, etc.)
- * so that proxy classes like this can save/restore their delegates'
- * values, but we don't have getters. Since we do have setters
- * (e.g. setDither), which this proxy forwards on, we have to have some
- * default/initial setting.
- *
- * The initial setting for dither is now true, since it almost always seems
- * to improve the quality at negligible cost.
- */
- private static final boolean DEFAULT_DITHER = true;
-
private StateListState mStateListState;
private boolean mMutated;
@@ -104,16 +92,16 @@ public class StateListDrawable extends DrawableContainer {
@Override
protected boolean onStateChange(int[] stateSet) {
+ final boolean changed = super.onStateChange(stateSet);
+
int idx = mStateListState.indexOfStateSet(stateSet);
if (DEBUG) android.util.Log.i(TAG, "onStateChange " + this + " states "
+ Arrays.toString(stateSet) + " found " + idx);
if (idx < 0) {
idx = mStateListState.indexOfStateSet(StateSet.WILD_CARD);
}
- if (selectDrawable(idx)) {
- return true;
- }
- return super.onStateChange(stateSet);
+
+ return selectDrawable(idx) || changed;
}
@Override
@@ -326,13 +314,14 @@ public class StateListDrawable extends DrawableContainer {
}
}
- private void mutate() {
+ void mutate() {
mThemeAttrs = mThemeAttrs != null ? mThemeAttrs.clone() : null;
final int[][] stateSets = new int[mStateSets.length][];
for (int i = mStateSets.length - 1; i >= 0; i--) {
stateSets[i] = mStateSets[i] != null ? mStateSets[i].clone() : null;
}
+ mStateSets = stateSets;
}
int addStateSet(int[] stateSet, Drawable drawable) {