summaryrefslogtreecommitdiffstats
path: root/graphics
diff options
context:
space:
mode:
authorAlan Viverette <alanv@google.com>2014-08-07 20:56:55 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-08-06 23:49:20 +0000
commitf9b4c2cc6ffbcb21f8e9b015ed3bdab0501bdf65 (patch)
tree1ee3b86b8cc0efff494baf4c339c6be79a6e1ea4 /graphics
parentcd3a994e5067db8dd0edd45ac4ff8a64387ff7fc (diff)
parentac1f5884fb171f8a81819e9c0ce3402ad621f534 (diff)
downloadframeworks_base-f9b4c2cc6ffbcb21f8e9b015ed3bdab0501bdf65.zip
frameworks_base-f9b4c2cc6ffbcb21f8e9b015ed3bdab0501bdf65.tar.gz
frameworks_base-f9b4c2cc6ffbcb21f8e9b015ed3bdab0501bdf65.tar.bz2
Merge "Fix CTS test for nine patch padding sanity check" into lmp-dev
Diffstat (limited to 'graphics')
-rw-r--r--graphics/java/android/graphics/drawable/NinePatchDrawable.java19
1 files changed, 12 insertions, 7 deletions
diff --git a/graphics/java/android/graphics/drawable/NinePatchDrawable.java b/graphics/java/android/graphics/drawable/NinePatchDrawable.java
index 6ebb8b5..a6dbcb0 100644
--- a/graphics/java/android/graphics/drawable/NinePatchDrawable.java
+++ b/graphics/java/android/graphics/drawable/NinePatchDrawable.java
@@ -626,13 +626,18 @@ public class NinePatchDrawable extends Drawable {
mAutoMirrored = autoMirror;
// Sanity check for valid padding when we have optical insets.
- if (mPadding.left < mOpticalInsets.left) {
- mPadding.left = mOpticalInsets.left;
- mPadding.right = mOpticalInsets.right;
- }
- if (mPadding.top < mOpticalInsets.top) {
- mPadding.top = mOpticalInsets.top;
- mPadding.bottom = mOpticalInsets.bottom;
+ if (!opticalInsets.isEmpty()) {
+ if (mPadding == null) {
+ mPadding = new Rect();
+ }
+ if (mPadding.left < opticalInsets.left) {
+ mPadding.left = opticalInsets.left;
+ mPadding.right = opticalInsets.right;
+ }
+ if (mPadding.top < opticalInsets.top) {
+ mPadding.top = opticalInsets.top;
+ mPadding.bottom = opticalInsets.bottom;
+ }
}
}