You've already forked android_translation_layer
mirror of
https://gitlab.com/android_translation_layer/android_translation_layer.git
synced 2025-10-27 11:48:10 -07:00
Drawable: implement GradientDrawable.inflate() and Drawable.createFromXmlInner()
This commit is contained in:
@@ -176,15 +176,26 @@ public class Drawable {
|
|||||||
while ((type=parser.next()) != XmlPullParser.START_TAG && type != XmlPullParser.END_DOCUMENT);
|
while ((type=parser.next()) != XmlPullParser.START_TAG && type != XmlPullParser.END_DOCUMENT);
|
||||||
if (type != XmlPullParser.START_TAG)
|
if (type != XmlPullParser.START_TAG)
|
||||||
throw new XmlPullParserException("No start tag found");
|
throw new XmlPullParserException("No start tag found");
|
||||||
|
|
||||||
|
return createFromXmlInner(resources, parser, parser, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Drawable createFromXmlInner(Resources resources, XmlPullParser parser, AttributeSet attrs) throws XmlPullParserException, IOException {
|
||||||
|
return createFromXmlInner(resources, parser, attrs, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Drawable createFromXmlInner(Resources resources, XmlPullParser parser, AttributeSet attrs, Theme theme) throws XmlPullParserException, IOException {
|
||||||
if ("selector".equals(parser.getName())) {
|
if ("selector".equals(parser.getName())) {
|
||||||
StateListDrawable drawable = new StateListDrawable();
|
StateListDrawable drawable = new StateListDrawable();
|
||||||
drawable.inflate(resources, parser, parser, null);
|
drawable.inflate(resources, parser, attrs, null);
|
||||||
return drawable;
|
return drawable;
|
||||||
} else if ("shape".equals(parser.getName())) {
|
} else if ("shape".equals(parser.getName())) {
|
||||||
return new GradientDrawable();
|
GradientDrawable drawable = new GradientDrawable();
|
||||||
|
drawable.inflate(resources, parser, attrs);
|
||||||
|
return drawable;
|
||||||
} else if ("bitmap".equals(parser.getName())) {
|
} else if ("bitmap".equals(parser.getName())) {
|
||||||
BitmapDrawable drawable = new BitmapDrawable();
|
BitmapDrawable drawable = new BitmapDrawable();
|
||||||
drawable.inflate(resources, parser, parser, null);
|
drawable.inflate(resources, parser, attrs, null);
|
||||||
return drawable;
|
return drawable;
|
||||||
} else if ("transition".equals(parser.getName())) {
|
} else if ("transition".equals(parser.getName())) {
|
||||||
return new Drawable();
|
return new Drawable();
|
||||||
@@ -193,7 +204,7 @@ public class Drawable {
|
|||||||
return new ColorDrawable(0);
|
return new ColorDrawable(0);
|
||||||
} else if ("vector".equals(parser.getName())) {
|
} else if ("vector".equals(parser.getName())) {
|
||||||
VectorDrawable drawable = new VectorDrawable();
|
VectorDrawable drawable = new VectorDrawable();
|
||||||
drawable.inflate(resources, parser, parser, null);
|
drawable.inflate(resources, parser, attrs, null);
|
||||||
return drawable;
|
return drawable;
|
||||||
} else if ("layer-list".equals(parser.getName())) {
|
} else if ("layer-list".equals(parser.getName())) {
|
||||||
return new LayerDrawable();
|
return new LayerDrawable();
|
||||||
@@ -201,14 +212,6 @@ public class Drawable {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Drawable createFromXmlInner(Resources resources, XmlPullParser parser, AttributeSet attrs) {
|
|
||||||
return createFromXmlInner(resources, parser, attrs, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Drawable createFromXmlInner(Resources resources, XmlPullParser parser, AttributeSet attrs, Theme theme) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Drawable createFromResourceStream(Resources resources, TypedValue value, InputStream is, String file,
|
public static Drawable createFromResourceStream(Resources resources, TypedValue value, InputStream is, String file,
|
||||||
Object object) {
|
Object object) {
|
||||||
Path path = Paths.get(android.os.Environment.getExternalStorageDirectory().getPath(), file);
|
Path path = Paths.get(android.os.Environment.getExternalStorageDirectory().getPath(), file);
|
||||||
|
|||||||
@@ -850,7 +850,6 @@ public class GradientDrawable extends Drawable {
|
|||||||
return !mRect.isEmpty();
|
return !mRect.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* @Override
|
|
||||||
public void inflate(Resources r, XmlPullParser parser,
|
public void inflate(Resources r, XmlPullParser parser,
|
||||||
AttributeSet attrs)
|
AttributeSet attrs)
|
||||||
throws XmlPullParserException, IOException {
|
throws XmlPullParserException, IOException {
|
||||||
@@ -860,8 +859,8 @@ public class GradientDrawable extends Drawable {
|
|||||||
TypedArray a = r.obtainAttributes(attrs,
|
TypedArray a = r.obtainAttributes(attrs,
|
||||||
com.android.internal.R.styleable.GradientDrawable);
|
com.android.internal.R.styleable.GradientDrawable);
|
||||||
|
|
||||||
super.inflateWithAttributes(r, parser, a,
|
// super.inflateWithAttributes(r, parser, a,
|
||||||
com.android.internal.R.styleable.GradientDrawable_visible);
|
// com.android.internal.R.styleable.GradientDrawable_visible);
|
||||||
|
|
||||||
int shapeType = a.getInt(
|
int shapeType = a.getInt(
|
||||||
com.android.internal.R.styleable.GradientDrawable_shape, RECTANGLE);
|
com.android.internal.R.styleable.GradientDrawable_shape, RECTANGLE);
|
||||||
@@ -1078,7 +1077,7 @@ public class GradientDrawable extends Drawable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mGradientState.computeOpacity();
|
mGradientState.computeOpacity();
|
||||||
}*/
|
}
|
||||||
|
|
||||||
private static float getFloatOrFraction(TypedArray a, int index, float defaultValue) {
|
private static float getFloatOrFraction(TypedArray a, int index, float defaultValue) {
|
||||||
TypedValue tv = a.peekValue(index);
|
TypedValue tv = a.peekValue(index);
|
||||||
|
|||||||
@@ -155,7 +155,7 @@ public class StateListDrawable extends DrawableContainer {
|
|||||||
+ ": <item> tag requires a 'drawable' attribute or "
|
+ ": <item> tag requires a 'drawable' attribute or "
|
||||||
+ "child tag defining a drawable");
|
+ "child tag defining a drawable");
|
||||||
}
|
}
|
||||||
// dr = Drawable.createFromXmlInner(r, parser, attrs, theme);
|
dr = Drawable.createFromXmlInner(r, parser, attrs, theme);
|
||||||
}
|
}
|
||||||
|
|
||||||
state.addStateSet(states, dr);
|
state.addStateSet(states, dr);
|
||||||
|
|||||||
Reference in New Issue
Block a user