Loading graphics/java/android/graphics/drawable/LayerDrawable.java +11 −9 Original line number Original line Diff line number Diff line Loading @@ -229,15 +229,18 @@ public class LayerDrawable extends Drawable implements Drawable.Callback { } } /** /** * Look for a layer with the given id, and returns its {@link Drawable}. * Looks for a layer with the given ID and returns its {@link Drawable}. * <p> * If multiple layers are found for the given ID, returns the * {@link Drawable} for the matching layer at the highest index. * * * @param id The layer ID to search for. * @param id The layer ID to search for. * @return The {@link Drawable} of the layer that has the given id in the hierarchy or null. * @return The {@link Drawable} for the highest-indexed layer that has the * given ID, or null if not found. */ */ public Drawable findDrawableByLayerId(int id) { public Drawable findDrawableByLayerId(int id) { final ChildDrawable[] layers = mLayerState.mChildren; final ChildDrawable[] layers = mLayerState.mChildren; final int N = mLayerState.mNum; for (int i = mLayerState.mNum - 1; i >= 0; i--) { for (int i = 0; i < N; i++) { if (layers[i].mId == id) { if (layers[i].mId == id) { return layers[i].mDrawable; return layers[i].mDrawable; } } Loading Loading @@ -370,7 +373,7 @@ public class LayerDrawable extends Drawable implements Drawable.Callback { } } /** /** * Invalidates cached padding. * Invalidates cached padding and recomputes child bounds. */ */ private void invalidatePadding() { private void invalidatePadding() { mHasCachedPadding = false; mHasCachedPadding = false; Loading @@ -379,10 +382,9 @@ public class LayerDrawable extends Drawable implements Drawable.Callback { @Override @Override public void invalidateDrawable(Drawable who) { public void invalidateDrawable(Drawable who) { final Callback callback = getCallback(); // Something changed, maybe it was the child drawable's padding. if (callback != null) { invalidatePadding(); callback.invalidateDrawable(this); invalidateSelf(); } } } @Override @Override Loading Loading
graphics/java/android/graphics/drawable/LayerDrawable.java +11 −9 Original line number Original line Diff line number Diff line Loading @@ -229,15 +229,18 @@ public class LayerDrawable extends Drawable implements Drawable.Callback { } } /** /** * Look for a layer with the given id, and returns its {@link Drawable}. * Looks for a layer with the given ID and returns its {@link Drawable}. * <p> * If multiple layers are found for the given ID, returns the * {@link Drawable} for the matching layer at the highest index. * * * @param id The layer ID to search for. * @param id The layer ID to search for. * @return The {@link Drawable} of the layer that has the given id in the hierarchy or null. * @return The {@link Drawable} for the highest-indexed layer that has the * given ID, or null if not found. */ */ public Drawable findDrawableByLayerId(int id) { public Drawable findDrawableByLayerId(int id) { final ChildDrawable[] layers = mLayerState.mChildren; final ChildDrawable[] layers = mLayerState.mChildren; final int N = mLayerState.mNum; for (int i = mLayerState.mNum - 1; i >= 0; i--) { for (int i = 0; i < N; i++) { if (layers[i].mId == id) { if (layers[i].mId == id) { return layers[i].mDrawable; return layers[i].mDrawable; } } Loading Loading @@ -370,7 +373,7 @@ public class LayerDrawable extends Drawable implements Drawable.Callback { } } /** /** * Invalidates cached padding. * Invalidates cached padding and recomputes child bounds. */ */ private void invalidatePadding() { private void invalidatePadding() { mHasCachedPadding = false; mHasCachedPadding = false; Loading @@ -379,10 +382,9 @@ public class LayerDrawable extends Drawable implements Drawable.Callback { @Override @Override public void invalidateDrawable(Drawable who) { public void invalidateDrawable(Drawable who) { final Callback callback = getCallback(); // Something changed, maybe it was the child drawable's padding. if (callback != null) { invalidatePadding(); callback.invalidateDrawable(this); invalidateSelf(); } } } @Override @Override Loading