List of usage examples for android.animation AnimatorListenerAdapter AnimatorListenerAdapter
AnimatorListenerAdapter
From source file:Main.java
public static void crossFade(final View toBeGone, View toBeVisible, int shortAnimationDuration) { if (Build.VERSION.SDK_INT >= 12) { toBeVisible.setAlpha(0f);/*from www .ja va 2 s. c o m*/ toBeVisible.setVisibility(View.VISIBLE); toBeVisible.animate().alpha(1f).setDuration(shortAnimationDuration).setListener(null); toBeGone.animate().alpha(0f).setDuration(shortAnimationDuration) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { toBeGone.setVisibility(View.GONE); } }); } else { switchOutIn(toBeGone, toBeVisible); } }
From source file:Main.java
public static void circleReveal(final View targetView, int centerX, int centerY, boolean isReverse) { if (targetView == null || !targetView.isAttachedToWindow()) return;//from w w w . j ava2 s .c o m int radius = (int) Math.hypot(targetView.getHeight(), targetView.getWidth()); Animator animator; if (isReverse) { animator = isCircleRevealSupported() ? ViewAnimationUtils.createCircularReveal(targetView, centerX, centerY, radius, 0) : createFade(targetView, 1, 0); animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { targetView.setVisibility(View.GONE); } }); } else { animator = isCircleRevealSupported() ? ViewAnimationUtils.createCircularReveal(targetView, centerX, centerY, 0, radius) : createFade(targetView, 0, 1); animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { targetView.setVisibility(View.VISIBLE); } }); } animator.setDuration(DURATION); animator.start(); }
From source file:Main.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) private static void fadeOutHoneyComb(final View view) { view.setAlpha(1.0F);/*from w w w . j a va 2s. c o m*/ ObjectAnimator animator = ObjectAnimator.ofFloat(view, "alpha", 1.0F, 0.0F).setDuration(ANIMATION_DURATION); animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(android.animation.Animator animation) { view.setVisibility(View.GONE); view.setAlpha(1.0F); } }); animator.start(); }
From source file:Main.java
public static void animateHeart(View view) { AnimatorSet animatorSet = new AnimatorSet(); ObjectAnimator imgScaleUpYAnim = ObjectAnimator.ofFloat(view, "scaleY", 1.0f, 1.2f); imgScaleUpYAnim.setDuration(300);/*from w w w. j a va2 s. co m*/ ObjectAnimator imgScaleUpXAnim = ObjectAnimator.ofFloat(view, "scaleX", 1.0f, 1.2f); imgScaleUpXAnim.setDuration(300); ObjectAnimator imgScaleDownYAnim = ObjectAnimator.ofFloat(view, "scaleY", 1.2f, 1.0f); imgScaleDownYAnim.setDuration(300); imgScaleDownYAnim.setInterpolator(ACCELERATE_INTERPOLATOR); ObjectAnimator imgScaleDownXAnim = ObjectAnimator.ofFloat(view, "scaleX", 1.2f, 1.0f); imgScaleDownXAnim.setDuration(300); animatorSet.playTogether(imgScaleUpXAnim, imgScaleUpYAnim); animatorSet.play(imgScaleDownYAnim).with(imgScaleDownXAnim).after(imgScaleUpXAnim); animatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { view.clearAnimation(); animatorSet.start(); } }); animatorSet.start(); }
From source file:Main.java
/** * Scales out the view from actual dimensions to 0. * @param view The view to scale./*w w w . j a v a 2 s . co m*/ * @param durationMs The duration of the scaling in milliseconds. */ public static void scaleOut(final View view, int durationMs) { AnimatorListenerAdapter listener = new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { view.setVisibility(View.GONE); } @Override public void onAnimationCancel(Animator animation) { view.setVisibility(View.GONE); view.setScaleX(0); view.setScaleY(0); } }; scaleInternal(view, 1 /* startScaleValue */, 0 /* endScaleValue */, durationMs, NO_DELAY, listener, EASE_OUT); }
From source file:Main.java
/** * Scales out the view from actual dimensions to 0. * @param view The view to scale./*ww w . ja va 2 s . co m*/ * @param durationMs The duration of the scaling in milliseconds. */ public static void scaleOut(final View view, int durationMs) { AnimatorListenerAdapter listener = new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { view.setVisibility(View.INVISIBLE); } @Override public void onAnimationCancel(Animator animation) { view.setVisibility(View.INVISIBLE); view.setScaleX(0); view.setScaleY(0); } }; scaleInternal(view, 1 /* startScaleValue */, 0 /* endScaleValue */, durationMs, NO_DELAY, listener, EASE_OUT); }
From source file:Main.java
public static void animateHeartButton(final View v) { AnimatorSet animatorSet = new AnimatorSet(); ObjectAnimator rotationAnim = ObjectAnimator.ofFloat(v, "rotation", 0f, 360f); rotationAnim.setDuration(300);/*from w w w. j a va2s.c o m*/ rotationAnim.setInterpolator(ACCELERATE_INTERPOLATOR); ObjectAnimator bounceAnimX = ObjectAnimator.ofFloat(v, "scaleX", 0.2f, 1f); bounceAnimX.setDuration(300); bounceAnimX.setInterpolator(OVERSHOOT_INTERPOLATOR); ObjectAnimator bounceAnimY = ObjectAnimator.ofFloat(v, "scaleY", 0.2f, 1f); bounceAnimY.setDuration(300); bounceAnimY.setInterpolator(OVERSHOOT_INTERPOLATOR); bounceAnimY.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { } }); animatorSet.play(bounceAnimX).with(bounceAnimY).after(rotationAnim); animatorSet.start(); }
From source file:Main.java
/** * Scales in the view from scale of 0 to actual dimensions. * @param view The view to scale./* w w w . j a v a2 s. c o m*/ * @param durationMs The duration of the scaling in milliseconds. * @param startDelayMs The delay to applying the scaling in milliseconds. */ public static void scaleIn(final View view, int durationMs, int startDelayMs) { AnimatorListenerAdapter listener = (new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { view.setVisibility(View.VISIBLE); } @Override public void onAnimationCancel(Animator animation) { view.setScaleX(1); view.setScaleY(1); } }); scaleInternal(view, 0 /* startScaleValue */, 1 /* endScaleValue */, durationMs, startDelayMs, listener, EASE_IN); }
From source file:Main.java
public static void startActivity(final Activity thisActivity, final Intent intent, final View triggerView, int colorOrImageRes, final long durationMills) { int[] location = new int[2]; triggerView.getLocationInWindow(location); final int cx = location[0] + triggerView.getWidth(); final int cy = location[1] + triggerView.getHeight() + (int) TypedValue .applyDimension(TypedValue.COMPLEX_UNIT_DIP, 160, thisActivity.getResources().getDisplayMetrics()); final ImageView view = new ImageView(thisActivity); view.setScaleType(ImageView.ScaleType.CENTER_CROP); view.setImageResource(colorOrImageRes); final ViewGroup decorView = (ViewGroup) thisActivity.getWindow().getDecorView(); int w = decorView.getWidth(); int h = decorView.getHeight(); decorView.addView(view, w, h);/*w w w . ja v a2s . co m*/ final int finalRadius = (int) Math.sqrt(w * w + h * h) + 1; Animator anim = ViewAnimationUtils.createCircularReveal(view, cx, cy, 0, finalRadius); anim.setDuration(durationMills); anim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); thisActivity.startActivity(intent); thisActivity.overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out); } }); anim.start(); }
From source file:Main.java
public static void showViewAlphaAnim(final View view, TimeInterpolator interpolator, final boolean visible) { if (visible && view.getVisibility() == View.VISIBLE || !visible && view.getVisibility() != View.VISIBLE) { return;//w ww. j a v a2s . c o m } float fromAlpha = visible ? 0.0F : 1.0F; float toAlpha = visible ? 1.0F : 0.0F; view.setAlpha(fromAlpha); view.setVisibility(View.VISIBLE); view.animate().alpha(toAlpha).setDuration(DURATION).setInterpolator(interpolator) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animator) { if (visible) { view.setAlpha(1.0F); view.setVisibility(View.VISIBLE); } else { view.setAlpha(0.0F); view.setVisibility(View.INVISIBLE); } } }).start(); }