summaryrefslogtreecommitdiffstats
path: root/graphics
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2009-03-03 14:04:24 -0800
committerThe Android Open Source Project <initial-contribution@android.com>2009-03-03 14:04:24 -0800
commit076357b8567458d4b6dfdcf839ef751634cd2bfb (patch)
treeefbb2fd6f1dc67d2d606382fc3b82983e7cb2e1f /graphics
parent3dec7d563a2f3e1eb967ce2054a00b6620e3558c (diff)
downloadframeworks_base-076357b8567458d4b6dfdcf839ef751634cd2bfb.zip
frameworks_base-076357b8567458d4b6dfdcf839ef751634cd2bfb.tar.gz
frameworks_base-076357b8567458d4b6dfdcf839ef751634cd2bfb.tar.bz2
auto import from //depot/cupcake/@132589
Diffstat (limited to 'graphics')
-rw-r--r--graphics/java/android/graphics/drawable/Drawable.java2
-rw-r--r--graphics/java/android/graphics/drawable/NinePatchDrawable.java81
-rw-r--r--graphics/java/android/graphics/drawable/StateListDrawable.java15
3 files changed, 5 insertions, 93 deletions
diff --git a/graphics/java/android/graphics/drawable/Drawable.java b/graphics/java/android/graphics/drawable/Drawable.java
index 42e28e8..cf72f38 100644
--- a/graphics/java/android/graphics/drawable/Drawable.java
+++ b/graphics/java/android/graphics/drawable/Drawable.java
@@ -739,8 +739,6 @@ public abstract class Drawable {
if (r != null) {
((BitmapDrawable) drawable).setDensityScale(r.getDisplayMetrics());
}
- } else if (name.equals("nine-patch")) {
- drawable = new NinePatchDrawable();
} else {
throw new XmlPullParserException(parser.getPositionDescription() +
": invalid drawable tag " + name);
diff --git a/graphics/java/android/graphics/drawable/NinePatchDrawable.java b/graphics/java/android/graphics/drawable/NinePatchDrawable.java
index dace96c..3ded37b 100644
--- a/graphics/java/android/graphics/drawable/NinePatchDrawable.java
+++ b/graphics/java/android/graphics/drawable/NinePatchDrawable.java
@@ -17,15 +17,6 @@
package android.graphics.drawable;
import android.graphics.*;
-import android.content.res.Resources;
-import android.content.res.TypedArray;
-import android.util.AttributeSet;
-import android.util.TypedValue;
-import org.xmlpull.v1.XmlPullParser;
-import org.xmlpull.v1.XmlPullParserException;
-
-import java.io.IOException;
-import java.io.InputStream;
/**
*
@@ -41,9 +32,6 @@ public class NinePatchDrawable extends Drawable {
private Paint mPaint;
private boolean mMutated;
- NinePatchDrawable() {
- }
-
public NinePatchDrawable(Bitmap bitmap, byte[] chunk, Rect padding, String srcName) {
this(new NinePatchState(new NinePatch(bitmap, chunk, srcName), padding));
}
@@ -52,13 +40,6 @@ public class NinePatchDrawable extends Drawable {
this(new NinePatchState(patch, null));
}
- private void setNinePatchState(NinePatchState state) {
- mNinePatchState = state;
- mNinePatch = state.mNinePatch;
- mPadding = state.mPadding;
- if (state.mDither) setDither(state.mDither);
- }
-
// overrides
@Override
@@ -92,55 +73,6 @@ public class NinePatchDrawable extends Drawable {
getPaint().setDither(dither);
}
- @Override
- public void inflate(Resources r, XmlPullParser parser, AttributeSet attrs)
- throws XmlPullParserException, IOException {
- super.inflate(r, parser, attrs);
-
- TypedArray a = r.obtainAttributes(attrs, com.android.internal.R.styleable.NinePatchDrawable);
-
- final int id = a.getResourceId(com.android.internal.R.styleable.NinePatchDrawable_src, 0);
- if (id == 0) {
- throw new XmlPullParserException(parser.getPositionDescription() +
- ": <nine-patch> requires a valid src attribute");
- }
-
- final boolean dither = a.getBoolean(
- com.android.internal.R.styleable.NinePatchDrawable_dither, false);
- final BitmapFactory.Options options = new BitmapFactory.Options();
- if (dither) {
- options.inDither = false;
- }
-
- final Rect padding = new Rect();
- Bitmap bitmap = null;
-
- try {
- final TypedValue value = new TypedValue();
- final InputStream is = r.openRawResource(id, value);
-
- bitmap = BitmapFactory.decodeStream(r, value, is, padding, options);
-
- is.close();
- } catch (IOException e) {
- // Ignore
- }
-
- if (bitmap == null) {
- throw new XmlPullParserException(parser.getPositionDescription() +
- ": <nine-patch> requires a valid src attribute");
- } else if (bitmap.getNinePatchChunk() == null) {
- throw new XmlPullParserException(parser.getPositionDescription() +
- ": <nine-patch> requires a valid 9-patch source image");
- }
-
- setNinePatchState(new NinePatchState(
- new NinePatch(bitmap, bitmap.getNinePatchChunk(), "XML 9-patch"), padding, dither));
-
- a.recycle();
- }
-
-
public Paint getPaint() {
if (mPaint == null) {
mPaint = new Paint();
@@ -209,24 +141,17 @@ public class NinePatchDrawable extends Drawable {
final static class NinePatchState extends ConstantState {
final NinePatch mNinePatch;
final Rect mPadding;
- final boolean mDither;
int mChangingConfigurations;
NinePatchState(NinePatch ninePatch, Rect padding) {
- this(ninePatch, padding, false);
- }
-
- NinePatchState(NinePatch ninePatch, Rect rect, boolean dither) {
mNinePatch = ninePatch;
- mPadding = rect;
- mDither = dither;
+ mPadding = padding;
}
NinePatchState(NinePatchState state) {
mNinePatch = new NinePatch(state.mNinePatch);
mPadding = new Rect(state.mPadding);
mChangingConfigurations = state.mChangingConfigurations;
- mDither = state.mDither;
}
@Override
@@ -241,7 +166,9 @@ public class NinePatchDrawable extends Drawable {
}
private NinePatchDrawable(NinePatchState state) {
- setNinePatchState(state);
+ mNinePatchState = state;
+ mNinePatch = state.mNinePatch;
+ mPadding = state.mPadding;
}
}
diff --git a/graphics/java/android/graphics/drawable/StateListDrawable.java b/graphics/java/android/graphics/drawable/StateListDrawable.java
index d22a4ba..475825c 100644
--- a/graphics/java/android/graphics/drawable/StateListDrawable.java
+++ b/graphics/java/android/graphics/drawable/StateListDrawable.java
@@ -203,20 +203,7 @@ public class StateListDrawable extends DrawableContainer {
public Drawable getStateDrawable(int index) {
return mStateListState.getChildren()[index];
}
-
- /**
- * Gets the index of the drawable with the provided state set.
- *
- * @param stateSet the state set to look up
- * @return the index of the provided state set, or -1 if not found
- * @hide pending API council
- * @see #getStateDrawable(int)
- * @see #getStateSet(int)
- */
- public int getStateDrawableIndex(int[] stateSet) {
- return mStateListState.indexOfStateSet(stateSet);
- }
-
+
@Override
public Drawable mutate() {
if (!mMutated && super.mutate() == this) {