use of android.view.InflateException in project android_frameworks_base by DirtyUnicorns.
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 android_frameworks_base by DirtyUnicorns.
the class PathInterpolator method parseInterpolatorFromTypeArray.
private void parseInterpolatorFromTypeArray(TypedArray a) {
// will be all coming from pathData.
if (a.hasValue(R.styleable.PathInterpolator_pathData)) {
String pathData = a.getString(R.styleable.PathInterpolator_pathData);
Path path = PathParser.createPathFromPathData(pathData);
if (path == null) {
throw new InflateException("The path is null, which is created" + " from " + pathData);
}
initPath(path);
} else {
if (!a.hasValue(R.styleable.PathInterpolator_controlX1)) {
throw new InflateException("pathInterpolator requires the controlX1 attribute");
} else if (!a.hasValue(R.styleable.PathInterpolator_controlY1)) {
throw new InflateException("pathInterpolator requires the controlY1 attribute");
}
float x1 = a.getFloat(R.styleable.PathInterpolator_controlX1, 0);
float y1 = a.getFloat(R.styleable.PathInterpolator_controlY1, 0);
boolean hasX2 = a.hasValue(R.styleable.PathInterpolator_controlX2);
boolean hasY2 = a.hasValue(R.styleable.PathInterpolator_controlY2);
if (hasX2 != hasY2) {
throw new InflateException("pathInterpolator requires both controlX2 and controlY2 for cubic Beziers.");
}
if (!hasX2) {
initQuad(x1, y1);
} else {
float x2 = a.getFloat(R.styleable.PathInterpolator_controlX2, 0);
float y2 = a.getFloat(R.styleable.PathInterpolator_controlY2, 0);
initCubic(x1, y1, x2, y2);
}
}
}
use of android.view.InflateException in project material-components-android by material-components.
the class TabLayoutTest method testInflateTabLayoutWithNonTabItem.
@Test
@UiThreadTest
public void testInflateTabLayoutWithNonTabItem() throws Throwable {
try {
final LayoutInflater inflater = LayoutInflater.from(activityTestRule.getActivity());
inflater.inflate(R.layout.design_tabs_with_non_tabitems, null);
} catch (Throwable throwable) {
assertTrue(throwable instanceof InflateException || throwable instanceof IllegalArgumentException);
}
}
use of android.view.InflateException in project Transitions-Everywhere by andkulikov.
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);
if (!constructor.isAccessible()) {
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 Transitions-Everywhere by andkulikov.
the class TransitionInflater method createTransitionFromXml.
//
// Transition loading
//
private Transition createTransitionFromXml(XmlPullParser parser, AttributeSet attrs, Transition parent) throws XmlPullParserException, IOException {
Transition transition = null;
// Make sure we are on a start tag.
int type;
int depth = parser.getDepth();
TransitionSet transitionSet = (parent instanceof TransitionSet) ? (TransitionSet) parent : null;
while (((type = parser.next()) != XmlPullParser.END_TAG || parser.getDepth() > depth) && type != XmlPullParser.END_DOCUMENT) {
if (type != XmlPullParser.START_TAG) {
continue;
}
String name = parser.getName();
if ("fade".equals(name)) {
transition = new Fade(mContext, attrs);
} else if ("changeBounds".equals(name)) {
transition = new ChangeBounds(mContext, attrs);
} else if ("slide".equals(name)) {
transition = new Slide(mContext, attrs);
} else if ("explode".equals(name)) {
transition = new Explode(mContext, attrs);
} else if ("changeImageTransform".equals(name)) {
transition = new ChangeImageTransform(mContext, attrs);
} else if ("changeTransform".equals(name)) {
transition = new ChangeTransform(mContext, attrs);
} else if ("changeClipBounds".equals(name)) {
transition = new ChangeClipBounds(mContext, attrs);
} else if ("autoTransition".equals(name)) {
transition = new AutoTransition(mContext, attrs);
} else if ("recolor".equals(name)) {
transition = new Recolor(mContext, attrs);
} else if ("changeScroll".equals(name)) {
transition = new ChangeScroll(mContext, attrs);
} else if ("transitionSet".equals(name)) {
transition = new TransitionSet(mContext, attrs);
} else if ("scale".equals(name)) {
transition = new Scale(mContext, attrs);
} else if ("translation".equals(name)) {
transition = new TranslationTransition(mContext, attrs);
} else if ("transition".equals(name)) {
transition = (Transition) createCustom(attrs, Transition.class, "transition");
} else if ("targets".equals(name)) {
getTargetIds(parser, attrs, parent);
} else if ("arcMotion".equals(name)) {
parent.setPathMotion(new ArcMotion(mContext, attrs));
} else if ("pathMotion".equals(name)) {
parent.setPathMotion((PathMotion) createCustom(attrs, PathMotion.class, "pathMotion"));
} else if ("patternPathMotion".equals(name)) {
parent.setPathMotion(new PatternPathMotion(mContext, attrs));
} else {
throw new RuntimeException("Unknown scene name: " + parser.getName());
}
if (transition != null) {
if (!parser.isEmptyElementTag()) {
createTransitionFromXml(parser, attrs, transition);
}
if (transitionSet != null) {
transitionSet.addTransition(transition);
transition = null;
} else if (parent != null) {
throw new InflateException("Could not add transition to another transition.");
}
}
}
return transition;
}
Aggregations