Loading graphics/java/android/graphics/drawable/DrawableContainer.java +19 −2 Original line number Original line Diff line number Diff line Loading @@ -210,6 +210,7 @@ public class DrawableContainer extends Drawable implements Drawable.Callback { /** /** * Change the global fade duration when a new drawable is entering * Change the global fade duration when a new drawable is entering * the scene. * the scene. * * @param ms The amount of time to fade in milliseconds. * @param ms The amount of time to fade in milliseconds. */ */ public void setEnterFadeDuration(int ms) { public void setEnterFadeDuration(int ms) { Loading @@ -219,6 +220,7 @@ public class DrawableContainer extends Drawable implements Drawable.Callback { /** /** * Change the global fade duration when a new drawable is leaving * Change the global fade duration when a new drawable is leaving * the scene. * the scene. * * @param ms The amount of time to fade in milliseconds. * @param ms The amount of time to fade in milliseconds. */ */ public void setExitFadeDuration(int ms) { public void setExitFadeDuration(int ms) { Loading Loading @@ -387,6 +389,13 @@ public class DrawableContainer extends Drawable implements Drawable.Callback { @Override @Override public void invalidateDrawable(@NonNull Drawable who) { public void invalidateDrawable(@NonNull Drawable who) { // This may have been called as the result of a tint changing, in // which case we may need to refresh the cached statefulness or // opacity. if (mDrawableContainerState != null) { mDrawableContainerState.invalidateCache(); } if (who == mCurrDrawable && getCallback() != null) { if (who == mCurrDrawable && getCallback() != null) { getCallback().invalidateDrawable(this); getCallback().invalidateDrawable(this); } } Loading Loading @@ -834,8 +843,8 @@ public class DrawableContainer extends Drawable implements Drawable.Callback { mDrawables[pos] = dr; mDrawables[pos] = dr; mNumChildren++; mNumChildren++; mChildrenChangingConfigurations |= dr.getChangingConfigurations(); mChildrenChangingConfigurations |= dr.getChangingConfigurations(); mCheckedStateful = false; mCheckedOpacity = false; invalidateCache(); mConstantPadding = null; mConstantPadding = null; mCheckedPadding = false; mCheckedPadding = false; Loading @@ -845,6 +854,14 @@ public class DrawableContainer extends Drawable implements Drawable.Callback { return pos; return pos; } } /** * Invalidates the cached opacity and statefulness. */ void invalidateCache() { mCheckedOpacity = false; mCheckedStateful = false; } final int getCapacity() { final int getCapacity() { return mDrawables.length; return mDrawables.length; } } Loading graphics/java/android/graphics/drawable/LayerDrawable.java +25 −12 Original line number Original line Diff line number Diff line Loading @@ -32,6 +32,7 @@ import android.graphics.Rect; import android.util.AttributeSet; import android.util.AttributeSet; import android.util.DisplayMetrics; import android.util.DisplayMetrics; import android.util.LayoutDirection; import android.util.LayoutDirection; import android.util.Log; import android.view.Gravity; import android.view.Gravity; import android.view.View; import android.view.View; Loading Loading @@ -66,6 +67,8 @@ import java.io.IOException; * @attr ref android.R.styleable#LayerDrawableItem_id * @attr ref android.R.styleable#LayerDrawableItem_id */ */ public class LayerDrawable extends Drawable implements Drawable.Callback { public class LayerDrawable extends Drawable implements Drawable.Callback { private static final String LOG_TAG = "LayerDrawable"; /** /** * Padding mode used to nest each layer inside the padding of the previous * Padding mode used to nest each layer inside the padding of the previous * layer. * layer. Loading @@ -89,6 +92,7 @@ public class LayerDrawable extends Drawable implements Drawable.Callback { */ */ public static final int INSET_UNDEFINED = Integer.MIN_VALUE; public static final int INSET_UNDEFINED = Integer.MIN_VALUE; @NonNull LayerState mLayerState; LayerState mLayerState; private int[] mPaddingL; private int[] mPaddingL; Loading Loading @@ -170,13 +174,9 @@ public class LayerDrawable extends Drawable implements Drawable.Callback { throws XmlPullParserException, IOException { throws XmlPullParserException, IOException { super.inflate(r, parser, attrs, theme); super.inflate(r, parser, attrs, theme); final LayerState state = mLayerState; if (state == null) { return; } // The density may have changed since the last update. This will // The density may have changed since the last update. This will // apply scaling to any existing constant state properties. // apply scaling to any existing constant state properties. final LayerState state = mLayerState; final int density = Drawable.resolveDensity(r, 0); final int density = Drawable.resolveDensity(r, 0); state.setDensity(density); state.setDensity(density); Loading @@ -202,10 +202,6 @@ public class LayerDrawable extends Drawable implements Drawable.Callback { super.applyTheme(t); super.applyTheme(t); final LayerState state = mLayerState; final LayerState state = mLayerState; if (state == null) { return; } final int density = Drawable.resolveDensity(t.getResources(), 0); final int density = Drawable.resolveDensity(t.getResources(), 0); state.setDensity(density); state.setDensity(density); Loading Loading @@ -403,7 +399,7 @@ public class LayerDrawable extends Drawable implements Drawable.Callback { @Override @Override public boolean canApplyTheme() { public boolean canApplyTheme() { return (mLayerState != null && mLayerState.canApplyTheme()) || super.canApplyTheme(); return mLayerState.canApplyTheme() || super.canApplyTheme(); } } /** /** Loading Loading @@ -986,6 +982,11 @@ public class LayerDrawable extends Drawable implements Drawable.Callback { if (mSuspendChildInvalidation) { if (mSuspendChildInvalidation) { mChildRequestedInvalidation = true; mChildRequestedInvalidation = true; } else { } else { // This may have been called as the result of a tint changing, in // which case we may need to refresh the cached statefulness or // opacity. mLayerState.invalidateCache(); invalidateSelf(); invalidateSelf(); } } } } Loading Loading @@ -1842,15 +1843,24 @@ public class LayerDrawable extends Drawable implements Drawable.Callback { final ConstantState cs = dr.getConstantState(); final ConstantState cs = dr.getConstantState(); if (cs == null) { if (cs == null) { clone = dr; clone = dr; if (dr.getCallback() != null) { // This drawable already has an owner. Log.w(LOG_TAG, "Invalid drawable added to LayerDrawable! Drawable already " + "belongs to another owner but does not expose a constant state.", new RuntimeException()); } } else if (res != null) { } else if (res != null) { clone = cs.newDrawable(res); clone = cs.newDrawable(res); } else { } else { clone = cs.newDrawable(); clone = cs.newDrawable(); } } clone.setCallback(owner); clone.setLayoutDirection(dr.getLayoutDirection()); clone.setLayoutDirection(dr.getLayoutDirection()); clone.setBounds(dr.getBounds()); clone.setBounds(dr.getBounds()); clone.setLevel(dr.getLevel()); clone.setLevel(dr.getLevel()); // Set the callback last to prevent invalidation from // propagating before the constant state has been set. clone.setCallback(owner); } else { } else { clone = null; clone = null; } } Loading Loading @@ -2139,7 +2149,10 @@ public class LayerDrawable extends Drawable implements Drawable.Callback { return true; return true; } } public void invalidateCache() { /** * Invalidates the cached opacity and statefulness. */ void invalidateCache() { mCheckedOpacity = false; mCheckedOpacity = false; mCheckedStateful = false; mCheckedStateful = false; } } Loading Loading
graphics/java/android/graphics/drawable/DrawableContainer.java +19 −2 Original line number Original line Diff line number Diff line Loading @@ -210,6 +210,7 @@ public class DrawableContainer extends Drawable implements Drawable.Callback { /** /** * Change the global fade duration when a new drawable is entering * Change the global fade duration when a new drawable is entering * the scene. * the scene. * * @param ms The amount of time to fade in milliseconds. * @param ms The amount of time to fade in milliseconds. */ */ public void setEnterFadeDuration(int ms) { public void setEnterFadeDuration(int ms) { Loading @@ -219,6 +220,7 @@ public class DrawableContainer extends Drawable implements Drawable.Callback { /** /** * Change the global fade duration when a new drawable is leaving * Change the global fade duration when a new drawable is leaving * the scene. * the scene. * * @param ms The amount of time to fade in milliseconds. * @param ms The amount of time to fade in milliseconds. */ */ public void setExitFadeDuration(int ms) { public void setExitFadeDuration(int ms) { Loading Loading @@ -387,6 +389,13 @@ public class DrawableContainer extends Drawable implements Drawable.Callback { @Override @Override public void invalidateDrawable(@NonNull Drawable who) { public void invalidateDrawable(@NonNull Drawable who) { // This may have been called as the result of a tint changing, in // which case we may need to refresh the cached statefulness or // opacity. if (mDrawableContainerState != null) { mDrawableContainerState.invalidateCache(); } if (who == mCurrDrawable && getCallback() != null) { if (who == mCurrDrawable && getCallback() != null) { getCallback().invalidateDrawable(this); getCallback().invalidateDrawable(this); } } Loading Loading @@ -834,8 +843,8 @@ public class DrawableContainer extends Drawable implements Drawable.Callback { mDrawables[pos] = dr; mDrawables[pos] = dr; mNumChildren++; mNumChildren++; mChildrenChangingConfigurations |= dr.getChangingConfigurations(); mChildrenChangingConfigurations |= dr.getChangingConfigurations(); mCheckedStateful = false; mCheckedOpacity = false; invalidateCache(); mConstantPadding = null; mConstantPadding = null; mCheckedPadding = false; mCheckedPadding = false; Loading @@ -845,6 +854,14 @@ public class DrawableContainer extends Drawable implements Drawable.Callback { return pos; return pos; } } /** * Invalidates the cached opacity and statefulness. */ void invalidateCache() { mCheckedOpacity = false; mCheckedStateful = false; } final int getCapacity() { final int getCapacity() { return mDrawables.length; return mDrawables.length; } } Loading
graphics/java/android/graphics/drawable/LayerDrawable.java +25 −12 Original line number Original line Diff line number Diff line Loading @@ -32,6 +32,7 @@ import android.graphics.Rect; import android.util.AttributeSet; import android.util.AttributeSet; import android.util.DisplayMetrics; import android.util.DisplayMetrics; import android.util.LayoutDirection; import android.util.LayoutDirection; import android.util.Log; import android.view.Gravity; import android.view.Gravity; import android.view.View; import android.view.View; Loading Loading @@ -66,6 +67,8 @@ import java.io.IOException; * @attr ref android.R.styleable#LayerDrawableItem_id * @attr ref android.R.styleable#LayerDrawableItem_id */ */ public class LayerDrawable extends Drawable implements Drawable.Callback { public class LayerDrawable extends Drawable implements Drawable.Callback { private static final String LOG_TAG = "LayerDrawable"; /** /** * Padding mode used to nest each layer inside the padding of the previous * Padding mode used to nest each layer inside the padding of the previous * layer. * layer. Loading @@ -89,6 +92,7 @@ public class LayerDrawable extends Drawable implements Drawable.Callback { */ */ public static final int INSET_UNDEFINED = Integer.MIN_VALUE; public static final int INSET_UNDEFINED = Integer.MIN_VALUE; @NonNull LayerState mLayerState; LayerState mLayerState; private int[] mPaddingL; private int[] mPaddingL; Loading Loading @@ -170,13 +174,9 @@ public class LayerDrawable extends Drawable implements Drawable.Callback { throws XmlPullParserException, IOException { throws XmlPullParserException, IOException { super.inflate(r, parser, attrs, theme); super.inflate(r, parser, attrs, theme); final LayerState state = mLayerState; if (state == null) { return; } // The density may have changed since the last update. This will // The density may have changed since the last update. This will // apply scaling to any existing constant state properties. // apply scaling to any existing constant state properties. final LayerState state = mLayerState; final int density = Drawable.resolveDensity(r, 0); final int density = Drawable.resolveDensity(r, 0); state.setDensity(density); state.setDensity(density); Loading @@ -202,10 +202,6 @@ public class LayerDrawable extends Drawable implements Drawable.Callback { super.applyTheme(t); super.applyTheme(t); final LayerState state = mLayerState; final LayerState state = mLayerState; if (state == null) { return; } final int density = Drawable.resolveDensity(t.getResources(), 0); final int density = Drawable.resolveDensity(t.getResources(), 0); state.setDensity(density); state.setDensity(density); Loading Loading @@ -403,7 +399,7 @@ public class LayerDrawable extends Drawable implements Drawable.Callback { @Override @Override public boolean canApplyTheme() { public boolean canApplyTheme() { return (mLayerState != null && mLayerState.canApplyTheme()) || super.canApplyTheme(); return mLayerState.canApplyTheme() || super.canApplyTheme(); } } /** /** Loading Loading @@ -986,6 +982,11 @@ public class LayerDrawable extends Drawable implements Drawable.Callback { if (mSuspendChildInvalidation) { if (mSuspendChildInvalidation) { mChildRequestedInvalidation = true; mChildRequestedInvalidation = true; } else { } else { // This may have been called as the result of a tint changing, in // which case we may need to refresh the cached statefulness or // opacity. mLayerState.invalidateCache(); invalidateSelf(); invalidateSelf(); } } } } Loading Loading @@ -1842,15 +1843,24 @@ public class LayerDrawable extends Drawable implements Drawable.Callback { final ConstantState cs = dr.getConstantState(); final ConstantState cs = dr.getConstantState(); if (cs == null) { if (cs == null) { clone = dr; clone = dr; if (dr.getCallback() != null) { // This drawable already has an owner. Log.w(LOG_TAG, "Invalid drawable added to LayerDrawable! Drawable already " + "belongs to another owner but does not expose a constant state.", new RuntimeException()); } } else if (res != null) { } else if (res != null) { clone = cs.newDrawable(res); clone = cs.newDrawable(res); } else { } else { clone = cs.newDrawable(); clone = cs.newDrawable(); } } clone.setCallback(owner); clone.setLayoutDirection(dr.getLayoutDirection()); clone.setLayoutDirection(dr.getLayoutDirection()); clone.setBounds(dr.getBounds()); clone.setBounds(dr.getBounds()); clone.setLevel(dr.getLevel()); clone.setLevel(dr.getLevel()); // Set the callback last to prevent invalidation from // propagating before the constant state has been set. clone.setCallback(owner); } else { } else { clone = null; clone = null; } } Loading Loading @@ -2139,7 +2149,10 @@ public class LayerDrawable extends Drawable implements Drawable.Callback { return true; return true; } } public void invalidateCache() { /** * Invalidates the cached opacity and statefulness. */ void invalidateCache() { mCheckedOpacity = false; mCheckedOpacity = false; mCheckedStateful = false; mCheckedStateful = false; } } Loading