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:com.waz.zclient.pages.main.participants.dialog.ParticipantsDialogFragment.java
/** * @return true if the animation was performed, * false otherwise//from w w w.j a v a 2 s . c o m */ private boolean animateBetweenMainAndDetail(boolean showGroup) { float startDetail; float endDetail; float startMain; float endMain; Interpolator interpolator; if (showGroup) { startDetail = 0; endDetail = dialogFrameLayout.getMeasuredWidth(); startMain = -dialogFrameLayout.getMeasuredHeight(); endMain = 0; interpolator = new Quart.EaseOut(); } else { startDetail = dialogFrameLayout.getMeasuredWidth(); endDetail = 0; startMain = 0; endMain = -dialogFrameLayout.getMeasuredHeight(); interpolator = new Quart.EaseOut(); } if (MathUtils.floatEqual(mainParticipantsContainer.getTranslationX(), endMain) && MathUtils.floatEqual(detailParticipantContainer.getTranslationX(), endDetail)) { return false; } ObjectAnimator slideInDetailParticipantAnimation = ObjectAnimator.ofFloat(detailParticipantContainer, View.TRANSLATION_X, startDetail, endDetail); slideInDetailParticipantAnimation .setDuration(getResources().getInteger(R.integer.framework_animation_duration_long)); slideInDetailParticipantAnimation.setInterpolator(interpolator); ObjectAnimator slideOutMainAnimation = ObjectAnimator.ofFloat(mainParticipantsContainer, View.TRANSLATION_X, startMain, endMain); slideOutMainAnimation.setDuration(getResources().getInteger(R.integer.framework_animation_duration_long)); slideOutMainAnimation.setInterpolator(interpolator); AnimatorSet participantTransition = new AnimatorSet(); participantTransition.playTogether(slideOutMainAnimation, slideInDetailParticipantAnimation); participantTransition.start(); return true; }
From source file:com.android.clear.reminder.ItemAnimator.java
@Override public void runPendingAnimations() { final AnimatorSet removeAnimatorSet = new AnimatorSet(); removeAnimatorSet.playTogether(mRemoveAnimatorsList); mRemoveAnimatorsList.clear();/*from w w w . j a va 2s . c o m*/ final AnimatorSet addAnimatorSet = new AnimatorSet(); addAnimatorSet.playTogether(mAddAnimatorsList); mAddAnimatorsList.clear(); final AnimatorSet changeAnimatorSet = new AnimatorSet(); changeAnimatorSet.playTogether(mChangeAnimatorsList); mChangeAnimatorsList.clear(); final AnimatorSet moveAnimatorSet = new AnimatorSet(); moveAnimatorSet.playTogether(mMoveAnimatorsList); mMoveAnimatorsList.clear(); final AnimatorSet pendingAnimatorSet = new AnimatorSet(); pendingAnimatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animator) { animator.removeAllListeners(); dispatchFinishedWhenDone(); } }); // Required order: removes, then changes & moves simultaneously, then additions. There are // redundant edges because changes or moves may be empty, causing the removes to incorrectly // play immediately. pendingAnimatorSet.play(removeAnimatorSet).before(changeAnimatorSet); pendingAnimatorSet.play(removeAnimatorSet).before(moveAnimatorSet); pendingAnimatorSet.play(changeAnimatorSet).with(moveAnimatorSet); pendingAnimatorSet.play(addAnimatorSet).after(changeAnimatorSet); pendingAnimatorSet.play(addAnimatorSet).after(moveAnimatorSet); pendingAnimatorSet.start(); }
From source file:net.huannguyen.conductorexample.transition.DetailPopAnimChangeHandler.java
@NonNull @Override//w w w. ja v a 2 s. c o m protected Animator getAnimator(@NonNull ViewGroup container, @Nullable View from, @Nullable View to, boolean isPush, boolean toAddedToContainer) { // Make sure the from view is a CountryDetailView if (from == null || !(from instanceof CountryDetailView)) throw new IllegalArgumentException("The from view must be a CountryDetailView"); if (to == null) throw new IllegalArgumentException("The to view must not be null"); final CountryDetailView detailView = (CountryDetailView) from; AnimatorSet animatorSet = new AnimatorSet(); // Set the to View's alpha to 0 to hide it at the beginning. to.setAlpha(0); // Scale down to hide the fab button PropertyValuesHolder fabScaleX = PropertyValuesHolder.ofFloat(View.SCALE_X, 0); PropertyValuesHolder fabScaleY = PropertyValuesHolder.ofFloat(View.SCALE_Y, 0); Animator hideFabButtonAnimator = ObjectAnimator.ofPropertyValuesHolder(detailView.favouriteFab, fabScaleX, fabScaleY); // Slide up the flag Animator flagAnimator = ObjectAnimator.ofFloat(detailView.flagView, View.TRANSLATION_Y, 0, -detailView.flagView.getHeight()); // Slide down the details Animator detailAnimator = ObjectAnimator.ofFloat(detailView.detailGroup, View.TRANSLATION_Y, 0, detailView.detailGroup.getHeight()); // Show the new view Animator showToViewAnimator = ObjectAnimator.ofFloat(to, View.ALPHA, 0, 1); animatorSet.playTogether(hideFabButtonAnimator, flagAnimator, detailAnimator, showToViewAnimator); animatorSet.setDuration(300); animatorSet.setInterpolator(new FastOutLinearInInterpolator()); animatorSet.start(); return animatorSet; }
From source file:com.alimuzaffar.lib.pin.PinEntryEditText.java
private void animateBottomUp(CharSequence text, final int start) { mCharBottom[start] = mLineCoords[start].bottom - mTextBottomPadding; ValueAnimator animUp = ValueAnimator.ofFloat(mCharBottom[start] + getPaint().getTextSize(), mCharBottom[start]);/*from www . j a va 2 s . c om*/ animUp.setDuration(300); animUp.setInterpolator(new OvershootInterpolator()); animUp.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { Float value = (Float) animation.getAnimatedValue(); mCharBottom[start] = value; PinEntryEditText.this.invalidate(); } }); mLastCharPaint.setAlpha(255); ValueAnimator animAlpha = ValueAnimator.ofInt(0, 255); animAlpha.setDuration(300); animAlpha.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { Integer value = (Integer) animation.getAnimatedValue(); mLastCharPaint.setAlpha(value); } }); AnimatorSet set = new AnimatorSet(); if (text.length() == mMaxLength && mOnPinEnteredListener != null) { set.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { mOnPinEnteredListener.onPinEntered(getText()); } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }); } set.playTogether(animUp, animAlpha); set.start(); }
From source file:io.plaidapp.ui.DesignerNewsStory.java
private void doFabExpand() { // translate the chrome placeholder ui so that it is centered on the FAB int fabCenterX = (fab.getLeft() + fab.getRight()) / 2; int fabCenterY = ((fab.getTop() + fab.getBottom()) / 2) - fabExpand.getTop(); int translateX = fabCenterX - (fabExpand.getWidth() / 2); int translateY = fabCenterY - (fabExpand.getHeight() / 2); fabExpand.setTranslationX(translateX); fabExpand.setTranslationY(translateY); // then reveal the placeholder ui, starting from the center & same dimens as fab fabExpand.setVisibility(View.VISIBLE); Animator reveal = ViewAnimationUtils .createCircularReveal(fabExpand, fabExpand.getWidth() / 2, fabExpand.getHeight() / 2, fab.getWidth() / 2, (int) Math.hypot(fabExpand.getWidth() / 2, fabExpand.getHeight() / 2)) .setDuration(fabExpandDuration); // translate the placeholder ui back into position along an arc GravityArcMotion arcMotion = new GravityArcMotion(); arcMotion.setMinimumVerticalAngle(70f); Path motionPath = arcMotion.getPath(translateX, translateY, 0, 0); Animator position = ObjectAnimator.ofFloat(fabExpand, View.TRANSLATION_X, View.TRANSLATION_Y, motionPath) .setDuration(fabExpandDuration); // animate from the FAB colour to the placeholder background color Animator background = ObjectAnimator .ofArgb(fabExpand, ViewUtils.BACKGROUND_COLOR, ContextCompat.getColor(this, R.color.designer_news), ContextCompat.getColor(this, R.color.background_light)) .setDuration(fabExpandDuration); // fade out the fab (rapidly) Animator fadeOutFab = ObjectAnimator.ofFloat(fab, View.ALPHA, 0f).setDuration(60); // play 'em all together with the material interpolator AnimatorSet show = new AnimatorSet(); show.setInterpolator(getFastOutSlowInInterpolator(DesignerNewsStory.this)); show.playTogether(reveal, background, position, fadeOutFab); show.start(); }
From source file:me.zchang.onchart.ui.MainActivity.java
private void popupThisWeek(int weekNum) { popupWeekText.setText(String.format(getString(R.string.weekday_week), weekNum)); popupWeekText.setVisibility(View.VISIBLE); popupWeekText.setScaleX(.3f);/* w w w.java 2 s.co m*/ popupWeekText.setScaleY(.3f); popupWeekText.setAlpha(.7f); Animator scaleAnimator = ObjectAnimator.ofFloat(popupWeekText, "scaleX", 1f); Animator scaleAnimator2 = ObjectAnimator.ofFloat(popupWeekText, "scaleY", 1f); scaleAnimator.setDuration(150); scaleAnimator2.setDuration(150); Animator alphaAnimator = ObjectAnimator.ofFloat(popupWeekText, "alpha", 0f); alphaAnimator.setStartDelay(120); alphaAnimator.setDuration(500); AnimatorSet animatorSet = new AnimatorSet(); animatorSet.play(scaleAnimator).with(scaleAnimator2).with(alphaAnimator); animatorSet.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { popupWeekText.setVisibility(View.GONE); } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }); animatorSet.start(); }
From source file:net.huannguyen.conductorexample.transition.DetailPushAnimChangeHandler.java
@NonNull @Override/*from ww w.j a v a2s . c o m*/ protected Animator getAnimator(@NonNull ViewGroup container, @Nullable View from, @Nullable View to, boolean isPush, boolean toAddedToContainer) { // Make sure the to view is a CountryDetailView if (to == null || !(to instanceof CountryDetailView)) throw new IllegalArgumentException("The to view must be a CountryDetailView"); final CountryDetailView detailView = (CountryDetailView) to; // Set the button scale to 0 to make it invisible at the beginning. detailView.favouriteFab.setScaleX(0); detailView.favouriteFab.setScaleY(0); AnimatorSet animatorSet = new AnimatorSet(); AnimatorSet flagAndDetailAnim = new AnimatorSet(); // Hide the old view Animator hideFromViewAnim = ObjectAnimator.ofFloat(from, View.ALPHA, 1, 0); // Slide down the flag Animator flagAnim = ObjectAnimator.ofFloat(detailView.flagView, View.TRANSLATION_Y, -detailView.flagView.getHeight(), 0); // Slide up the details Animator detailAnim = ObjectAnimator.ofFloat(detailView.detailGroup, View.TRANSLATION_Y, detailView.detailGroup.getHeight(), 0); flagAndDetailAnim.playTogether(hideFromViewAnim, flagAnim, detailAnim); flagAndDetailAnim.setDuration(300); flagAndDetailAnim.setInterpolator(new FastOutSlowInInterpolator()); // Scale up the favourite fab PropertyValuesHolder fabScaleX = PropertyValuesHolder.ofFloat(View.SCALE_X, 0, 1); PropertyValuesHolder fabScaleY = PropertyValuesHolder.ofFloat(View.SCALE_Y, 0, 1); Animator favouriteAnim = ObjectAnimator .ofPropertyValuesHolder(detailView.favouriteFab, fabScaleX, fabScaleY).setDuration(200); animatorSet.playSequentially(flagAndDetailAnim, favouriteAnim); animatorSet.start(); return animatorSet; }
From source file:org.telegram.ui.Components.StickersAlert.java
private void hidePreview() { AnimatorSet animatorSet = new AnimatorSet(); animatorSet.playTogether(ObjectAnimator.ofFloat(stickerPreviewLayout, "alpha", 0.0f)); animatorSet.setDuration(200);/* w w w .j a v a2s .co m*/ animatorSet.addListener(new AnimatorListenerAdapterProxy() { @Override public void onAnimationEnd(Animator animation) { stickerPreviewLayout.setVisibility(View.GONE); } }); animatorSet.start(); }
From source file:io.plaidapp.ui.DesignerNewsStory.java
private void doFabExpand() { // translate the chrome placeholder ui so that it is centered on the FAB int fabCenterX = (fab.getLeft() + fab.getRight()) / 2; int fabCenterY = ((fab.getTop() + fab.getBottom()) / 2) - fabExpand.getTop(); int translateX = fabCenterX - (fabExpand.getWidth() / 2); int translateY = fabCenterY - (fabExpand.getHeight() / 2); fabExpand.setTranslationX(translateX); fabExpand.setTranslationY(translateY); // then reveal the placeholder ui, starting from the center & same dimens as fab fabExpand.setVisibility(View.VISIBLE); Animator reveal = ViewAnimationUtils .createCircularReveal(fabExpand, fabExpand.getWidth() / 2, fabExpand.getHeight() / 2, fab.getWidth() / 2, (int) Math.hypot(fabExpand.getWidth() / 2, fabExpand.getHeight() / 2)) .setDuration(fabExpandDuration); // translate the placeholder ui back into position along an arc ArcMotion arcMotion = new ArcMotion(); arcMotion.setMinimumVerticalAngle(70f); Path motionPath = arcMotion.getPath(translateX, translateY, 0, 0); Animator position = ObjectAnimator.ofFloat(fabExpand, View.TRANSLATION_X, View.TRANSLATION_Y, motionPath) .setDuration(fabExpandDuration); // animate from the FAB colour to the placeholder background color Animator background = ObjectAnimator .ofArgb(fabExpand, ViewUtils.BACKGROUND_COLOR, ContextCompat.getColor(this, R.color.designer_news), ContextCompat.getColor(this, R.color.background_light)) .setDuration(fabExpandDuration); // fade out the fab (rapidly) Animator fadeOutFab = ObjectAnimator.ofFloat(fab, View.ALPHA, 0f).setDuration(60); // play 'em all together with the material interpolator AnimatorSet show = new AnimatorSet(); show.setInterpolator(//from www .j a v a2 s . c o m AnimationUtils.loadInterpolator(DesignerNewsStory.this, android.R.interpolator.fast_out_slow_in)); show.playTogether(reveal, background, position, fadeOutFab); show.start(); }
From source file:com.example.imac.animationsdemo.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 w w . j a v a 2 s . c o m*/ * <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; //? ??? 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). Log.e("==startBounds===", startBounds.left + " " + startBounds.top); AnimatorSet set = new AnimatorSet(); Log.e("=====", startBounds.left + " " + startBounds.top + " " + thumbView.getLeft() + " " + thumbView.getTop()); set.play(ObjectAnimator.ofFloat(expandedImageView, "X", startBounds.left, finalBounds.left)) .with(ObjectAnimator.ofFloat(expandedImageView, "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; } }); }