Search in sources :

Example 1 with TranslationTransition

use of com.transitionseverywhere.extra.TranslationTransition 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;
}
Also used : Scale(com.transitionseverywhere.extra.Scale) TranslationTransition(com.transitionseverywhere.extra.TranslationTransition) TranslationTransition(com.transitionseverywhere.extra.TranslationTransition) InflateException(android.view.InflateException)

Aggregations

InflateException (android.view.InflateException)1 Scale (com.transitionseverywhere.extra.Scale)1 TranslationTransition (com.transitionseverywhere.extra.TranslationTransition)1