Example usage for android.view.animation DecelerateInterpolator DecelerateInterpolator

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

Introduction

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

Prototype

public DecelerateInterpolator(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  www .jav a  2  s  .  c  o  m*/

    // 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 ww .ja 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();

        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  w w  .  j a  v  a  2s  .  co m*/

    // 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;
}