Search in sources :

Example 21 with RotateAnimation

use of android.view.animation.RotateAnimation in project xRecyclerViewF by Dsiner.

the class ArrowRefreshHeader method initAnim.

private void initAnim() {
    mRotateUpAnim = new RotateAnimation(0.0f, -180.0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    mRotateUpAnim.setDuration(ROTATE_ANIM_DURATION);
    mRotateUpAnim.setFillAfter(true);
    mRotateDownAnim = new RotateAnimation(-180.0f, 0.0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    mRotateDownAnim.setDuration(ROTATE_ANIM_DURATION);
    mRotateDownAnim.setFillAfter(true);
}
Also used : RotateAnimation(android.view.animation.RotateAnimation)

Example 22 with RotateAnimation

use of android.view.animation.RotateAnimation in project android_packages_apps_Updater by LineageOS.

the class UpdatesActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_updates);
    RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
    mAdapter = new UpdatesListAdapter(this);
    recyclerView.setAdapter(mAdapter);
    RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(this);
    recyclerView.setLayoutManager(layoutManager);
    RecyclerView.ItemAnimator animator = recyclerView.getItemAnimator();
    if (animator instanceof SimpleItemAnimator) {
        ((SimpleItemAnimator) animator).setSupportsChangeAnimations(false);
    }
    mBroadcastReceiver = new BroadcastReceiver() {

        @Override
        public void onReceive(Context context, Intent intent) {
            if (UpdaterController.ACTION_UPDATE_STATUS.equals(intent.getAction())) {
                String downloadId = intent.getStringExtra(UpdaterController.EXTRA_DOWNLOAD_ID);
                handleDownloadStatusChange(downloadId);
                mAdapter.notifyDataSetChanged();
            } else if (UpdaterController.ACTION_DOWNLOAD_PROGRESS.equals(intent.getAction()) || UpdaterController.ACTION_INSTALL_PROGRESS.equals(intent.getAction())) {
                String downloadId = intent.getStringExtra(UpdaterController.EXTRA_DOWNLOAD_ID);
                mAdapter.notifyItemChanged(downloadId);
            } else if (UpdaterController.ACTION_UPDATE_REMOVED.equals(intent.getAction())) {
                String downloadId = intent.getStringExtra(UpdaterController.EXTRA_DOWNLOAD_ID);
                mAdapter.removeItem(downloadId);
            }
        }
    };
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayShowTitleEnabled(false);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    TextView headerTitle = (TextView) findViewById(R.id.header_title);
    headerTitle.setText(getString(R.string.header_title_text, BuildInfoUtils.getBuildVersion()));
    updateLastCheckedString();
    TextView headerBuildVersion = (TextView) findViewById(R.id.header_build_version);
    headerBuildVersion.setText(getString(R.string.header_android_version, Build.VERSION.RELEASE));
    TextView headerBuildDate = (TextView) findViewById(R.id.header_build_date);
    headerBuildDate.setText(StringGenerator.getDateLocalizedUTC(this, DateFormat.LONG, BuildInfoUtils.getBuildDateTimestamp()));
    // Switch between header title and appbar title minimizing overlaps
    final CollapsingToolbarLayout collapsingToolbar = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
    final AppBarLayout appBar = (AppBarLayout) findViewById(R.id.app_bar);
    appBar.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {

        boolean mIsShown = false;

        @Override
        public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
            int scrollRange = appBarLayout.getTotalScrollRange();
            if (!mIsShown && scrollRange + verticalOffset < 10) {
                collapsingToolbar.setTitle(getString(R.string.display_name));
                mIsShown = true;
            } else if (mIsShown && scrollRange + verticalOffset > 100) {
                collapsingToolbar.setTitle(null);
                mIsShown = false;
            }
        }
    });
    if (!Utils.hasTouchscreen(this)) {
        // This can't be collapsed without a touchscreen
        appBar.setExpanded(false);
    }
    mRefreshAnimation = new RotateAnimation(0, 360, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    mRefreshAnimation.setInterpolator(new LinearInterpolator());
    mRefreshAnimation.setDuration(1000);
}
Also used : Context(android.content.Context) SimpleItemAnimator(android.support.v7.widget.SimpleItemAnimator) Intent(android.content.Intent) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) BroadcastReceiver(android.content.BroadcastReceiver) RotateAnimation(android.view.animation.RotateAnimation) LinearInterpolator(android.view.animation.LinearInterpolator) CollapsingToolbarLayout(android.support.design.widget.CollapsingToolbarLayout) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) AppBarLayout(android.support.design.widget.AppBarLayout) Toolbar(android.support.v7.widget.Toolbar)

Example 23 with RotateAnimation

use of android.view.animation.RotateAnimation in project Osmand by osmandapp.

the class BusyIndicator method updateStatus.

/**
 * @param status - 0 invisible
 * 1
 */
public void updateStatus(int status) {
    if (this.status != status) {
        this.status = status;
        final Drawable drawable;
        if (this.status == STATUS_BLACK) {
            drawable = ctx.getResources().getDrawable(R.drawable.progress_grey);
        } else if (this.status == STATUS_ORANGE) {
            drawable = ctx.getResources().getDrawable(R.drawable.progress_orange);
        } else if (this.status == STATUS_GREEN) {
            drawable = ctx.getResources().getDrawable(R.drawable.progress_green);
        } else {
            drawable = null;
        }
        final RotateAnimation animation;
        if (drawable != null) {
            animation = new RotateAnimation(0, 360, RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f);
            animation.setRepeatCount(Animation.INFINITE);
            final int cycles = 12;
            animation.setInterpolator(new Interpolator() {

                @Override
                public float getInterpolation(float input) {
                    return ((int) (input * cycles)) / (float) cycles;
                }
            });
            animation.setDuration(1200);
            animation.setStartTime(RotateAnimation.START_ON_FIRST_FRAME);
            animation.setStartOffset(0);
        } else {
            animation = null;
        }
        uiHandler.post(new Runnable() {

            @Override
            public void run() {
                bar.setVisibility(drawable != null ? View.VISIBLE : View.INVISIBLE);
                if (bar.getAnimation() != null) {
                    bar.clearAnimation();
                }
                if (drawable != null) {
                    bar.setBackgroundDrawable(drawable);
                    bar.startAnimation(animation);
                }
            }
        });
    }
}
Also used : RotateAnimation(android.view.animation.RotateAnimation) Drawable(android.graphics.drawable.Drawable) Interpolator(android.view.animation.Interpolator)

Example 24 with RotateAnimation

use of android.view.animation.RotateAnimation in project KL2 by jweihao.

the class ViewAnimationActivity method onViewClicked.

@OnClick({ R.id.button_alpha, R.id.button_rotate, R.id.button_translate, R.id.button_scale, R.id.button_set })
public void onViewClicked(View view) {
    switch(view.getId()) {
        // 透明
        case R.id.button_alpha:
            AlphaAnimation aa = new AlphaAnimation(0, 1);
            aa.setDuration(2000);
            mImageview.startAnimation(aa);
            break;
        // 旋转
        case R.id.button_rotate:
            // 参数为,旋转的起始角度,旋转中心点的坐标。(这里设置的是旋转参考系为自身中心点)
            RotateAnimation ra = new RotateAnimation(0, 360, RotateAnimation.RELATIVE_TO_SELF, 0.5F, RotateAnimation.RELATIVE_TO_SELF, 0.5F);
            ra.setDuration(2000);
            mImageview.startAnimation(ra);
            break;
        // 位移
        case R.id.button_translate:
            TranslateAnimation ta = new TranslateAnimation(0, 100, 0, 800);
            ta.setDuration(3000);
            // 使用位移来实现监听事件功能
            ta.setAnimationListener(new Animation.AnimationListener() {

                @Override
                public void onAnimationStart(Animation animation) {
                    Toast.makeText(ViewAnimationActivity.this, "开始 TranslateAnimation", Toast.LENGTH_SHORT).show();
                }

                @Override
                public void onAnimationEnd(Animation animation) {
                    Toast.makeText(ViewAnimationActivity.this, "结束 TranslateAnimation", Toast.LENGTH_SHORT).show();
                }

                // 通知动画的重复
                @Override
                public void onAnimationRepeat(Animation animation) {
                }
            });
            mImageview.startAnimation(ta);
            break;
        // 缩放
        case R.id.button_scale:
            // (设置参数缩放的中心点为自身中心点,从0放大到2倍)
            ScaleAnimation sa = new ScaleAnimation(0, 2, 0, 2, Animation.RELATIVE_TO_SELF, 0.5F, Animation.RELATIVE_TO_SELF, 0.5F);
            sa.setDuration(3000);
            mImageview.startAnimation(sa);
            break;
        // 动画集合,通过AnimationSet,可以将动画以组合的形式展现出来。
        case R.id.button_set:
            // 动画集合
            AnimationSet as = new AnimationSet(true);
            as.setDuration(3000);
            // 透明
            AlphaAnimation alpha = new AlphaAnimation(0, 1);
            alpha.setDuration(3000);
            as.addAnimation(alpha);
            // 位移
            TranslateAnimation translate = new TranslateAnimation(0, 100, 0, 800);
            translate.setDuration(3000);
            as.addAnimation(translate);
            mImageview.startAnimation(as);
            break;
        default:
            break;
    }
}
Also used : RotateAnimation(android.view.animation.RotateAnimation) TranslateAnimation(android.view.animation.TranslateAnimation) ScaleAnimation(android.view.animation.ScaleAnimation) RotateAnimation(android.view.animation.RotateAnimation) TranslateAnimation(android.view.animation.TranslateAnimation) AlphaAnimation(android.view.animation.AlphaAnimation) Animation(android.view.animation.Animation) AnimationSet(android.view.animation.AnimationSet) AlphaAnimation(android.view.animation.AlphaAnimation) ScaleAnimation(android.view.animation.ScaleAnimation) OnClick(butterknife.OnClick)

Example 25 with RotateAnimation

use of android.view.animation.RotateAnimation in project ArcMenu by daCapricorn.

the class ArcMenu method createHintSwitchAnimation.

private static Animation createHintSwitchAnimation(final boolean expanded) {
    Animation animation = new RotateAnimation(expanded ? 45 : 0, expanded ? 0 : 45, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    animation.setStartOffset(0);
    animation.setDuration(100);
    animation.setInterpolator(new DecelerateInterpolator());
    animation.setFillAfter(true);
    return animation;
}
Also used : DecelerateInterpolator(android.view.animation.DecelerateInterpolator) RotateAnimation(android.view.animation.RotateAnimation) ScaleAnimation(android.view.animation.ScaleAnimation) RotateAnimation(android.view.animation.RotateAnimation) AlphaAnimation(android.view.animation.AlphaAnimation) Animation(android.view.animation.Animation)

Aggregations

RotateAnimation (android.view.animation.RotateAnimation)111 LinearInterpolator (android.view.animation.LinearInterpolator)38 Animation (android.view.animation.Animation)27 AnimationSet (android.view.animation.AnimationSet)24 ScaleAnimation (android.view.animation.ScaleAnimation)17 ImageView (android.widget.ImageView)15 View (android.view.View)14 TextView (android.widget.TextView)14 AlphaAnimation (android.view.animation.AlphaAnimation)13 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)12 TranslateAnimation (android.view.animation.TranslateAnimation)9 Context (android.content.Context)5 LinearLayout (android.widget.LinearLayout)5 Intent (android.content.Intent)4 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)4 IOException (java.io.IOException)4 Paint (android.graphics.Paint)3 Drawable (android.graphics.drawable.Drawable)3 RecyclerView (android.support.v7.widget.RecyclerView)3 AttributeSet (android.util.AttributeSet)3