List of usage examples for android.animation AnimatorSet start
@SuppressWarnings("unchecked") @Override public void start()
Starting this AnimatorSet
will, in turn, start the animations for which it is responsible.
From source file:Main.java
public static void animateScaleIn(View view, long duration, Animator.AnimatorListener listener) { view.setScaleX(0f);/*from w ww . j a v a2s . c o m*/ view.setScaleY(0f); view.setVisibility(View.VISIBLE); AnimatorSet scaleSet = new AnimatorSet(); scaleSet.playTogether(ObjectAnimator.ofFloat(view, View.SCALE_X, 1f), ObjectAnimator.ofFloat(view, View.SCALE_Y, 1f)); scaleSet.setInterpolator(new AccelerateDecelerateInterpolator()); scaleSet.setDuration(duration); if (listener != null) { scaleSet.addListener(listener); } scaleSet.start(); //return scaleSet; }
From source file:Main.java
public static void animFlicker(View view, long duration, int repeatCount) { AnimatorSet animatorSet = new AnimatorSet(); ObjectAnimator alphaIn = ObjectAnimator.ofFloat(view, "alpha", 0.0f, 1.0f); ObjectAnimator alphaOut = ObjectAnimator.ofFloat(view, "alpha", 1.0f, 0.0f); alphaIn.setDuration(duration);// w ww .j a v a 2s . co m alphaIn.setStartDelay(duration); alphaOut.setDuration(duration); alphaOut.setRepeatCount(repeatCount); alphaIn.setRepeatCount(repeatCount); animatorSet.playTogether(alphaOut, alphaIn); animatorSet.start(); }
From source file:com.microsoft.azure.engagement.ProductDiscountActivity.java
/** * Method that animates a view/*from w ww .java 2 s .co m*/ * * @param view The view to animate * @param objectAnimator The objectAnimator to play * @param isVisible The visibility of the view at the end of the animation */ public static final void performAnimation(final View view, ObjectAnimator objectAnimator, final boolean isVisible) { view.setVisibility(View.VISIBLE); objectAnimator.setDuration(300); final AnimatorSet animatorSet = new AnimatorSet(); animatorSet.play(objectAnimator); animatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); view.setVisibility(isVisible ? View.VISIBLE : View.INVISIBLE); } }); animatorSet.start(); }
From source file:com.chromium.fontinstaller.util.ViewUtils.java
public static void reveal(Activity activity, View view, View sourceView, int colorRes) { if (activity == null || view == null || sourceView == null) return;//from w w w . j av a 2 s. c o m if (isLollipop()) { final ViewGroupOverlay groupOverlay = (ViewGroupOverlay) activity.getWindow().getDecorView() .getOverlay(); final Rect displayRect = new Rect(); view.getGlobalVisibleRect(displayRect); // Make reveal cover the display and status bar. final View revealView = new View(activity); revealView.setTop(displayRect.top); revealView.setBottom(displayRect.bottom); revealView.setLeft(displayRect.left); revealView.setRight(displayRect.right); revealView.setBackgroundColor(ContextCompat.getColor(activity, colorRes)); groupOverlay.add(revealView); final int[] clearLocation = new int[2]; sourceView.getLocationInWindow(clearLocation); clearLocation[0] += sourceView.getWidth() / 2; clearLocation[1] += sourceView.getHeight() / 2; final int revealCenterX = clearLocation[0] - revealView.getLeft(); final int revealCenterY = clearLocation[1] - revealView.getTop(); final double x1_2 = Math.pow(revealView.getLeft() - revealCenterX, 2); final double x2_2 = Math.pow(revealView.getRight() - revealCenterX, 2); final double y_2 = Math.pow(revealView.getTop() - revealCenterY, 2); final float revealRadius = (float) Math.max(Math.sqrt(x1_2 + y_2), Math.sqrt(x2_2 + y_2)); try { final Animator revealAnimator = ViewAnimationUtils.createCircularReveal(revealView, revealCenterX, revealCenterY, 0.0f, revealRadius); revealAnimator .setDuration(activity.getResources().getInteger(android.R.integer.config_mediumAnimTime)); final Animator alphaAnimator = ObjectAnimator.ofFloat(revealView, View.ALPHA, 0.0f); alphaAnimator .setDuration(activity.getResources().getInteger(android.R.integer.config_shortAnimTime)); alphaAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); view.startAnimation(AnimationUtils.loadAnimation(activity, R.anim.abc_fade_in)); view.setVisibility(View.VISIBLE); } }); final AnimatorSet animatorSet = new AnimatorSet(); animatorSet.play(revealAnimator).before(alphaAnimator); animatorSet.setInterpolator(new AccelerateDecelerateInterpolator()); animatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animator) { groupOverlay.remove(revealView); } }); animatorSet.start(); } catch (IllegalStateException e) { Timber.i("View is detached - not animating"); } } else { view.setVisibility(View.VISIBLE); } }
From source file:Main.java
public static void runFlipHorizonAnimation(@NonNull View view, long duration, final Runnable rWhenEnd) { view.setAlpha(0);// ww w. jav a2s. c o m AnimatorSet set = new AnimatorSet(); ObjectAnimator objectAnimator1 = ObjectAnimator.ofFloat(view, "rotationY", -180f, 0f); ObjectAnimator objectAnimator2 = ObjectAnimator.ofFloat(view, "alpha", 0f, 1f); set.setDuration(duration); set.playTogether(objectAnimator1, objectAnimator2); if (rWhenEnd != null) set.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { rWhenEnd.run(); } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }); set.start(); }
From source file:Main.java
public static void scaleHide(final View view, final Runnable rWhenEnd) { if (view.getWindowToken() == null) { view.setVisibility(View.INVISIBLE); if (rWhenEnd != null) { rWhenEnd.run();// ww w. j a va 2 s .c o m } return; } ObjectAnimator scaleX = ObjectAnimator.ofFloat(view, "scaleX", 1f, 0f); ObjectAnimator scaleY = ObjectAnimator.ofFloat(view, "scaleY", 1f, 0f); AnimatorSet set = new AnimatorSet(); set.playTogether(scaleX, scaleY); set.setDuration(DURATION_SHORT); set.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { view.setVisibility(View.INVISIBLE); if (rWhenEnd != null) { rWhenEnd.run(); } } @Override public void onAnimationCancel(Animator animation) { view.setVisibility(View.INVISIBLE); if (rWhenEnd != null) { rWhenEnd.run(); } } @Override public void onAnimationRepeat(Animator animation) { } }); set.start(); }
From source file:Main.java
public static void scaleShow(final View view, final Runnable rWhenEnd) { if (view.getVisibility() == View.VISIBLE) { view.setVisibility(View.VISIBLE); if (rWhenEnd != null) { rWhenEnd.run();// ww w . java 2 s . c o m } return; } if (view.getWindowToken() == null) { view.addOnAttachStateChangeListener(new View.OnAttachStateChangeListener() { @Override public void onViewAttachedToWindow(View v) { scaleShow(view); } @Override public void onViewDetachedFromWindow(View v) { } }); } ObjectAnimator scaleX = ObjectAnimator.ofFloat(view, "scaleX", 0f, 1f); ObjectAnimator scaleY = ObjectAnimator.ofFloat(view, "scaleY", 0f, 1f); AnimatorSet set = new AnimatorSet(); set.playTogether(scaleX, scaleY); set.setDuration(DURATION_SHORT); set.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { view.setVisibility(View.VISIBLE); if (rWhenEnd != null) { rWhenEnd.run(); } } @Override public void onAnimationCancel(Animator animation) { view.setVisibility(View.VISIBLE); if (rWhenEnd != null) { rWhenEnd.run(); } } @Override public void onAnimationRepeat(Animator animation) { } }); set.start(); }
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 . ja v a 2s. 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
public static void animateHeart(View view) { AnimatorSet animatorSet = new AnimatorSet(); ObjectAnimator imgScaleUpYAnim = ObjectAnimator.ofFloat(view, "scaleY", 1.0f, 1.2f); imgScaleUpYAnim.setDuration(300);//w w w . j ava2 s .c o 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:io.jawg.osmcontributor.ui.adapters.OfflineRegionsAdapter.java
@Override public void onBindViewHolder(final OfflineRegionHolder holder, final int position) { OfflineRegionItem region = offlineRegions.get(position); String regionName = OfflineRegionManager.decodeRegionName(region.getOfflineRegion().getMetadata()); holder.offlineRegionTextView.setText(regionName); if (region.isSelected()) { Animator animX = ObjectAnimator.ofFloat(holder.cardView, View.SCALE_X, 1.15f); Animator animY = ObjectAnimator.ofFloat(holder.cardView, View.SCALE_Y, 1.15f); AnimatorSet animSet = new AnimatorSet(); animSet.playTogether(animX, animY); animSet.start(); } else {/*from w w w . java 2 s. c o m*/ Animator animX = ObjectAnimator.ofFloat(holder.cardView, View.SCALE_X, 1.0f); Animator animY = ObjectAnimator.ofFloat(holder.cardView, View.SCALE_Y, 1.0f); AnimatorSet animSet = new AnimatorSet(); animSet.playTogether(animX, animY); animSet.start(); } if (region.getStatus().isComplete()) { holder.cardView.setBackgroundColor(ContextCompat.getColor(context, R.color.colorPrimaryDark)); holder.offlineRegionTextView.setTextColor(Color.WHITE); } else { holder.cardView.setBackgroundColor(ContextCompat.getColor(context, R.color.active_text)); holder.offlineRegionTextView.setTextColor(ContextCompat.getColor(context, R.color.disable_text)); } }