summaryrefslogtreecommitdiffstats
path: root/graphics
diff options
context:
space:
mode:
authorAlan Viverette <alanv@google.com>2014-08-12 21:12:55 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-08-12 19:31:43 +0000
commit1725f941249a9cc421731d5ac5e8fe6fc9da5606 (patch)
tree53b9a7ede4114459474c9bd81e1297e16c9c2b98 /graphics
parentcd542b8a98ea9c648622c9360c251de4be4223e4 (diff)
parentad55abdc748f2cba6955e9e60cf7964dc027f2b5 (diff)
downloadframeworks_base-1725f941249a9cc421731d5ac5e8fe6fc9da5606.zip
frameworks_base-1725f941249a9cc421731d5ac5e8fe6fc9da5606.tar.gz
frameworks_base-1725f941249a9cc421731d5ac5e8fe6fc9da5606.tar.bz2
Merge "Fix NPE in NinePatchDrawable, propagate theme in StateListDrawable" into lmp-dev
Diffstat (limited to 'graphics')
-rw-r--r--graphics/java/android/graphics/drawable/NinePatchDrawable.java14
-rw-r--r--graphics/java/android/graphics/drawable/StateListDrawable.java31
2 files changed, 22 insertions, 23 deletions
diff --git a/graphics/java/android/graphics/drawable/NinePatchDrawable.java b/graphics/java/android/graphics/drawable/NinePatchDrawable.java
index a6dbcb0..0aa1b0d 100644
--- a/graphics/java/android/graphics/drawable/NinePatchDrawable.java
+++ b/graphics/java/android/graphics/drawable/NinePatchDrawable.java
@@ -17,6 +17,7 @@
package android.graphics.drawable;
import android.annotation.NonNull;
+import android.annotation.Nullable;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.content.res.Resources.Theme;
@@ -609,16 +610,17 @@ public class NinePatchDrawable extends Drawable {
// Empty constructor.
}
- NinePatchState(NinePatch ninePatch, Rect padding) {
+ NinePatchState(@NonNull NinePatch ninePatch, @Nullable Rect padding) {
this(ninePatch, padding, null, DEFAULT_DITHER, false);
}
- NinePatchState(NinePatch ninePatch, Rect padding, Rect opticalInsets) {
+ NinePatchState(@NonNull NinePatch ninePatch, @Nullable Rect padding,
+ @Nullable Rect opticalInsets) {
this(ninePatch, padding, opticalInsets, DEFAULT_DITHER, false);
}
- NinePatchState(NinePatch ninePatch, Rect padding, Rect opticalInsets, boolean dither,
- boolean autoMirror) {
+ NinePatchState(@NonNull NinePatch ninePatch, @Nullable Rect padding,
+ @Nullable Rect opticalInsets, boolean dither, boolean autoMirror) {
mNinePatch = ninePatch;
mPadding = padding;
mOpticalInsets = Insets.of(opticalInsets);
@@ -626,7 +628,7 @@ public class NinePatchDrawable extends Drawable {
mAutoMirrored = autoMirror;
// Sanity check for valid padding when we have optical insets.
- if (!opticalInsets.isEmpty()) {
+ if (opticalInsets != null && !opticalInsets.isEmpty()) {
if (mPadding == null) {
mPadding = new Rect();
}
@@ -643,7 +645,7 @@ public class NinePatchDrawable extends Drawable {
// Copy constructor
- NinePatchState(NinePatchState state) {
+ NinePatchState(@NonNull NinePatchState state) {
// We don't deep-copy any fields because they are all immutable.
mNinePatch = state.mNinePatch;
mTint = state.mTint;
diff --git a/graphics/java/android/graphics/drawable/StateListDrawable.java b/graphics/java/android/graphics/drawable/StateListDrawable.java
index f359fdd..4c513e9 100644
--- a/graphics/java/android/graphics/drawable/StateListDrawable.java
+++ b/graphics/java/android/graphics/drawable/StateListDrawable.java
@@ -16,6 +16,8 @@
package android.graphics.drawable;
+import com.android.internal.R;
+
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
@@ -116,32 +118,27 @@ public class StateListDrawable extends DrawableContainer {
public void inflate(Resources r, XmlPullParser parser, AttributeSet attrs, Theme theme)
throws XmlPullParserException, IOException {
- TypedArray a = r.obtainAttributes(attrs,
- com.android.internal.R.styleable.StateListDrawable);
+ final TypedArray a = r.obtainAttributes(attrs, R.styleable.StateListDrawable);
super.inflateWithAttributes(r, parser, a,
- com.android.internal.R.styleable.StateListDrawable_visible);
+ R.styleable.StateListDrawable_visible);
mStateListState.setVariablePadding(a.getBoolean(
- com.android.internal.R.styleable.StateListDrawable_variablePadding, false));
+ R.styleable.StateListDrawable_variablePadding, false));
mStateListState.setConstantSize(a.getBoolean(
- com.android.internal.R.styleable.StateListDrawable_constantSize, false));
+ R.styleable.StateListDrawable_constantSize, false));
mStateListState.setEnterFadeDuration(a.getInt(
- com.android.internal.R.styleable.StateListDrawable_enterFadeDuration, 0));
+ R.styleable.StateListDrawable_enterFadeDuration, 0));
mStateListState.setExitFadeDuration(a.getInt(
- com.android.internal.R.styleable.StateListDrawable_exitFadeDuration, 0));
-
- setDither(a.getBoolean(com.android.internal.R.styleable.StateListDrawable_dither,
- DEFAULT_DITHER));
+ R.styleable.StateListDrawable_exitFadeDuration, 0));
- setAutoMirrored(a.getBoolean(
- com.android.internal.R.styleable.StateListDrawable_autoMirrored, false));
+ setDither(a.getBoolean(R.styleable.StateListDrawable_dither, DEFAULT_DITHER));
+ setAutoMirrored(a.getBoolean(R.styleable.StateListDrawable_autoMirrored, false));
a.recycle();
- int type;
-
final int innerDepth = parser.getDepth() + 1;
+ int type;
int depth;
while ((type = parser.next()) != XmlPullParser.END_DOCUMENT
&& ((depth = parser.getDepth()) >= innerDepth
@@ -163,7 +160,7 @@ public class StateListDrawable extends DrawableContainer {
for (i = 0; i < numAttrs; i++) {
final int stateResId = attrs.getAttributeNameResource(i);
if (stateResId == 0) break;
- if (stateResId == com.android.internal.R.attr.drawable) {
+ if (stateResId == R.attr.drawable) {
drawableRes = attrs.getAttributeResourceValue(i, 0);
} else {
states[j++] = attrs.getAttributeBooleanValue(i, false)
@@ -173,9 +170,9 @@ public class StateListDrawable extends DrawableContainer {
}
states = StateSet.trimStateSet(states, j);
- Drawable dr;
+ final Drawable dr;
if (drawableRes != 0) {
- dr = r.getDrawable(drawableRes);
+ dr = r.getDrawable(drawableRes, theme);
} else {
while ((type = parser.next()) == XmlPullParser.TEXT) {
}