Example usage for android.view.animation AnticipateOvershootInterpolator AnticipateOvershootInterpolator

List of usage examples for android.view.animation AnticipateOvershootInterpolator AnticipateOvershootInterpolator

Introduction

In this page you can find the example usage for android.view.animation AnticipateOvershootInterpolator AnticipateOvershootInterpolator.

Prototype

public AnticipateOvershootInterpolator(Context context, AttributeSet attrs) 

Source Link

Usage

From source file:Main.java

private static Interpolator createInterpolatorFromXml(Context c, XmlPullParser parser)
        throws XmlPullParserException, IOException {

    Interpolator interpolator = null;//from w w w .j  a v  a 2 s .c om

    // Make sure we are on a start tag.
    int type;
    int depth = parser.getDepth();

    while (((type = parser.next()) != XmlPullParser.END_TAG || parser.getDepth() > depth)
            && type != XmlPullParser.END_DOCUMENT) {

        if (type != XmlPullParser.START_TAG) {
            continue;
        }

        AttributeSet attrs = Xml.asAttributeSet(parser);

        String name = parser.getName();
        switch (name) {
        case "linearInterpolator":
            interpolator = new LinearInterpolator(c, attrs);
            break;
        case "accelerateInterpolator":
            interpolator = new AccelerateInterpolator(c, attrs);
            break;
        case "decelerateInterpolator":
            interpolator = new DecelerateInterpolator(c, attrs);
            break;
        case "accelerateDecelerateInterpolator":
            interpolator = new AccelerateDecelerateInterpolator(c, attrs);
            break;
        case "cycleInterpolator":
            interpolator = new CycleInterpolator(c, attrs);
            break;
        case "anticipateInterpolator":
            interpolator = new AnticipateInterpolator(c, attrs);
            break;
        case "overshootInterpolator":
            interpolator = new OvershootInterpolator(c, attrs);
            break;
        case "anticipateOvershootInterpolator":
            interpolator = new AnticipateOvershootInterpolator(c, attrs);
            break;
        case "bounceInterpolator":
            interpolator = new BounceInterpolator(c, attrs);
            break;
        default:
            throw new RuntimeException("Unknown interpolator name: " + parser.getName());
        }

    }

    return interpolator;

}

From source file:com.hippo.anani.AnimationUtils.java

private static Interpolator createInterpolatorFromXml(Context context, XmlPullParser parser)
        throws XmlPullParserException, IOException {

    Interpolator interpolator = null;/*from w  w w . ja  v  a2  s .c  om*/

    // Make sure we are on a start tag.
    int type;
    int depth = parser.getDepth();

    while (((type = parser.next()) != XmlPullParser.END_TAG || parser.getDepth() > depth)
            && type != XmlPullParser.END_DOCUMENT) {

        if (type != XmlPullParser.START_TAG) {
            continue;
        }

        AttributeSet attrs = Xml.asAttributeSet(parser);

        String name = parser.getName();

        if (name.equals("linearInterpolator")) {
            interpolator = new LinearInterpolator();
        } else if (name.equals("accelerateInterpolator")) {
            interpolator = new AccelerateInterpolator(context, attrs);
        } else if (name.equals("decelerateInterpolator")) {
            interpolator = new DecelerateInterpolator(context, attrs);
        } else if (name.equals("accelerateDecelerateInterpolator")) {
            interpolator = new AccelerateDecelerateInterpolator();
        } else if (name.equals("cycleInterpolator")) {
            interpolator = new CycleInterpolator(context, attrs);
        } else if (name.equals("anticipateInterpolator")) {
            interpolator = new AnticipateInterpolator(context, attrs);
        } else if (name.equals("overshootInterpolator")) {
            interpolator = new OvershootInterpolator(context, attrs);
        } else if (name.equals("anticipateOvershootInterpolator")) {
            interpolator = new AnticipateOvershootInterpolator(context, attrs);
        } else if (name.equals("bounceInterpolator")) {
            interpolator = new BounceInterpolator();
        } else if (name.equals("pathInterpolator")) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                interpolator = new android.view.animation.PathInterpolator(context, attrs);
            } else {
                interpolator = new PathInterpolator(context, attrs);
            }
        } else {
            throw new RuntimeException("Unknown interpolator name: " + parser.getName());
        }
    }
    return interpolator;
}

From source file:android.support.graphics.drawable.AnimationUtilsCompat.java

private static Interpolator createInterpolatorFromXml(Context context, Resources res, Theme theme,
        XmlPullParser parser) throws XmlPullParserException, IOException {

    Interpolator interpolator = null;/*from   w ww.ja  v a  2s .  com*/

    // Make sure we are on a start tag.
    int type;
    int depth = parser.getDepth();

    while (((type = parser.next()) != XmlPullParser.END_TAG || parser.getDepth() > depth)
            && type != XmlPullParser.END_DOCUMENT) {

        if (type != XmlPullParser.START_TAG) {
            continue;
        }

        AttributeSet attrs = Xml.asAttributeSet(parser);

        String name = parser.getName();

        if (name.equals("linearInterpolator")) {
            interpolator = new LinearInterpolator();
        } else if (name.equals("accelerateInterpolator")) {
            interpolator = new AccelerateInterpolator(context, attrs);
        } else if (name.equals("decelerateInterpolator")) {
            interpolator = new DecelerateInterpolator(context, attrs);
        } else if (name.equals("accelerateDecelerateInterpolator")) {
            interpolator = new AccelerateDecelerateInterpolator();
        } else if (name.equals("cycleInterpolator")) {
            interpolator = new CycleInterpolator(context, attrs);
        } else if (name.equals("anticipateInterpolator")) {
            interpolator = new AnticipateInterpolator(context, attrs);
        } else if (name.equals("overshootInterpolator")) {
            interpolator = new OvershootInterpolator(context, attrs);
        } else if (name.equals("anticipateOvershootInterpolator")) {
            interpolator = new AnticipateOvershootInterpolator(context, attrs);
        } else if (name.equals("bounceInterpolator")) {
            interpolator = new BounceInterpolator();
        } else if (name.equals("pathInterpolator")) {
            interpolator = new PathInterpolatorCompat(context, attrs, parser);
        } else {
            throw new RuntimeException("Unknown interpolator name: " + parser.getName());
        }
    }
    return interpolator;
}

From source file:com.savvasdalkitsis.betwixt.Interpolators.java

/**
 * <strong>ANDROID INTERPOLATOR</strong><br/><br/>
 * An interpolator where the change starts backward then flings forward and overshoots the
 * target value and finally goes back to the final value.
 * @param tension Amount of anticipation/overshoot. When tension equals 0.0f, there is no
 *                anticipation/overshoot and the interpolator becomes a simple
 *                acceleration/deceleration interpolator.
 * @param extraTension Amount by which to multiply the tension. For instance, to get the same
 *                     overshoot as an OvershootInterpolator with a tension of 2.0f, you would
 *                     use an extraTension of 1.5f.
 *//*ww w. j  a v  a2 s . c  om*/
@NonNull
public static Interpolator anticipateOvershoot(int tension, int extraTension) {
    return new AnticipateOvershootInterpolator(tension, extraTension);
}