From 34a14f967ab6c88829c9a36ce6e909c47b3ee398 Mon Sep 17 00:00:00 2001 From: Alan Viverette Date: Fri, 15 Aug 2014 16:13:15 -0700 Subject: Better handling of unresolved theme attributes Also adds a (very obviously wrong) default color to RippleDrawable Change-Id: I6d29b371f4e59accbebf25eb059b1f372b9184b0 --- graphics/java/android/graphics/drawable/RippleDrawable.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'graphics/java/android') diff --git a/graphics/java/android/graphics/drawable/RippleDrawable.java b/graphics/java/android/graphics/drawable/RippleDrawable.java index ea9f7320d024..0447e1770179 100644 --- a/graphics/java/android/graphics/drawable/RippleDrawable.java +++ b/graphics/java/android/graphics/drawable/RippleDrawable.java @@ -395,8 +395,12 @@ public class RippleDrawable extends LayerDrawable { mState.mColor = color; } - // If we're not waiting on a theme, verify required attributes. - if (state.mTouchThemeAttrs == null && mState.mColor == null) { + verifyRequiredAttributes(a); + } + + private void verifyRequiredAttributes(TypedArray a) throws XmlPullParserException { + if (mState.mColor == null && (mState.mTouchThemeAttrs == null + || mState.mTouchThemeAttrs[R.styleable.RippleDrawable_color] == 0)) { throw new XmlPullParserException(a.getPositionDescription() + ": requires a valid color attribute"); } @@ -891,7 +895,7 @@ public class RippleDrawable extends LayerDrawable { static class RippleState extends LayerState { int[] mTouchThemeAttrs; - ColorStateList mColor = null; + ColorStateList mColor = ColorStateList.valueOf(Color.MAGENTA); int mMaxRadius = RADIUS_AUTO; public RippleState(RippleState orig, RippleDrawable owner, Resources res) { -- cgit v1.2.3-59-g8ed1b