List of usage examples for android.view.animation DecelerateInterpolator DecelerateInterpolator
public DecelerateInterpolator()
From source file:com.capricorn.ArcMenu.java
private static Animation createQuickHintSwitchAnimation(final boolean expanded) { Animation animation = new RotateAnimation(expanded ? 45 : 0, expanded ? 0 : 45, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); animation.setStartOffset(0);//w w w .j a va2 s . c o m animation.setDuration(10); animation.setInterpolator(new DecelerateInterpolator()); animation.setFillAfter(true); return animation; }
From source file:com.tmall.wireless.tangram.ext.SwipeItemTouchListener.java
private void resetViews(RecyclerView recyclerView, final int swipingType, final boolean reachActionEdge, final int direction) { int contentWidth = recyclerView.getWidth(); AnimatorSet animatorSet = new AnimatorSet(); List<Animator> list = new ArrayList<>(); String translation = "translationX"; if (swipingType == SWIPING_VER) { translation = "translationY"; }//from w w w .j av a2 s .c o m for (View view : mChildList) { ObjectAnimator animator; if (reachActionEdge) { animator = ObjectAnimator.ofFloat(view, translation, contentWidth * direction) .setDuration(ANIMATE_DURATION); animator.setInterpolator(new AccelerateInterpolator()); } else { animator = ObjectAnimator.ofFloat(view, translation, 0).setDuration(ANIMATE_DURATION); animator.setInterpolator(new DecelerateInterpolator()); } list.add(animator); } animatorSet.playTogether(list); animatorSet.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { if (swipingType == SWIPING_HOR && reachActionEdge) { if (mSwipeCardRef != null && mSwipeCardRef.get() != null) { SwipeCard swipeCard = mSwipeCardRef.get(); swipeCard.switchTo(swipeCard.getCurrentIndex() - direction); } } mChildList.clear(); } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }); animatorSet.start(); if (swipingType == SWIPING_VER) { if (pullFromEndListener != null) { if (mDistanceY < 0 && (mDistanceY < -pullFromEndListener.getPullEdge())) { pullFromEndListener.onAction(); } else { pullFromEndListener.onReset(); } } } swipeType = SWIPING_NONE; }
From source file:com.fugueweb.pub.animation.ZoomActivity.java
/** * "Zooms" in a thumbnail view by assigning the high resolution image to a hidden "zoomed-in" * image view and animating its bounds to fit the entire activity content area. More * specifically:/*from w ww. ja v a 2 s. c om*/ * * <ol> * <li>Assign the high-res image to the hidden "zoomed-in" (expanded) image view.</li> * <li>Calculate the starting and ending bounds for the expanded view.</li> * <li>Animate each of four positioning/sizing properties (X, Y, SCALE_X, SCALE_Y) * simultaneously, from the starting bounds to the ending bounds.</li> * <li>Zoom back out by running the reverse animation on click.</li> * </ol> * * @param thumbView The thumbnail view to zoom in. * @param imageResId The high-resolution version of the image represented by the thumbnail. */ private void zoomImageFromThumb(final View thumbView, int imageResId) { // If there's an animation in progress, cancel it immediately and proceed with this one. if (mCurrentAnimator != null) { mCurrentAnimator.cancel(); } // Load the high-resolution "zoomed-in" image. final ImageView expandedImageView = (ImageView) findViewById(R.id.expanded_image); expandedImageView.setImageResource(imageResId); // Calculate the starting and ending bounds for the zoomed-in image. This step // involves lots of math. Math. final Rect startBounds = new Rect(); final Rect finalBounds = new Rect(); final Point globalOffset = new Point(); // The start bounds are the global visible rectangle of the thumbnail, and the // final bounds are the global visible rectangle of the container view. Also // set the container view's offset as the origin for the bounds, since that's // the origin for the positioning animation properties (X, Y). thumbView.getGlobalVisibleRect(startBounds); findViewById(R.id.container).getGlobalVisibleRect(finalBounds, globalOffset); startBounds.offset(-globalOffset.x, -globalOffset.y); finalBounds.offset(-globalOffset.x, -globalOffset.y); // Adjust the start bounds to be the same aspect ratio as the final bounds using the // "center crop" technique. This prevents undesirable stretching during the animation. // Also calculate the start scaling factor (the end scaling factor is always 1.0). float startScale; if ((float) finalBounds.width() / finalBounds.height() > (float) startBounds.width() / startBounds.height()) { // Extend start bounds horizontally startScale = (float) startBounds.height() / finalBounds.height(); float startWidth = startScale * finalBounds.width(); float deltaWidth = (startWidth - startBounds.width()) / 2; startBounds.left -= deltaWidth; startBounds.right += deltaWidth; } else { // Extend start bounds vertically startScale = (float) startBounds.width() / finalBounds.width(); float startHeight = startScale * finalBounds.height(); float deltaHeight = (startHeight - startBounds.height()) / 2; startBounds.top -= deltaHeight; startBounds.bottom += deltaHeight; } // Hide the thumbnail and show the zoomed-in view. When the animation begins, // it will position the zoomed-in view in the place of the thumbnail. thumbView.setAlpha(0f); expandedImageView.setVisibility(View.VISIBLE); // Set the pivot point for SCALE_X and SCALE_Y transformations to the top-left corner of // the zoomed-in view (the default is the center of the view). expandedImageView.setPivotX(0f); expandedImageView.setPivotY(0f); // Construct and run the parallel animation of the four translation and scale properties // (X, Y, SCALE_X, and SCALE_Y). AnimatorSet set = new AnimatorSet(); set.play(ObjectAnimator.ofFloat(expandedImageView, View.X, startBounds.left, finalBounds.left)) .with(ObjectAnimator.ofFloat(expandedImageView, View.Y, startBounds.top, finalBounds.top)) .with(ObjectAnimator.ofFloat(expandedImageView, View.SCALE_X, startScale, 1f)) .with(ObjectAnimator.ofFloat(expandedImageView, View.SCALE_Y, startScale, 1f)); set.setDuration(mShortAnimationDuration); set.setInterpolator(new DecelerateInterpolator()); set.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mCurrentAnimator = null; } @Override public void onAnimationCancel(Animator animation) { mCurrentAnimator = null; } }); set.start(); mCurrentAnimator = set; // Upon clicking the zoomed-in image, it should zoom back down to the original bounds // and show the thumbnail instead of the expanded image. final float startScaleFinal = startScale; expandedImageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (mCurrentAnimator != null) { mCurrentAnimator.cancel(); } // Animate the four positioning/sizing properties in parallel, back to their // original values. AnimatorSet set = new AnimatorSet(); set.play(ObjectAnimator.ofFloat(expandedImageView, View.X, startBounds.left)) .with(ObjectAnimator.ofFloat(expandedImageView, View.Y, startBounds.top)) .with(ObjectAnimator.ofFloat(expandedImageView, View.SCALE_X, startScaleFinal)) .with(ObjectAnimator.ofFloat(expandedImageView, View.SCALE_Y, startScaleFinal)); set.setDuration(mShortAnimationDuration); set.setInterpolator(new DecelerateInterpolator()); set.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { thumbView.setAlpha(1f); expandedImageView.setVisibility(View.GONE); mCurrentAnimator = null; } @Override public void onAnimationCancel(Animator animation) { thumbView.setAlpha(1f); expandedImageView.setVisibility(View.GONE); mCurrentAnimator = null; } }); set.start(); mCurrentAnimator = set; } }); }
From source file:com.mukesh.OtpView.java
private void setupAnimator() { defaultAddAnimator = ValueAnimator.ofFloat(0.5f, 1f); defaultAddAnimator.setDuration(150); defaultAddAnimator.setInterpolator(new DecelerateInterpolator()); defaultAddAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override/*w w w. j a v a 2 s. co m*/ public void onAnimationUpdate(ValueAnimator animation) { float scale = (float) animation.getAnimatedValue(); int alpha = (int) (255 * scale); animatorTextPaint.setTextSize(getTextSize() * scale); animatorTextPaint.setAlpha(alpha); postInvalidate(); } }); }
From source file:de.mrapp.android.bottomsheet.view.DraggableView.java
/** * Handles when a drag gesture has been ended by the user. *//*www . j av a 2 s.c o m*/ private void handleRelease() { float speed = Math.max(dragHelper.getDragSpeed(), animationSpeed); if (getTopMargin() > initialMargin || (dragHelper.getDragSpeed() > animationSpeed && dragHelper.getDistance() > 0) || (getDeviceType(getContext()) == DeviceType.TABLET && isMaximized() && getTopMargin() > minMargin)) { animateHideView(parentHeight - getTopMargin(), speed, new DecelerateInterpolator(), true); } else { animateShowView(-(getTopMargin() - minMargin), speed, new DecelerateInterpolator()); } }
From source file:com.tmall.wireless.tangram3.ext.SwipeItemTouchListener.java
private void resetViews(RecyclerView recyclerView, final int swipingType, final boolean reachActionEdge, final int direction) { if (enableAnim) { int contentWidth = recyclerView.getWidth(); AnimatorSet animatorSet = new AnimatorSet(); List<Animator> list = new ArrayList<>(); String translation = "translationX"; if (swipingType == SWIPING_VER) { translation = "translationY"; }/*from w ww . j a v a2 s. c o m*/ for (View view : mChildList) { ObjectAnimator animator; if (reachActionEdge) { animator = ObjectAnimator.ofFloat(view, translation, contentWidth * direction) .setDuration(ANIMATE_DURATION); animator.setInterpolator(new AccelerateInterpolator()); } else { animator = ObjectAnimator.ofFloat(view, translation, 0).setDuration(ANIMATE_DURATION); animator.setInterpolator(new DecelerateInterpolator()); } list.add(animator); } animatorSet.playTogether(list); animatorSet.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { if (swipingType == SWIPING_HOR && reachActionEdge) { if (mSwipeCardRef != null && mSwipeCardRef.get() != null) { SwipeCard swipeCard = mSwipeCardRef.get(); swipeCard.switchTo(swipeCard.getCurrentIndex() - direction); } } mChildList.clear(); } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }); animatorSet.start(); } else { if (swipingType == SWIPING_HOR && reachActionEdge) { if (mSwipeCardRef != null && mSwipeCardRef.get() != null) { SwipeCard swipeCard = mSwipeCardRef.get(); swipeCard.switchTo(swipeCard.getCurrentIndex() - direction); } } mChildList.clear(); } if (swipingType == SWIPING_VER) { if (pullFromEndListener != null) { if (mDistanceY < 0 && (mDistanceY < -pullFromEndListener.getPullEdge())) { pullFromEndListener.onAction(); } else { pullFromEndListener.onReset(); } } } swipeType = SWIPING_NONE; }
From source file:org.videolan.vlc.gui.helpers.UiTools.java
public static void fillAboutView(View v) { TextView link = (TextView) v.findViewById(R.id.main_link); link.setText(Html.fromHtml(VLCApplication.getAppResources().getString(R.string.about_link))); String revision = VLCApplication.getAppResources().getString(R.string.build_revision) + " VLC: " + VLCApplication.getAppResources().getString(R.string.build_vlc_revision); String builddate = VLCApplication.getAppResources().getString(R.string.build_time); String builder = VLCApplication.getAppResources().getString(R.string.build_host); TextView compiled = (TextView) v.findViewById(R.id.main_compiled); compiled.setText(builder + " (" + builddate + ")"); TextView textview_rev = (TextView) v.findViewById(R.id.main_revision); textview_rev.setText(VLCApplication.getAppResources().getString(R.string.revision) + " " + revision + " (" + builddate + ") " + BuildConfig.FLAVOR_abi); final ImageView logo = (ImageView) v.findViewById(R.id.logo); logo.setOnClickListener(new View.OnClickListener() { @Override/*from w w w . ja v a2 s .c om*/ public void onClick(View v) { AnimationSet anim = new AnimationSet(true); RotateAnimation rotate = new RotateAnimation(0f, 360f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); rotate.setDuration(800); rotate.setInterpolator(new DecelerateInterpolator()); anim.addAnimation(rotate); logo.startAnimation(anim); } }); }
From source file:android.example.com.animationdemos.ZoomActivity.java
/** * "Zooms" in a thumbnail view by assigning the high resolution image to a hidden "zoomed-in" * image view and animating its bounds to fit the entire activity content area. More * specifically://from ww w. java 2 s . c om * <p/> * <ol> * <li>Assign the high-res image to the hidden "zoomed-in" (expanded) image view.</li> * <li>Calculate the starting and ending bounds for the expanded view.</li> * <li>Animate each of four positioning/sizing properties (X, Y, SCALE_X, SCALE_Y) * simultaneously, from the starting bounds to the ending bounds.</li> * <li>Zoom back out by running the reverse animation on click.</li> * </ol> * * @param thumbView The thumbnail view to zoom in. * @param imageResId The high-resolution version of the image represented by the thumbnail. */ private void zoomImageFromThumb(final View thumbView, int imageResId) { // If there's an animation in progress, cancel it immediately and proceed with this one. if (mCurrentAnimator != null) { mCurrentAnimator.cancel(); } // Load the high-resolution "zoomed-in" image. final ImageView expandedImageView = (ImageView) findViewById(R.id.expanded_image); expandedImageView.setImageResource(imageResId); // Calculate the starting and ending bounds for the zoomed-in image. This step // involves lots of math. Yay, math. final Rect startBounds = new Rect(); final Rect finalBounds = new Rect(); final Point globalOffset = new Point(); // The start bounds are the global visible rectangle of the thumbnail, and the // final bounds are the global visible rectangle of the container view. Also // set the container view's offset as the origin for the bounds, since that's // the origin for the positioning animation properties (X, Y). thumbView.getGlobalVisibleRect(startBounds); findViewById(R.id.container).getGlobalVisibleRect(finalBounds, globalOffset); startBounds.offset(-globalOffset.x, -globalOffset.y); finalBounds.offset(-globalOffset.x, -globalOffset.y); // Adjust the start bounds to be the same aspect ratio as the final bounds using the // "center crop" technique. This prevents undesirable stretching during the animation. // Also calculate the start scaling factor (the end scaling factor is always 1.0). float startScale; if ((float) finalBounds.width() / finalBounds.height() > (float) startBounds.width() / startBounds.height()) { // Extend start bounds horizontally startScale = (float) startBounds.height() / finalBounds.height(); float startWidth = startScale * finalBounds.width(); float deltaWidth = (startWidth - startBounds.width()) / 2; startBounds.left -= deltaWidth; startBounds.right += deltaWidth; } else { // Extend start bounds vertically startScale = (float) startBounds.width() / finalBounds.width(); float startHeight = startScale * finalBounds.height(); float deltaHeight = (startHeight - startBounds.height()) / 2; startBounds.top -= deltaHeight; startBounds.bottom += deltaHeight; } // Hide the thumbnail and show the zoomed-in view. When the animation begins, // it will position the zoomed-in view in the place of the thumbnail. thumbView.setAlpha(0f); expandedImageView.setVisibility(View.VISIBLE); // Set the pivot point for SCALE_X and SCALE_Y transformations to the top-left corner of // the zoomed-in view (the default is the center of the view). expandedImageView.setPivotX(0f); expandedImageView.setPivotY(0f); // Construct and run the parallel animation of the four translation and scale properties // (X, Y, SCALE_X, and SCALE_Y). AnimatorSet set = new AnimatorSet(); set.play(ObjectAnimator.ofFloat(expandedImageView, View.X, startBounds.left, finalBounds.left)) .with(ObjectAnimator.ofFloat(expandedImageView, View.Y, startBounds.top, finalBounds.top)) .with(ObjectAnimator.ofFloat(expandedImageView, View.SCALE_X, startScale, 1f)) .with(ObjectAnimator.ofFloat(expandedImageView, View.SCALE_Y, startScale, 1f)); set.setDuration(mShortAnimationDuration); set.setInterpolator(new DecelerateInterpolator()); set.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mCurrentAnimator = null; } @Override public void onAnimationCancel(Animator animation) { mCurrentAnimator = null; } }); set.start(); mCurrentAnimator = set; // Upon clicking the zoomed-in image, it should zoom back down to the original bounds // and show the thumbnail instead of the expanded image. final float startScaleFinal = startScale; expandedImageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (mCurrentAnimator != null) { mCurrentAnimator.cancel(); } // Animate the four positioning/sizing properties in parallel, back to their // original values. AnimatorSet set = new AnimatorSet(); set.play(ObjectAnimator.ofFloat(expandedImageView, View.X, startBounds.left)) .with(ObjectAnimator.ofFloat(expandedImageView, View.Y, startBounds.top)) .with(ObjectAnimator.ofFloat(expandedImageView, View.SCALE_X, startScaleFinal)) .with(ObjectAnimator.ofFloat(expandedImageView, View.SCALE_Y, startScaleFinal)); set.setDuration(mShortAnimationDuration); set.setInterpolator(new DecelerateInterpolator()); set.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { thumbView.setAlpha(1f); expandedImageView.setVisibility(View.GONE); mCurrentAnimator = null; } @Override public void onAnimationCancel(Animator animation) { thumbView.setAlpha(1f); expandedImageView.setVisibility(View.GONE); mCurrentAnimator = null; } }); set.start(); mCurrentAnimator = set; } }); }
From source file:cn.androidy.materialdesignsample.animations.ZoomActivity.java
/** * "Zooms" in a thumbnail view by assigning the high resolution image to a hidden "zoomed-in" * image view and animating its bounds to fit the entire activity content area. More * specifically:/*from w ww . ja v a 2 s .c o m*/ * * <ol> * <li>Assign the high-res image to the hidden "zoomed-in" (expanded) image view.</li> * <li>Calculate the starting and ending bounds for the expanded view.</li> * <li>Animate each of four positioning/sizing properties (X, Y, SCALE_X, SCALE_Y) * simultaneously, from the starting bounds to the ending bounds.</li> * <li>Zoom back out by running the reverse animation on click.</li> * </ol> * * @param thumbView The thumbnail view to zoom in. * @param imageResId The high-resolution version of the image represented by the thumbnail. */ private void zoomImageFromThumb(final View thumbView, int imageResId) { // If there's an animation in progress, cancel it immediately and proceed with this one. if (mCurrentAnimator != null) { mCurrentAnimator.cancel(); } // Load the high-resolution "zoomed-in" image. final ImageView expandedImageView = (ImageView) findViewById(R.id.expanded_image); expandedImageView.setImageResource(imageResId); // Calculate the starting and ending bounds for the zoomed-in image. This step // involves lots of math. Yay, math. final Rect startBounds = new Rect(); final Rect finalBounds = new Rect(); final Point globalOffset = new Point(); // The start bounds are the global visible rectangle of the thumbnail, and the // final bounds are the global visible rectangle of the container view. Also // set the container view's offset as the origin for the bounds, since that's // the origin for the positioning animation properties (X, Y). thumbView.getGlobalVisibleRect(startBounds); findViewById(R.id.container).getGlobalVisibleRect(finalBounds, globalOffset); startBounds.offset(-globalOffset.x, -globalOffset.y); finalBounds.offset(-globalOffset.x, -globalOffset.y); // Adjust the start bounds to be the same aspect ratio as the final bounds using the // "center crop" technique. This prevents undesirable stretching during the animation. // Also calculate the start scaling factor (the end scaling factor is always 1.0). float startScale; if ((float) finalBounds.width() / finalBounds.height() > (float) startBounds.width() / startBounds.height()) { // Extend start bounds horizontally startScale = (float) startBounds.height() / finalBounds.height(); float startWidth = startScale * finalBounds.width(); float deltaWidth = (startWidth - startBounds.width()) / 2; startBounds.left -= deltaWidth; startBounds.right += deltaWidth; } else { // Extend start bounds vertically startScale = (float) startBounds.width() / finalBounds.width(); float startHeight = startScale * finalBounds.height(); float deltaHeight = (startHeight - startBounds.height()) / 2; startBounds.top -= deltaHeight; startBounds.bottom += deltaHeight; } // Hide the thumbnail and show the zoomed-in view. When the animation begins, // it will position the zoomed-in view in the place of the thumbnail. thumbView.setAlpha(0f); expandedImageView.setVisibility(View.VISIBLE); // Set the pivot point for SCALE_X and SCALE_Y transformations to the top-left corner of // the zoomed-in view (the default is the center of the view). expandedImageView.setPivotX(0f); expandedImageView.setPivotY(0f); // Construct and run the parallel animation of the four translation and scale properties // (X, Y, SCALE_X, and SCALE_Y). AnimatorSet set = new AnimatorSet(); set.play(ObjectAnimator.ofFloat(expandedImageView, View.X, startBounds.left, finalBounds.left)) .with(ObjectAnimator.ofFloat(expandedImageView, View.Y, startBounds.top, finalBounds.top)) .with(ObjectAnimator.ofFloat(expandedImageView, View.SCALE_X, startScale, 1f)) .with(ObjectAnimator.ofFloat(expandedImageView, View.SCALE_Y, startScale, 1f)); set.setDuration(mShortAnimationDuration); set.setInterpolator(new DecelerateInterpolator()); set.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mCurrentAnimator = null; } @Override public void onAnimationCancel(Animator animation) { mCurrentAnimator = null; } }); set.start(); mCurrentAnimator = set; // Upon clicking the zoomed-in image, it should zoom back down to the original bounds // and show the thumbnail instead of the expanded image. final float startScaleFinal = startScale; expandedImageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (mCurrentAnimator != null) { mCurrentAnimator.cancel(); } // Animate the four positioning/sizing properties in parallel, back to their // original values. AnimatorSet set = new AnimatorSet(); set.play(ObjectAnimator.ofFloat(expandedImageView, View.X, startBounds.left)) .with(ObjectAnimator.ofFloat(expandedImageView, View.Y, startBounds.top)) .with(ObjectAnimator.ofFloat(expandedImageView, View.SCALE_X, startScaleFinal)) .with(ObjectAnimator.ofFloat(expandedImageView, View.SCALE_Y, startScaleFinal)); set.setDuration(mShortAnimationDuration); set.setInterpolator(new DecelerateInterpolator()); set.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { thumbView.setAlpha(1f); expandedImageView.setVisibility(View.GONE); mCurrentAnimator = null; } @Override public void onAnimationCancel(Animator animation) { thumbView.setAlpha(1f); expandedImageView.setVisibility(View.GONE); mCurrentAnimator = null; } }); set.start(); mCurrentAnimator = set; } }); }
From source file:fr.julienvermet.bugdroid.ui.tablet.AbsBugsMultiPaneFragment.java
public void collapseLeftPane(int speed) { int targetWidth = mMinLeftWidth; ValueAnimator animator = ValueAnimator.ofObject(new WidthEvaluator(mLeftPane), mLeftPane.getWidth(), targetWidth);//from ww w .ja v a2 s. c o m animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { super.onAnimationStart(animation); mLeftName.setVisibility(View.VISIBLE); } @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); mLeftView.setVisibility(View.GONE); mIsLeftCollapsed = true; } }); animator.setInterpolator(new DecelerateInterpolator()); animator.setDuration(speed); animator.start(); }