Search in sources :

Example 21 with InflateException

use of android.view.InflateException in project android_frameworks_base by AOSPA.

the class TransitionInflater method createCustom.

private Object createCustom(AttributeSet attrs, Class expectedType, String tag) {
    String className = attrs.getAttributeValue(null, "class");
    if (className == null) {
        throw new InflateException(tag + " tag must have a 'class' attribute");
    }
    try {
        synchronized (sConstructors) {
            Constructor constructor = sConstructors.get(className);
            if (constructor == null) {
                Class c = mContext.getClassLoader().loadClass(className).asSubclass(expectedType);
                if (c != null) {
                    constructor = c.getConstructor(sConstructorSignature);
                    constructor.setAccessible(true);
                    sConstructors.put(className, constructor);
                }
            }
            return constructor.newInstance(mContext, attrs);
        }
    } catch (InstantiationException e) {
        throw new InflateException("Could not instantiate " + expectedType + " class " + className, e);
    } catch (ClassNotFoundException e) {
        throw new InflateException("Could not instantiate " + expectedType + " class " + className, e);
    } catch (InvocationTargetException e) {
        throw new InflateException("Could not instantiate " + expectedType + " class " + className, e);
    } catch (NoSuchMethodException e) {
        throw new InflateException("Could not instantiate " + expectedType + " class " + className, e);
    } catch (IllegalAccessException e) {
        throw new InflateException("Could not instantiate " + expectedType + " class " + className, e);
    }
}
Also used : Constructor(java.lang.reflect.Constructor) InflateException(android.view.InflateException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 22 with InflateException

use of android.view.InflateException in project android_frameworks_base by AOSPA.

the class Transition method parseMatchOrder.

private static int[] parseMatchOrder(String matchOrderString) {
    StringTokenizer st = new StringTokenizer(matchOrderString, ",");
    int[] matches = new int[st.countTokens()];
    int index = 0;
    while (st.hasMoreTokens()) {
        String token = st.nextToken().trim();
        if (MATCH_ID_STR.equalsIgnoreCase(token)) {
            matches[index] = Transition.MATCH_ID;
        } else if (MATCH_INSTANCE_STR.equalsIgnoreCase(token)) {
            matches[index] = Transition.MATCH_INSTANCE;
        } else if (MATCH_NAME_STR.equalsIgnoreCase(token)) {
            matches[index] = Transition.MATCH_NAME;
        } else if (MATCH_VIEW_NAME_STR.equalsIgnoreCase(token)) {
            matches[index] = Transition.MATCH_NAME;
        } else if (MATCH_ITEM_ID_STR.equalsIgnoreCase(token)) {
            matches[index] = Transition.MATCH_ITEM_ID;
        } else if (token.isEmpty()) {
            int[] smallerMatches = new int[matches.length - 1];
            System.arraycopy(matches, 0, smallerMatches, 0, index);
            matches = smallerMatches;
            index--;
        } else {
            throw new InflateException("Unknown match type in matchOrder: '" + token + "'");
        }
        index++;
    }
    return matches;
}
Also used : StringTokenizer(java.util.StringTokenizer) InflateException(android.view.InflateException)

Example 23 with InflateException

use of android.view.InflateException in project platform_frameworks_base by android.

the class Transition method parseMatchOrder.

private static int[] parseMatchOrder(String matchOrderString) {
    StringTokenizer st = new StringTokenizer(matchOrderString, ",");
    int[] matches = new int[st.countTokens()];
    int index = 0;
    while (st.hasMoreTokens()) {
        String token = st.nextToken().trim();
        if (MATCH_ID_STR.equalsIgnoreCase(token)) {
            matches[index] = Transition.MATCH_ID;
        } else if (MATCH_INSTANCE_STR.equalsIgnoreCase(token)) {
            matches[index] = Transition.MATCH_INSTANCE;
        } else if (MATCH_NAME_STR.equalsIgnoreCase(token)) {
            matches[index] = Transition.MATCH_NAME;
        } else if (MATCH_VIEW_NAME_STR.equalsIgnoreCase(token)) {
            matches[index] = Transition.MATCH_NAME;
        } else if (MATCH_ITEM_ID_STR.equalsIgnoreCase(token)) {
            matches[index] = Transition.MATCH_ITEM_ID;
        } else if (token.isEmpty()) {
            int[] smallerMatches = new int[matches.length - 1];
            System.arraycopy(matches, 0, smallerMatches, 0, index);
            matches = smallerMatches;
            index--;
        } else {
            throw new InflateException("Unknown match type in matchOrder: '" + token + "'");
        }
        index++;
    }
    return matches;
}
Also used : StringTokenizer(java.util.StringTokenizer) InflateException(android.view.InflateException)

Example 24 with InflateException

use of android.view.InflateException in project platform_frameworks_base by android.

the class TransitionInflater method createCustom.

private Object createCustom(AttributeSet attrs, Class expectedType, String tag) {
    String className = attrs.getAttributeValue(null, "class");
    if (className == null) {
        throw new InflateException(tag + " tag must have a 'class' attribute");
    }
    try {
        synchronized (sConstructors) {
            Constructor constructor = sConstructors.get(className);
            if (constructor == null) {
                Class c = mContext.getClassLoader().loadClass(className).asSubclass(expectedType);
                if (c != null) {
                    constructor = c.getConstructor(sConstructorSignature);
                    constructor.setAccessible(true);
                    sConstructors.put(className, constructor);
                }
            }
            return constructor.newInstance(mContext, attrs);
        }
    } catch (InstantiationException e) {
        throw new InflateException("Could not instantiate " + expectedType + " class " + className, e);
    } catch (ClassNotFoundException e) {
        throw new InflateException("Could not instantiate " + expectedType + " class " + className, e);
    } catch (InvocationTargetException e) {
        throw new InflateException("Could not instantiate " + expectedType + " class " + className, e);
    } catch (NoSuchMethodException e) {
        throw new InflateException("Could not instantiate " + expectedType + " class " + className, e);
    } catch (IllegalAccessException e) {
        throw new InflateException("Could not instantiate " + expectedType + " class " + className, e);
    }
}
Also used : Constructor(java.lang.reflect.Constructor) InflateException(android.view.InflateException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 25 with InflateException

use of android.view.InflateException in project platform_frameworks_base by android.

the class SimpleInflater method inflate.

public void inflate(int menuRes) {
    XmlResourceParser parser = null;
    try {
        parser = mContext.getResources().getLayout(menuRes);
        AttributeSet attrs = Xml.asAttributeSet(parser);
        parseMenu(parser, attrs);
    } catch (XmlPullParserException e) {
        throw new InflateException("Error inflating menu XML", e);
    } catch (IOException e) {
        throw new InflateException("Error inflating menu XML", e);
    } finally {
        if (parser != null)
            parser.close();
    }
}
Also used : XmlResourceParser(android.content.res.XmlResourceParser) AttributeSet(android.util.AttributeSet) InflateException(android.view.InflateException) XmlPullParserException(org.xmlpull.v1.XmlPullParserException) IOException(java.io.IOException)

Aggregations

InflateException (android.view.InflateException)100 IOException (java.io.IOException)51 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)48 AttributeSet (android.util.AttributeSet)30 XmlResourceParser (android.content.res.XmlResourceParser)19 Constructor (java.lang.reflect.Constructor)13 View (android.view.View)12 Path (android.graphics.Path)10 SuppressLint (android.annotation.SuppressLint)6 InvocationTargetException (java.lang.reflect.InvocationTargetException)6 StringTokenizer (java.util.StringTokenizer)6 NonNull (android.annotation.NonNull)5 PathParser (android.util.PathParser)5 TypedValue (android.util.TypedValue)5 NonNull (android.support.annotation.NonNull)4 ExpandedMenuView (android.support.v7.internal.view.menu.ExpandedMenuView)4 ActionBarView (android.support.v7.internal.widget.ActionBarView)4 ViewGroup (android.view.ViewGroup)4 AlertDialog (android.app.AlertDialog)3 LayoutInflater (android.view.LayoutInflater)3