Search in sources :

Example 11 with AnimationListener

use of android.view.animation.Animation.AnimationListener in project Lazy by l123456789jy.

the class ViewAnimationUtils method translate.

/*
	 *  ************************************************************* 视图移动动画
	 * ********************************************************************
	 */
/**
     * 视图移动
     *
     * @param view           要移动的视图
     * @param fromXDelta     X轴开始坐标
     * @param toXDelta       X轴结束坐标
     * @param fromYDelta     Y轴开始坐标
     * @param toYDelta       Y轴结束坐标
     * @param cycles         重复
     * @param durationMillis 持续时间
     * @param isBanClick     在执行动画的过程中是否禁止点击
     */
public static void translate(final View view, float fromXDelta, float toXDelta, float fromYDelta, float toYDelta, float cycles, long durationMillis, final boolean isBanClick) {
    TranslateAnimation translateAnimation = new TranslateAnimation(fromXDelta, toXDelta, fromYDelta, toYDelta);
    translateAnimation.setDuration(durationMillis);
    if (cycles > 0.0) {
        translateAnimation.setInterpolator(new CycleInterpolator(cycles));
    }
    translateAnimation.setAnimationListener(new AnimationListener() {

        @Override
        public void onAnimationStart(Animation animation) {
            if (isBanClick) {
                view.setClickable(false);
            }
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            if (isBanClick) {
                view.setClickable(true);
            }
        }
    });
    view.startAnimation(translateAnimation);
}
Also used : TranslateAnimation(android.view.animation.TranslateAnimation) TranslateAnimation(android.view.animation.TranslateAnimation) AlphaAnimation(android.view.animation.AlphaAnimation) Animation(android.view.animation.Animation) CycleInterpolator(android.view.animation.CycleInterpolator) AnimationListener(android.view.animation.Animation.AnimationListener)

Example 12 with AnimationListener

use of android.view.animation.Animation.AnimationListener in project Lazy by l123456789jy.

the class ViewAnimationUtils method visibleViewByAlpha.

/**
     * 将给定视图渐渐显示出来(view.setVisibility(View.VISIBLE))
     *
     * @param view              被处理的视图
     * @param durationMillis    持续时间,毫秒
     * @param isBanClick        在执行动画的过程中是否禁止点击
     * @param animationListener 动画监听器
     */
public static void visibleViewByAlpha(final View view, long durationMillis, final boolean isBanClick, final AnimationListener animationListener) {
    if (view.getVisibility() != View.VISIBLE) {
        view.setVisibility(View.VISIBLE);
        AlphaAnimation showAlphaAnimation = AnimationUtils.getShowAlphaAnimation(durationMillis);
        showAlphaAnimation.setAnimationListener(new AnimationListener() {

            @Override
            public void onAnimationStart(Animation animation) {
                if (isBanClick) {
                    view.setClickable(false);
                }
                if (animationListener != null) {
                    animationListener.onAnimationStart(animation);
                }
            }

            @Override
            public void onAnimationRepeat(Animation animation) {
                if (animationListener != null) {
                    animationListener.onAnimationRepeat(animation);
                }
            }

            @Override
            public void onAnimationEnd(Animation animation) {
                if (isBanClick) {
                    view.setClickable(true);
                }
                if (animationListener != null) {
                    animationListener.onAnimationEnd(animation);
                }
            }
        });
        view.startAnimation(showAlphaAnimation);
    }
}
Also used : TranslateAnimation(android.view.animation.TranslateAnimation) AlphaAnimation(android.view.animation.AlphaAnimation) Animation(android.view.animation.Animation) AnimationListener(android.view.animation.Animation.AnimationListener) AlphaAnimation(android.view.animation.AlphaAnimation)

Example 13 with AnimationListener

use of android.view.animation.Animation.AnimationListener in project Lazy by l123456789jy.

the class ViewAnimationUtils method goneViewByAlpha.

/**
     * 将给定视图渐渐隐去最后从界面中移除(view.setVisibility(View.GONE))
     *
     * @param view              被处理的视图
     * @param durationMillis    持续时间,毫秒
     * @param isBanClick        在执行动画的过程中是否禁止点击
     * @param animationListener 动画监听器
     */
public static void goneViewByAlpha(final View view, long durationMillis, final boolean isBanClick, final AnimationListener animationListener) {
    if (view.getVisibility() != View.GONE) {
        view.setVisibility(View.GONE);
        AlphaAnimation hiddenAlphaAnimation = AnimationUtils.getHiddenAlphaAnimation(durationMillis);
        hiddenAlphaAnimation.setAnimationListener(new AnimationListener() {

            @Override
            public void onAnimationStart(Animation animation) {
                if (isBanClick) {
                    view.setClickable(false);
                }
                if (animationListener != null) {
                    animationListener.onAnimationStart(animation);
                }
            }

            @Override
            public void onAnimationRepeat(Animation animation) {
                if (animationListener != null) {
                    animationListener.onAnimationRepeat(animation);
                }
            }

            @Override
            public void onAnimationEnd(Animation animation) {
                if (isBanClick) {
                    view.setClickable(true);
                }
                if (animationListener != null) {
                    animationListener.onAnimationEnd(animation);
                }
            }
        });
        view.startAnimation(hiddenAlphaAnimation);
    }
}
Also used : TranslateAnimation(android.view.animation.TranslateAnimation) AlphaAnimation(android.view.animation.AlphaAnimation) Animation(android.view.animation.Animation) AnimationListener(android.view.animation.Animation.AnimationListener) AlphaAnimation(android.view.animation.AlphaAnimation)

Example 14 with AnimationListener

use of android.view.animation.Animation.AnimationListener in project MaterialDesignLibrary by navasmdc.

the class Dialog method dismiss.

@Override
public void dismiss() {
    Animation anim = AnimationUtils.loadAnimation(context, R.anim.dialog_main_hide_amination);
    anim.setAnimationListener(new AnimationListener() {

        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            view.post(new Runnable() {

                @Override
                public void run() {
                    Dialog.super.dismiss();
                }
            });
        }
    });
    Animation backAnim = AnimationUtils.loadAnimation(context, R.anim.dialog_root_hide_amin);
    view.startAnimation(anim);
    backView.startAnimation(backAnim);
}
Also used : Animation(android.view.animation.Animation) AnimationListener(android.view.animation.Animation.AnimationListener)

Example 15 with AnimationListener

use of android.view.animation.Animation.AnimationListener in project MaterialDesignLibrary by navasmdc.

the class SnackBar method dismiss.

/**
	 * @author Jack Tony
	 */
@Override
public void dismiss() {
    Animation anim = AnimationUtils.loadAnimation(activity, R.anim.snackbar_hide_animation);
    anim.setAnimationListener(new AnimationListener() {

        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            SnackBar.super.dismiss();
        }
    });
    view.startAnimation(anim);
}
Also used : Animation(android.view.animation.Animation) AnimationListener(android.view.animation.Animation.AnimationListener)

Aggregations

Animation (android.view.animation.Animation)80 AnimationListener (android.view.animation.Animation.AnimationListener)80 AlphaAnimation (android.view.animation.AlphaAnimation)25 TranslateAnimation (android.view.animation.TranslateAnimation)20 View (android.view.View)14 LinearInterpolator (android.view.animation.LinearInterpolator)12 RotateAnimation (android.view.animation.RotateAnimation)10 ScaleAnimation (android.view.animation.ScaleAnimation)10 ImageView (android.widget.ImageView)10 Rect (android.graphics.Rect)7 PopupWindow (android.widget.PopupWindow)6 Window (wei.mark.standout.ui.Window)6 ViewGroup (android.view.ViewGroup)5 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)5 SuppressLint (android.annotation.SuppressLint)4 Interpolator (android.view.animation.Interpolator)4 OvershootInterpolator (android.view.animation.OvershootInterpolator)4 TextView (android.widget.TextView)4 Notification (android.app.Notification)3 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)3