Merge "Prevent LayerDrawable bounds updates from being re-entrant" into nyc-dev
am: 5c9444216d
* commit '5c9444216d187ec2126fdd200e499a1fb3f6ee62':
Prevent LayerDrawable bounds updates from being re-entrant
Change-Id: I7517614a5bc600f85c232779a18bf6fbf1f81068
This commit is contained in:
@@ -104,6 +104,9 @@ public class LayerDrawable extends Drawable implements Drawable.Callback {
|
|||||||
private Rect mHotspotBounds;
|
private Rect mHotspotBounds;
|
||||||
private boolean mMutated;
|
private boolean mMutated;
|
||||||
|
|
||||||
|
private boolean mSuspendChildInvalidation;
|
||||||
|
private boolean mChildRequestedInvalidation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new layer drawable with the list of specified layers.
|
* Creates a new layer drawable with the list of specified layers.
|
||||||
*
|
*
|
||||||
@@ -944,10 +947,38 @@ public class LayerDrawable extends Drawable implements Drawable.Callback {
|
|||||||
return mLayerState.mPaddingMode;
|
return mLayerState.mPaddingMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Temporarily suspends child invalidation.
|
||||||
|
*
|
||||||
|
* @see #resumeChildInvalidation()
|
||||||
|
*/
|
||||||
|
private void suspendChildInvalidation() {
|
||||||
|
mSuspendChildInvalidation = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resumes child invalidation after suspension, immediately performing an
|
||||||
|
* invalidation if one was requested by a child during suspension.
|
||||||
|
*
|
||||||
|
* @see #suspendChildInvalidation()
|
||||||
|
*/
|
||||||
|
private void resumeChildInvalidation() {
|
||||||
|
mSuspendChildInvalidation = false;
|
||||||
|
|
||||||
|
if (mChildRequestedInvalidation) {
|
||||||
|
mChildRequestedInvalidation = false;
|
||||||
|
invalidateSelf();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void invalidateDrawable(@NonNull Drawable who) {
|
public void invalidateDrawable(@NonNull Drawable who) {
|
||||||
|
if (mSuspendChildInvalidation) {
|
||||||
|
mChildRequestedInvalidation = true;
|
||||||
|
} else {
|
||||||
invalidateSelf();
|
invalidateSelf();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void scheduleDrawable(@NonNull Drawable who, @NonNull Runnable what, long when) {
|
public void scheduleDrawable(@NonNull Drawable who, @NonNull Runnable what, long when) {
|
||||||
@@ -1482,6 +1513,15 @@ public class LayerDrawable extends Drawable implements Drawable.Callback {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateLayerBounds(Rect bounds) {
|
private void updateLayerBounds(Rect bounds) {
|
||||||
|
try {
|
||||||
|
suspendChildInvalidation();
|
||||||
|
updateLayerBoundsInternal(bounds);
|
||||||
|
} finally {
|
||||||
|
resumeChildInvalidation();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateLayerBoundsInternal(Rect bounds) {
|
||||||
int paddingL = 0;
|
int paddingL = 0;
|
||||||
int paddingT = 0;
|
int paddingT = 0;
|
||||||
int paddingR = 0;
|
int paddingR = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user