Example usage for android.view.animation RotateAnimation RotateAnimation

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

Introduction

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

Prototype

public RotateAnimation(float fromDegrees, float toDegrees, int pivotXType, float pivotXValue, int pivotYType,
        float pivotYValue) 

Source Link

Document

Constructor to use when building a RotateAnimation from code

Usage

From source file:Main.java

public static Animation createForeverReverseRotationAnimation() {
    Animation mRotateAnimation = new RotateAnimation(720, 0, Animation.RESTART, 0.5f, Animation.RESTART, 0.5f);
    mRotateAnimation.setInterpolator(new LinearInterpolator());
    mRotateAnimation.setRepeatCount(Animation.INFINITE);
    mRotateAnimation.setRepeatMode(Animation.RESTART);
    mRotateAnimation.setStartTime(Animation.START_ON_FIRST_FRAME);
    return mRotateAnimation;
}

From source file:Main.java

public static AnimationSet RotateAndFadeOutAnimation() {
    AlphaAnimation fade_out = new AlphaAnimation(1f, 0.2f);
    fade_out.setDuration(500);//from  www  .ja  va2 s .  co  m
    fade_out.setStartOffset(0);
    fade_out.setFillAfter(true);

    ScaleAnimation shrink = new ScaleAnimation(1f, 0.2f, 1f, 0.2f, Animation.RELATIVE_TO_SELF, .5f,
            Animation.RELATIVE_TO_SELF, .5f);
    shrink.setDuration(400);
    shrink.setStartOffset(0);
    shrink.setFillAfter(true);

    RotateAnimation rotate = new RotateAnimation(0.0f, 360f, Animation.RELATIVE_TO_SELF, .5f,
            Animation.RELATIVE_TO_SELF, .5f);
    rotate.setDuration(500);
    rotate.setStartOffset(0);
    rotate.setInterpolator(new LinearInterpolator());
    rotate.setFillAfter(true);

    AnimationSet Reload = new AnimationSet(true);
    Reload.addAnimation(fade_out);
    Reload.addAnimation(shrink);
    Reload.addAnimation(rotate);
    Reload.setInterpolator(new AccelerateInterpolator(1.1f));

    return Reload;
}

From source file:Main.java

public static List<Animation> initAnimation(int AnimationType, float fromAlpha, float toAlpha,
        float fromDegress, float toDegress, float pinX, float pinY) {
    List<Animation> animations = new ArrayList<>();
    AlphaAnimation alphaAnimation = new AlphaAnimation(fromAlpha, toAlpha);
    alphaAnimation.setDuration(300);/*from   w  w w  .  ja  v  a  2  s .co m*/
    AlphaAnimation exit_alphaAnimation = new AlphaAnimation(toAlpha, fromAlpha);
    exit_alphaAnimation.setDuration(300);
    OvershootInterpolator overshootInterpolator = new OvershootInterpolator(3.5f);
    RotateAnimation rotateAnimation = new RotateAnimation(fromDegress, toDegress, AnimationType, pinX,
            AnimationType, pinY);
    rotateAnimation.setDuration(300);
    rotateAnimation.setInterpolator(overshootInterpolator);
    rotateAnimation.setFillAfter(true);
    RotateAnimation exit_rotateAnimation = new RotateAnimation(toDegress, fromAlpha, AnimationType, pinX,
            AnimationType, pinY);
    exit_rotateAnimation.setDuration(300);
    exit_rotateAnimation.setInterpolator(overshootInterpolator);
    exit_rotateAnimation.setFillAfter(true);
    animations.add(alphaAnimation);
    animations.add(exit_alphaAnimation);
    animations.add(rotateAnimation);
    animations.add(exit_rotateAnimation);
    return animations;
}

From source file:com.canyinghao.canrefresh.classic.RotateRefreshView.java

public RotateRefreshView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    mRotateAnimation = new RotateAnimation(0, 720, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
            0.5f);// w  w  w .j a va 2  s.co  m
    rotateHight = (int) getResources().getDimension(R.dimen.refresh_height_rotate);

    View v = LayoutInflater.from(context).inflate(R.layout.layout_rotate_refresh, null);

    addView(v);

    FrameLayout.LayoutParams params = (LayoutParams) v.getLayoutParams();
    params.height = rotateHight;
    v.setLayoutParams(params);

}

From source file:com.idreamsky.dreamroom.ui.custum.CatLoadingView.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    if (mDialog == null) {
        mDialog = new Dialog(getActivity(), R.style.cart_dialog);
        mDialog.setContentView(R.layout.catloading_main);
        mDialog.setCanceledOnTouchOutside(true);
        mDialog.getWindow().setGravity(Gravity.CENTER);

        operatingAnim = new RotateAnimation(360f, 0f, Animation.RELATIVE_TO_SELF, 0.5f,
                Animation.RELATIVE_TO_SELF, 0.5f);
        operatingAnim.setRepeatCount(Animation.INFINITE);
        operatingAnim.setDuration(2000);

        eye_left_Anim = new RotateAnimation(360f, 0f, Animation.RELATIVE_TO_SELF, 0.5f,
                Animation.RELATIVE_TO_SELF, 0.5f);
        eye_left_Anim.setRepeatCount(Animation.INFINITE);
        eye_left_Anim.setDuration(2000);

        eye_right_Anim = new RotateAnimation(360f, 0f, Animation.RELATIVE_TO_SELF, 0.5f,
                Animation.RELATIVE_TO_SELF, 0.5f);
        eye_right_Anim.setRepeatCount(Animation.INFINITE);
        eye_right_Anim.setDuration(2000);

        LinearInterpolator lin = new LinearInterpolator();
        operatingAnim.setInterpolator(lin);
        eye_left_Anim.setInterpolator(lin);
        eye_right_Anim.setInterpolator(lin);

        View view = mDialog.getWindow().getDecorView();

        mouse = view.findViewById(R.id.mouse);

        eye_left = view.findViewById(R.id.eye_left);

        eye_right = view.findViewById(R.id.eye_right);

        eyelid_left = (EyelidView) view.findViewById(R.id.eyelid_left);

        eyelid_left.setColor(Color.parseColor("#d0ced1"));

        eyelid_left.setFromFull(true);/*from  w  w w  .j a v  a  2  s. c  om*/

        eyelid_right = (EyelidView) view.findViewById(R.id.eyelid_right);

        eyelid_right.setColor(Color.parseColor("#d0ced1"));

        eyelid_right.setFromFull(true);

        mGraduallyTextView = (GraduallyTextView) view.findViewById(R.id.graduallyTextView);

        operatingAnim.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {
            }

            @Override
            public void onAnimationEnd(Animation animation) {
            }

            @Override
            public void onAnimationRepeat(Animation animation) {
                eyelid_left.resetAnimator();
                eyelid_right.resetAnimator();
            }
        });
    }
    return mDialog;
}

From source file:MainActivity.java

private void calculateCompassDirection(SensorEvent event) {
    switch (event.sensor.getType()) {
    case Sensor.TYPE_ACCELEROMETER:
        mAccelerationValues = event.values.clone();
        break;//  w  w w.  j a v a 2s.c  o  m
    case Sensor.TYPE_MAGNETIC_FIELD:
        mGravityValues = event.values.clone();
        break;
    }
    boolean success = SensorManager.getRotationMatrix(mRotationMatrix, null, mAccelerationValues,
            mGravityValues);
    if (success) {
        float[] orientationValues = new float[3];
        SensorManager.getOrientation(mRotationMatrix, orientationValues);
        float azimuth = (float) Math.toDegrees(-orientationValues[0]);
        RotateAnimation rotateAnimation = new RotateAnimation(mLastDirectionInDegrees, azimuth,
                Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
        rotateAnimation.setDuration(50);
        rotateAnimation.setFillAfter(true);
        mImageViewCompass.startAnimation(rotateAnimation);
        mLastDirectionInDegrees = azimuth;
    }
}

From source file:org.videolan.myvlc.core.gui.about.AboutMainFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.about_main, container, false);
    TextView link = (TextView) v.findViewById(R.id.main_link);
    link.setText(Html.fromHtml(this.getString(R.string.about_link)));

    String builddate = Util.readAsset("builddate.txt", "Unknown");
    String builder = Util.readAsset("builder.txt", "unknown");
    String revision = Util.readAsset("revision.txt", "unknown");

    TextView compiled = (TextView) v.findViewById(R.id.main_compiled);
    compiled.setText(builder + " (" + builddate + ")");
    TextView textview_rev = (TextView) v.findViewById(R.id.main_revision);
    textview_rev.setText(getResources().getString(R.string.revision) + " " + revision + " (" + builddate + ")");

    final ImageView logo = (ImageView) v.findViewById(R.id.logo);
    logo.setOnClickListener(new OnClickListener() {
        @Override//from w  ww . ja va 2  s. co  m
        public void onClick(View v) {
            AnimationSet anim = new AnimationSet(true);
            RotateAnimation rotate = new RotateAnimation(0f, 360f, Animation.RELATIVE_TO_SELF, 0.5f,
                    Animation.RELATIVE_TO_SELF, 0.5f);
            rotate.setDuration(800);
            rotate.setInterpolator(new DecelerateInterpolator());
            anim.addAnimation(rotate);
            logo.startAnimation(anim);
        }
    });

    return v;
}

From source file:com.pwned.steamfriends.views.TwitterStream.java

@Override
public void onCreate(Bundle savedInstanceState) {
    setMyTheme();/*from w  ww.  ja  v  a2  s . c  o  m*/
    super.onCreate(savedInstanceState);
    tracker = GoogleAnalyticsTracker.getInstance();
    tracker.start(Constants.UACODE, 20, this);
    tracker.trackPageView("/TwitterStream");

    mManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    mManager.cancel(APP_ID);

    setContentView(R.layout.twitter);
    m_streams = new ArrayList<Stream>();
    this.m_adapter = new TwitterStreamAdapter(this, R.layout.row, m_streams);
    setListAdapter(this.m_adapter);

    viewStream = new Thread() {
        @Override
        public void run() {
            getStream();
        }
    };

    Animation a = new RotateAnimation(0.0f, 360.0f, Animation.RELATIVE_TO_SELF, 0.5f,
            Animation.RELATIVE_TO_SELF, 0.5f);
    a.setRepeatMode(Animation.RESTART);
    a.setRepeatCount(Animation.INFINITE);
    a.setDuration(750);

    a.setInterpolator(AnimationUtils.loadInterpolator(this, android.R.anim.linear_interpolator));
    ivLoad = (ImageView) findViewById(R.id.loading_spinner);
    ivLoad.startAnimation(a);

    Thread thread = new Thread(null, viewStream, "SpecialsBackground");
    thread.start();
    //m_ProgressDialog = ProgressDialog.show(TwitterStream.this,"","Loading Twitter Stream...", true);

    steamHeader = (ImageView) findViewById(R.id.headerimage);
    steamHeader.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            Intent myIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(Constants.HEADER_URL));
            startActivity(myIntent);
        }
    });
}

From source file:library.internal.IndicatorLayout.java

public IndicatorLayout(Context context, PullToRefreshBase.Mode mode) {
    super(context);
    mArrowImageView = new ImageView(context);

    Drawable arrowD = ContextCompat.getDrawable(context, R.drawable.indicator_arrow);
    mArrowImageView.setImageDrawable(arrowD);

    final int padding = getResources().getDimensionPixelSize(R.dimen.indicator_internal_padding);
    mArrowImageView.setPadding(padding, padding, padding, padding);
    addView(mArrowImageView);//from  www  .j a va 2s . com

    int inAnimResId, outAnimResId;
    switch (mode) {
    case PULL_FROM_END:
        inAnimResId = R.anim.slide_in_from_bottom;
        outAnimResId = R.anim.slide_out_to_bottom;
        setBackgroundResource(R.drawable.indicator_bg_bottom);

        // Rotate Arrow so it's pointing the correct way
        mArrowImageView.setScaleType(ScaleType.MATRIX);
        Matrix matrix = new Matrix();
        matrix.setRotate(180f, arrowD.getIntrinsicWidth() / 2f, arrowD.getIntrinsicHeight() / 2f);
        mArrowImageView.setImageMatrix(matrix);
        break;
    default:
    case PULL_FROM_START:
        inAnimResId = R.anim.slide_in_from_top;
        outAnimResId = R.anim.slide_out_to_top;
        setBackgroundResource(R.drawable.indicator_bg_top);
        break;
    }

    mInAnim = AnimationUtils.loadAnimation(context, inAnimResId);
    mInAnim.setAnimationListener(this);

    mOutAnim = AnimationUtils.loadAnimation(context, outAnimResId);
    mOutAnim.setAnimationListener(this);

    final Interpolator interpolator = new LinearInterpolator();
    mRotateAnimation = new RotateAnimation(0, -180, Animation.RELATIVE_TO_SELF, 0.5f,
            Animation.RELATIVE_TO_SELF, 0.5f);
    mRotateAnimation.setInterpolator(interpolator);
    mRotateAnimation.setDuration(DEFAULT_ROTATION_ANIMATION_DURATION);
    mRotateAnimation.setFillAfter(true);

    mResetRotateAnimation = new RotateAnimation(-180, 0, Animation.RELATIVE_TO_SELF, 0.5f,
            Animation.RELATIVE_TO_SELF, 0.5f);
    mResetRotateAnimation.setInterpolator(interpolator);
    mResetRotateAnimation.setDuration(DEFAULT_ROTATION_ANIMATION_DURATION);
    mResetRotateAnimation.setFillAfter(true);

}

From source file:cn.djangoogle.pull2load.internal.IndicatorLayout.java

public IndicatorLayout(Context context, Pull2LoadBase.Mode mode) {
    super(context);
    mArrowImageView = new ImageView(context);

    Drawable arrowD = ContextCompat.getDrawable(context, R.drawable.indicator_arrow);
    mArrowImageView.setImageDrawable(arrowD);

    final int padding = getResources().getDimensionPixelSize(R.dimen.indicator_internal_padding);
    mArrowImageView.setPadding(padding, padding, padding, padding);
    addView(mArrowImageView);/*w  w  w .  j  av  a2s  .c o  m*/

    int inAnimResId, outAnimResId;
    switch (mode) {
    case PULL_FROM_END:
        inAnimResId = R.anim.slide_in_from_bottom;
        outAnimResId = R.anim.slide_out_to_bottom;
        setBackgroundResource(R.drawable.indicator_bg_bottom);

        // Rotate Arrow so it's pointing the correct way
        mArrowImageView.setScaleType(ScaleType.MATRIX);
        Matrix matrix = new Matrix();
        matrix.setRotate(180f, arrowD.getIntrinsicWidth() / 2f, arrowD.getIntrinsicHeight() / 2f);
        mArrowImageView.setImageMatrix(matrix);
        break;
    default:
    case PULL_FROM_START:
        inAnimResId = R.anim.slide_in_from_top;
        outAnimResId = R.anim.slide_out_to_top;
        setBackgroundResource(R.drawable.indicator_bg_top);
        break;
    }

    mInAnim = AnimationUtils.loadAnimation(context, inAnimResId);
    mInAnim.setAnimationListener(this);

    mOutAnim = AnimationUtils.loadAnimation(context, outAnimResId);
    mOutAnim.setAnimationListener(this);

    final Interpolator interpolator = new LinearInterpolator();
    mRotateAnimation = new RotateAnimation(0, -180, Animation.RELATIVE_TO_SELF, 0.5f,
            Animation.RELATIVE_TO_SELF, 0.5f);
    mRotateAnimation.setInterpolator(interpolator);
    mRotateAnimation.setDuration(DEFAULT_ROTATION_ANIMATION_DURATION);
    mRotateAnimation.setFillAfter(true);

    mResetRotateAnimation = new RotateAnimation(-180, 0, Animation.RELATIVE_TO_SELF, 0.5f,
            Animation.RELATIVE_TO_SELF, 0.5f);
    mResetRotateAnimation.setInterpolator(interpolator);
    mResetRotateAnimation.setDuration(DEFAULT_ROTATION_ANIMATION_DURATION);
    mResetRotateAnimation.setFillAfter(true);

}