List of usage examples for android.animation Animator setDuration
public abstract Animator setDuration(long duration);
From source file:Main.java
public static void hideRevealEffect(final View v, int centerX, int centerY, int initialRadius) { v.setVisibility(View.VISIBLE); // create the animation (the final radius is zero) Animator anim = ViewAnimationUtils.createCircularReveal(v, centerX, centerY, initialRadius, 0); anim.setDuration(350); // make the view invisible when the animation is done anim.addListener(new AnimatorListenerAdapter() { @Override/*from w w w.ja v a2s .com*/ public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); v.setVisibility(View.INVISIBLE); } }); anim.start(); }
From source file:com.flexible.flexibleadapter.helpers.AnimatorHelper.java
/** * Adds a custom duration to the current view. * * @param animators user defined list of animators * @param duration duration in milliseconds *///from www.j a v a 2 s .co m public static void setDuration(@NonNull List<Animator> animators, @IntRange(from = 0) long duration) { if (animators.size() > 0) { Animator animator = animators.get(animators.size() - 1); animator.setDuration(duration); } }
From source file:Main.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP) public static void show(final View view, final int cornerType, int normalAnimRes, final AnimatorListenerAdapter listener) { try {//from ww w . ja v a 2s. c o m int[] amaya = calulateCorner(view, cornerType); Animator anim = ViewAnimationUtils.createCircularReveal(view, amaya[0], amaya[1], 0, amaya[2]); anim.setInterpolator(new LinearInterpolator()); anim.setDuration(300); anim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { super.onAnimationStart(animation); view.setVisibility(View.VISIBLE); if (listener != null) { listener.onAnimationStart(animation); } } }); anim.start(); } catch (Exception e) { e.printStackTrace(); view.setVisibility(View.VISIBLE); } }
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();// w w w.j a v a 2s .c o m 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(); } 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:Main.java
public static void revealColorFromCoordinates(int x, int y, View viewRoot) { float finalRadius = (float) Math.hypot(viewRoot.getWidth(), viewRoot.getHeight()); Animator anim = null; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { anim = ViewAnimationUtils.createCircularReveal(viewRoot, x, y, 0, finalRadius); }//from w ww. j a v a 2 s . co m //viewRoot.setBackgroundColor(ContextCompat.getColor(viewRoot.getContext(), R.color.colorPrimary)); anim.setDuration(1000); anim.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 ava 2 s.c om 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
@TargetApi(Build.VERSION_CODES.LOLLIPOP) private static void hide(final View view, int cornerType, int animRes, final boolean goneOrInvisible, final AnimatorListenerAdapter listener) { int[] amaya = calulateCorner(view, cornerType); // if(view) Animator anim = ViewAnimationUtils.createCircularReveal(view, amaya[0], amaya[1], amaya[2], 0); anim.addListener(new AnimatorListenerAdapter() { @Override//from ww w . j a va 2 s. c o m public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); view.setVisibility(goneOrInvisible ? View.GONE : View.INVISIBLE); if (listener != null) listener.onAnimationEnd(animation); } }); anim.setDuration(300); anim.start(); }
From source file:com.syncedsynapse.kore2.utils.UIUtils.java
/** * Launches the remote activity, performing a circular reveal animation if * Lollipop or later//from w w w . j a va 2 s .co m * * @param context Context * @param centerX Center X of the animation * @param centerY Center Y of the animation * @param exitTransitionView View to reveal. Should occupy the whole screen and * be invisible before calling this */ @TargetApi(21) public static void switchToRemoteWithAnimation(final Context context, int centerX, int centerY, final View exitTransitionView) { final Intent launchIntent = new Intent(context, RemoteActivity.class); if (Utils.isLollipopOrLater()) { // Show the animation int endRadius = Math.max(exitTransitionView.getHeight(), exitTransitionView.getWidth()); Animator exitAnim = ViewAnimationUtils.createCircularReveal(exitTransitionView, centerX, centerY, 0, endRadius); exitAnim.setDuration(200); exitAnim.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { // Launch remote activity context.startActivity(launchIntent); } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }); exitTransitionView.setVisibility(View.VISIBLE); exitAnim.start(); } else { // No animation show, just launch the remote context.startActivity(launchIntent); } }
From source file:io.digibyte.tools.animation.BRAnimator.java
public static LayoutTransition getDefaultTransition() { LayoutTransition itemLayoutTransition = new LayoutTransition(); itemLayoutTransition.setStartDelay(LayoutTransition.APPEARING, 0); itemLayoutTransition.setStartDelay(LayoutTransition.DISAPPEARING, 0); itemLayoutTransition.setStartDelay(LayoutTransition.CHANGE_APPEARING, 0); itemLayoutTransition.setStartDelay(LayoutTransition.CHANGE_DISAPPEARING, 0); itemLayoutTransition.setStartDelay(LayoutTransition.CHANGING, 0); itemLayoutTransition.setDuration(100); itemLayoutTransition.setInterpolator(LayoutTransition.CHANGING, new OvershootInterpolator(2f)); Animator scaleUp = ObjectAnimator.ofPropertyValuesHolder((Object) null, PropertyValuesHolder.ofFloat(View.SCALE_X, 1, 1), PropertyValuesHolder.ofFloat(View.SCALE_Y, 0, 1)); scaleUp.setDuration(50); scaleUp.setStartDelay(50);//from w w w.ja v a2 s.com Animator scaleDown = ObjectAnimator.ofPropertyValuesHolder((Object) null, PropertyValuesHolder.ofFloat(View.SCALE_X, 1, 1), PropertyValuesHolder.ofFloat(View.SCALE_Y, 1, 0)); scaleDown.setDuration(2); itemLayoutTransition.setAnimator(LayoutTransition.APPEARING, scaleUp); itemLayoutTransition.setAnimator(LayoutTransition.DISAPPEARING, null); itemLayoutTransition.enableTransitionType(LayoutTransition.CHANGING); return itemLayoutTransition; }
From source file:Main.java
public static void circleReveal(final View targetView, int centerX, int centerY, boolean isReverse) { if (targetView == null || !targetView.isAttachedToWindow()) return;// ww w . j a v a 2s. c om 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(); }