Search in sources :

Example 1 with Scale

use of com.transitionseverywhere.extra.Scale in project Transitions-Everywhere by andkulikov.

the class ScaleSample method onCreateView.

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_scale, container, false);
    final ViewGroup transitionsContainer = (ViewGroup) view.findViewById(R.id.transitions_container);
    final TextView text1 = (TextView) transitionsContainer.findViewById(R.id.text1);
    transitionsContainer.findViewById(R.id.button1).setOnClickListener(new VisibleToggleClickListener() {

        @Override
        protected void changeVisibility(boolean visible) {
            TransitionManager.beginDelayedTransition(transitionsContainer, new Scale());
            text1.setVisibility(visible ? View.VISIBLE : View.INVISIBLE);
        }
    });
    final TextView text2 = (TextView) transitionsContainer.findViewById(R.id.text2);
    transitionsContainer.findViewById(R.id.button2).setOnClickListener(new VisibleToggleClickListener() {

        @Override
        protected void changeVisibility(boolean visible) {
            TransitionSet set = new TransitionSet().addTransition(new Scale(0.7f)).addTransition(new Fade()).setInterpolator(visible ? new LinearOutSlowInInterpolator() : new FastOutLinearInInterpolator());
            TransitionManager.beginDelayedTransition(transitionsContainer, set);
            text2.setVisibility(visible ? View.VISIBLE : View.INVISIBLE);
        }
    });
    return view;
}
Also used : LinearOutSlowInInterpolator(android.support.v4.view.animation.LinearOutSlowInInterpolator) TransitionSet(com.transitionseverywhere.TransitionSet) ViewGroup(android.view.ViewGroup) FastOutLinearInInterpolator(android.support.v4.view.animation.FastOutLinearInInterpolator) TextView(android.widget.TextView) Scale(com.transitionseverywhere.extra.Scale) TextView(android.widget.TextView) View(android.view.View) Fade(com.transitionseverywhere.Fade) Nullable(android.support.annotation.Nullable)

Example 2 with Scale

use of com.transitionseverywhere.extra.Scale 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

Scale (com.transitionseverywhere.extra.Scale)2 Nullable (android.support.annotation.Nullable)1 FastOutLinearInInterpolator (android.support.v4.view.animation.FastOutLinearInInterpolator)1 LinearOutSlowInInterpolator (android.support.v4.view.animation.LinearOutSlowInInterpolator)1 InflateException (android.view.InflateException)1 View (android.view.View)1 ViewGroup (android.view.ViewGroup)1 TextView (android.widget.TextView)1 Fade (com.transitionseverywhere.Fade)1 TransitionSet (com.transitionseverywhere.TransitionSet)1 TranslationTransition (com.transitionseverywhere.extra.TranslationTransition)1