summaryrefslogtreecommitdiffstats
path: root/graphics/java
diff options
context:
space:
mode:
authorAdam Powell <adamp@google.com>2012-03-21 14:53:15 -0700
committerAdam Powell <adamp@google.com>2012-03-21 14:53:39 -0700
commit26e35fca60426ce375a4a0534dbc9964123c76ee (patch)
tree59368b7bb162adf1f9c5add5e800cb21d44b708f /graphics/java
parent8dc8a435a123414b058799b3df2b567f22dc518c (diff)
downloadframeworks_base-26e35fca60426ce375a4a0534dbc9964123c76ee.zip
frameworks_base-26e35fca60426ce375a4a0534dbc9964123c76ee.tar.gz
frameworks_base-26e35fca60426ce375a4a0534dbc9964123c76ee.tar.bz2
Fix LayerDrawable#mutate
Change-Id: I985b80141ffc96db969eaf36538df938cb093661
Diffstat (limited to 'graphics/java')
-rw-r--r--graphics/java/android/graphics/drawable/LayerDrawable.java7
1 files changed, 6 insertions, 1 deletions
diff --git a/graphics/java/android/graphics/drawable/LayerDrawable.java b/graphics/java/android/graphics/drawable/LayerDrawable.java
index 6698d31..383fe71 100644
--- a/graphics/java/android/graphics/drawable/LayerDrawable.java
+++ b/graphics/java/android/graphics/drawable/LayerDrawable.java
@@ -575,6 +575,11 @@ public class LayerDrawable extends Drawable implements Drawable.Callback {
@Override
public Drawable mutate() {
if (!mMutated && super.mutate() == this) {
+ if (!mLayerState.canConstantState()) {
+ throw new IllegalStateException("One or more children of this LayerDrawable does " +
+ "not have constant state; this drawable cannot be mutated.");
+ }
+ mLayerState = new LayerState(mLayerState, this, null);
final ChildDrawable[] array = mLayerState.mChildren;
final int N = mLayerState.mNum;
for (int i = 0; i < N; i++) {
@@ -694,7 +699,7 @@ public class LayerDrawable extends Drawable implements Drawable.Callback {
return stateful;
}
- public synchronized boolean canConstantState() {
+ public boolean canConstantState() {
if (!mCheckedConstantState && mChildren != null) {
mCanConstantState = true;
final int N = mNum;