List of usage examples for android.view View clearAnimation
public void clearAnimation()
From source file:Main.java
public static void animShow(View v, int duration, float from, float to) { if (v.getVisibility() == View.GONE) { v.setVisibility(View.VISIBLE); }//from w ww .j av a 2 s. c o m v.clearAnimation(); ObjectAnimator.ofFloat(v, "alpha", from, to).setDuration(duration).start(); }
From source file:Main.java
public static void clearAnimation(View v) { if (null == v) { return;/*from ww w .j a v a 2 s . c o m*/ } if (null != v.getAnimation()) { v.getAnimation().cancel(); v.clearAnimation(); } }
From source file:Main.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1) public static ViewPropertyAnimator fadeIn(View to, int duration) { if (to.getVisibility() != View.VISIBLE) { to.setAlpha(0f);/*from ww w .j av a2s.c o m*/ to.setVisibility(View.VISIBLE); } to.clearAnimation(); final ViewPropertyAnimator animator = to.animate(); animator.alpha(1f).setDuration(duration).setListener(null); return animator; }
From source file:im.ene.ribbon.MiscUtils.java
protected static void switchColor(final BottomNavigationView navigation, final View v, final View backgroundOverlay, final ColorDrawable backgroundDrawable, final int newColor) { backgroundOverlay.clearAnimation(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Animator currentAnimator = (Animator) backgroundOverlay.getTag(R.id.ribbon_background_overlay_animator); if (null != currentAnimator) { currentAnimator.cancel();//from ww w . j av a2 s.co m } } backgroundDrawable.setColor(newColor); backgroundOverlay.setVisibility(View.INVISIBLE); ViewCompat.setAlpha(backgroundOverlay, 1); }
From source file:Main.java
public static void fadeIn(Context context, View view, boolean animate) { if (view == null || view.getVisibility() == View.VISIBLE) { return;// w w w . j a v a2 s.co m } if (animate) { view.startAnimation( android.view.animation.AnimationUtils.loadAnimation(context, android.R.anim.fade_in)); } else { view.clearAnimation(); } view.setVisibility(View.VISIBLE); }
From source file:Main.java
public static void fadeOut(Context context, View view, boolean animate) { if (view == null || view.getVisibility() != View.VISIBLE) { return;//from w ww . j a v a2 s .c o m } if (animate) { view.startAnimation( android.view.animation.AnimationUtils.loadAnimation(context, android.R.anim.fade_out)); } else { view.clearAnimation(); } view.setVisibility(View.GONE); }
From source file:org.smssecure.smssecure.util.ViewUtil.java
public static void animateIn(final @NonNull View view, final @NonNull Animation animation) { if (view.getVisibility() == View.VISIBLE) return;/*from www. j a v a 2 s . c o m*/ view.clearAnimation(); animation.reset(); animation.setStartTime(0); view.setVisibility(View.VISIBLE); view.startAnimation(animation); }
From source file:Main.java
/** * Cancel any previous animation./*from w w w. j a va 2 s.com*/ * @param view the view. */ public static void cancelAnimation(View view) { Animation animation = view.getAnimation(); if (animation != null) { animation.reset(); animation.cancel(); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { view.animate().cancel(); } view.clearAnimation(); }
From source file:im.ene.ribbon.AnimUtil.java
static void animate(BottomNavigationView parent, View view, final View backgroundOverlay, final ColorDrawable backgroundDrawable, final int newColor, long duration) { int centerX = (int) (ViewCompat.getX(view) + (view.getWidth() / 2)); int centerY = parent.getPaddingTop() + view.getHeight() / 2; backgroundOverlay.clearAnimation(); final Object animator; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Animator currentAnimator = (Animator) backgroundOverlay.getTag(R.id.ribbon_background_overlay_animator); if (currentAnimator != null) { //currentAnimator.end(); currentAnimator.cancel();/*from w ww .j a va 2s.c o m*/ } final float startRadius = 1; final float finalRadius = centerX > parent.getWidth() / 2 ? centerX : parent.getWidth() - centerX; animator = ViewAnimationUtils.createCircularReveal(backgroundOverlay, centerX, centerY, startRadius, finalRadius); backgroundOverlay.setTag(R.id.ribbon_background_overlay_animator, animator); } else { ViewCompat.setAlpha(backgroundOverlay, 0); animator = ViewCompat.animate(backgroundOverlay).alpha(1); } backgroundOverlay.setBackgroundColor(newColor); backgroundOverlay.setVisibility(View.VISIBLE); if (animator instanceof ViewPropertyAnimatorCompat) { ((ViewPropertyAnimatorCompat) animator).setListener(new ViewPropertyAnimatorListener() { boolean cancelled; @Override public void onAnimationStart(final View view) { } @Override public void onAnimationEnd(final View view) { if (!cancelled) { backgroundDrawable.setColor(newColor); backgroundOverlay.setVisibility(View.INVISIBLE); ViewCompat.setAlpha(backgroundOverlay, 1); } } @Override public void onAnimationCancel(final View view) { cancelled = true; } }).setDuration(duration).start(); } else { Animator animator1 = (Animator) animator; animator1.setDuration(duration); animator1.setInterpolator(new DecelerateInterpolator()); animator1.addListener(new Animator.AnimatorListener() { boolean cancelled; @Override public void onAnimationStart(final Animator animation) { } @Override public void onAnimationEnd(final Animator animation) { if (!cancelled) { backgroundDrawable.setColor(newColor); backgroundOverlay.setVisibility(View.INVISIBLE); ViewCompat.setAlpha(backgroundOverlay, 1); } } @Override public void onAnimationCancel(final Animator animation) { cancelled = true; } @Override public void onAnimationRepeat(final Animator animation) { } }); animator1.start(); } }
From source file:org.smssecure.smssecure.util.ViewUtil.java
public static ListenableFuture<Boolean> animateOut(final @NonNull View view, final @NonNull Animation animation, final int visibility) { final SettableFuture future = new SettableFuture(); if (view.getVisibility() == visibility) { future.set(true);//from w w w . ja v a 2 s . co m } else { view.clearAnimation(); animation.reset(); animation.setStartTime(0); animation.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { view.setVisibility(visibility); future.set(true); } }); view.startAnimation(animation); } return future; }