Loading graphics/java/android/graphics/drawable/AnimatedStateListDrawable.java +1 −1 Original line number Diff line number Diff line Loading @@ -575,7 +575,7 @@ public class AnimatedStateListDrawable extends StateListDrawable { } } private void mutate() { void mutate() { mTransitions = mTransitions.clone(); mStateIds = mStateIds.clone(); } Loading graphics/java/android/graphics/drawable/DrawableContainer.java +4 −1 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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; } } Loading graphics/java/android/graphics/drawable/LayerDrawable.java +14 −0 Original line number Diff line number Diff line Loading @@ -133,6 +133,7 @@ public class LayerDrawable extends Drawable implements Drawable.Callback { mLayerState.mChildren = r; ensurePadding(); refreshPadding(); } LayerDrawable() { Loading @@ -143,6 +144,7 @@ public class LayerDrawable extends Drawable implements Drawable.Callback { mLayerState = createConstantState(state, res); if (mLayerState.mNum > 0) { ensurePadding(); refreshPadding(); } } Loading @@ -162,6 +164,7 @@ public class LayerDrawable extends Drawable implements Drawable.Callback { inflateLayers(r, parser, attrs, theme); ensurePadding(); refreshPadding(); } /** Loading Loading @@ -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; } Loading Loading @@ -568,6 +572,8 @@ public class LayerDrawable extends Drawable implements Drawable.Callback { childDrawable.mDrawable = drawable; mLayerState.invalidateCache(); refreshChildPadding(index, childDrawable); } /** Loading Loading @@ -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()) { Loading graphics/java/android/graphics/drawable/RippleDrawable.java +2 −0 Original line number Diff line number Diff line Loading @@ -198,6 +198,7 @@ public class RippleDrawable extends LayerDrawable { setColor(color); ensurePadding(); refreshPadding(); updateLocalState(); } Loading Loading @@ -1013,6 +1014,7 @@ public class RippleDrawable extends LayerDrawable { if (mState.mNum > 0) { ensurePadding(); refreshPadding(); } if (res != null) { Loading graphics/java/android/graphics/drawable/StateListDrawable.java +7 −18 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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 Loading Loading @@ -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) { Loading Loading
graphics/java/android/graphics/drawable/AnimatedStateListDrawable.java +1 −1 Original line number Diff line number Diff line Loading @@ -575,7 +575,7 @@ public class AnimatedStateListDrawable extends StateListDrawable { } } private void mutate() { void mutate() { mTransitions = mTransitions.clone(); mStateIds = mStateIds.clone(); } Loading
graphics/java/android/graphics/drawable/DrawableContainer.java +4 −1 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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; } } Loading
graphics/java/android/graphics/drawable/LayerDrawable.java +14 −0 Original line number Diff line number Diff line Loading @@ -133,6 +133,7 @@ public class LayerDrawable extends Drawable implements Drawable.Callback { mLayerState.mChildren = r; ensurePadding(); refreshPadding(); } LayerDrawable() { Loading @@ -143,6 +144,7 @@ public class LayerDrawable extends Drawable implements Drawable.Callback { mLayerState = createConstantState(state, res); if (mLayerState.mNum > 0) { ensurePadding(); refreshPadding(); } } Loading @@ -162,6 +164,7 @@ public class LayerDrawable extends Drawable implements Drawable.Callback { inflateLayers(r, parser, attrs, theme); ensurePadding(); refreshPadding(); } /** Loading Loading @@ -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; } Loading Loading @@ -568,6 +572,8 @@ public class LayerDrawable extends Drawable implements Drawable.Callback { childDrawable.mDrawable = drawable; mLayerState.invalidateCache(); refreshChildPadding(index, childDrawable); } /** Loading Loading @@ -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()) { Loading
graphics/java/android/graphics/drawable/RippleDrawable.java +2 −0 Original line number Diff line number Diff line Loading @@ -198,6 +198,7 @@ public class RippleDrawable extends LayerDrawable { setColor(color); ensurePadding(); refreshPadding(); updateLocalState(); } Loading Loading @@ -1013,6 +1014,7 @@ public class RippleDrawable extends LayerDrawable { if (mState.mNum > 0) { ensurePadding(); refreshPadding(); } if (res != null) { Loading
graphics/java/android/graphics/drawable/StateListDrawable.java +7 −18 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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 Loading Loading @@ -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) { Loading