load Route Once RotateAnimation - Android android.animation

Android examples for android.animation:RotateAnimation

Description

load Route Once RotateAnimation

Demo Code


//package com.java2s;
import android.view.animation.Animation;
import android.view.animation.LinearInterpolator;
import android.view.animation.RotateAnimation;

public class Main {
    public static final long TIME = 2000;

    public static RotateAnimation loadRouteOnce(float fromDegrees,
            float toDegrees) {
        return loadRoute(fromDegrees, toDegrees, 0);
    }/*from  w  w  w.  ja  v a  2s.  c om*/

    public static RotateAnimation loadRoute(float fromDegrees,
            float toDegrees, int repeatCount) {
        RotateAnimation gpsLocAni = null;
        gpsLocAni = new RotateAnimation(fromDegrees, toDegrees,
                Animation.RELATIVE_TO_SELF, 0.5f,
                Animation.RELATIVE_TO_SELF, 0.5f);
        long time = (long) (toDegrees - fromDegrees) * TIME / 360;
        gpsLocAni.setDuration(time);
        if (repeatCount < 0) {
            gpsLocAni.setRepeatCount(Animation.INFINITE);
        } else {
            gpsLocAni.setRepeatCount(repeatCount);
        }

        // gpsLocAni.setRepeatMode(Animation.RESTART);
        gpsLocAni.setFillAfter(true);
        gpsLocAni.setInterpolator(new LinearInterpolator());// ????
        return gpsLocAni;
    }
}

Related Tutorials