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);
}
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);
}
}
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);
}
}
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);
}
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);
}
Aggregations