Drawable: implement GradientDrawable.inflate() and Drawable.createFromXmlInner()

This commit is contained in:
Julian Winkler
2024-05-19 15:06:17 +02:00
parent dd3965df8a
commit 765f01e715
3 changed files with 19 additions and 17 deletions

View File

@@ -176,15 +176,26 @@ public class Drawable {
while ((type=parser.next()) != XmlPullParser.START_TAG && type != XmlPullParser.END_DOCUMENT);
if (type != XmlPullParser.START_TAG)
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())) {
StateListDrawable drawable = new StateListDrawable();
drawable.inflate(resources, parser, parser, null);
drawable.inflate(resources, parser, attrs, null);
return drawable;
} 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())) {
BitmapDrawable drawable = new BitmapDrawable();
drawable.inflate(resources, parser, parser, null);
drawable.inflate(resources, parser, attrs, null);
return drawable;
} else if ("transition".equals(parser.getName())) {
return new Drawable();
@@ -193,7 +204,7 @@ public class Drawable {
return new ColorDrawable(0);
} else if ("vector".equals(parser.getName())) {
VectorDrawable drawable = new VectorDrawable();
drawable.inflate(resources, parser, parser, null);
drawable.inflate(resources, parser, attrs, null);
return drawable;
} else if ("layer-list".equals(parser.getName())) {
return new LayerDrawable();
@@ -201,14 +212,6 @@ public class Drawable {
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,
Object object) {
Path path = Paths.get(android.os.Environment.getExternalStorageDirectory().getPath(), file);