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);
}
}
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;
}
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;
}
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);
}
}
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();
}
}
Aggregations