Search in sources :

Example 1 with IconShape

use of com.android.launcher3.graphics.IconShape in project Neo-Launcher by NeoApplications.

the class IconShape method getAllShapes.

private static List<IconShape> getAllShapes(Context context) {
    ArrayList<IconShape> result = new ArrayList<>();
    try (XmlResourceParser parser = context.getResources().getXml(R.xml.folder_shapes)) {
        // Find the root tag
        int type;
        while ((type = parser.next()) != XmlPullParser.END_TAG && type != XmlPullParser.END_DOCUMENT && !"shapes".equals(parser.getName())) ;
        final int depth = parser.getDepth();
        int[] radiusAttr = new int[] { R.attr.folderIconRadius };
        IntArray keysToIgnore = new IntArray(0);
        while (((type = parser.next()) != XmlPullParser.END_TAG || parser.getDepth() > depth) && type != XmlPullParser.END_DOCUMENT) {
            if (type == XmlPullParser.START_TAG) {
                AttributeSet attrs = Xml.asAttributeSet(parser);
                TypedArray a = context.obtainStyledAttributes(attrs, radiusAttr);
                IconShape shape = getShapeDefinition(parser.getName(), a.getFloat(0, 1));
                a.recycle();
                shape.mAttrs = Themes.createValueMap(context, attrs, keysToIgnore);
                result.add(shape);
            }
        }
    } catch (IOException | XmlPullParserException e) {
        throw new RuntimeException(e);
    }
    return result;
}
Also used : XmlResourceParser(android.content.res.XmlResourceParser) ArrayList(java.util.ArrayList) IOException(java.io.IOException) Paint(android.graphics.Paint) IntArray(com.android.launcher3.util.IntArray) AttributeSet(android.util.AttributeSet) TypedArray(android.content.res.TypedArray) XmlPullParserException(org.xmlpull.v1.XmlPullParserException)

Example 2 with IconShape

use of com.android.launcher3.graphics.IconShape in project android_packages_apps_Trebuchet by LineageOS.

the class IconShape method getAllShapes.

private static List<IconShape> getAllShapes(Context context) {
    ArrayList<IconShape> result = new ArrayList<>();
    try (XmlResourceParser parser = context.getResources().getXml(R.xml.folder_shapes)) {
        // Find the root tag
        int type;
        while ((type = parser.next()) != XmlPullParser.END_TAG && type != XmlPullParser.END_DOCUMENT && !"shapes".equals(parser.getName())) ;
        final int depth = parser.getDepth();
        int[] radiusAttr = new int[] { R.attr.folderIconRadius };
        IntArray keysToIgnore = new IntArray(0);
        while (((type = parser.next()) != XmlPullParser.END_TAG || parser.getDepth() > depth) && type != XmlPullParser.END_DOCUMENT) {
            if (type == XmlPullParser.START_TAG) {
                AttributeSet attrs = Xml.asAttributeSet(parser);
                TypedArray a = context.obtainStyledAttributes(attrs, radiusAttr);
                IconShape shape = getShapeDefinition(parser.getName(), a.getFloat(0, 1));
                a.recycle();
                shape.mAttrs = Themes.createValueMap(context, attrs, keysToIgnore);
                result.add(shape);
            }
        }
    } catch (IOException | XmlPullParserException e) {
        throw new RuntimeException(e);
    }
    return result;
}
Also used : XmlResourceParser(android.content.res.XmlResourceParser) ArrayList(java.util.ArrayList) IOException(java.io.IOException) Paint(android.graphics.Paint) IntArray(com.android.launcher3.util.IntArray) AttributeSet(android.util.AttributeSet) TypedArray(android.content.res.TypedArray) XmlPullParserException(org.xmlpull.v1.XmlPullParserException)

Aggregations

TypedArray (android.content.res.TypedArray)2 XmlResourceParser (android.content.res.XmlResourceParser)2 Paint (android.graphics.Paint)2 AttributeSet (android.util.AttributeSet)2 IntArray (com.android.launcher3.util.IntArray)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)2