List of usage examples for android.animation AnimatorSet AnimatorSet
public AnimatorSet()
From source file:com.flexible.flexibleadapter.AnimatorAdapter.java
/** * Animates the view based on the custom animator list built with {@link #getAnimators(View, int, boolean)}. * * @since 5.0.0-b1/*from w w w . ja v a 2 s . co m*/ * @deprecated New system in place. Implement {@link FlexibleViewHolder#scrollAnimators(List, int, boolean)} * and add new animator(s) to the list of {@code animators}. */ @Deprecated public final void animateView(final View itemView, int position) { // if (DEBUG) // Log.v(TAG, "shouldAnimate=" + shouldAnimate // + " isFastScroll=" + isFastScroll // + " isNotified=" + mAnimatorNotifierObserver.isPositionNotified() // + " isReverseEnabled=" + isReverseEnabled // + " mLastAnimatedPosition=" + mLastAnimatedPosition // + (!isReverseEnabled ? " Pos>AniPos=" + (position > mLastAnimatedPosition) : "") // ); if (shouldAnimate && !isFastScroll && !mAnimatorNotifierObserver.isPositionNotified() && (isReverseEnabled || position > mLastAnimatedPosition || (position == 0 && mRecyclerView.getChildCount() == 0))) { //Cancel animation is necessary when fling cancelExistingAnimation(itemView.hashCode()); //Retrieve user animators List<Animator> animators = getAnimators(itemView, position, position > mLastAnimatedPosition); //Add Alpha animator ViewCompat.setAlpha(itemView, 0); animators.add(ObjectAnimator.ofFloat(itemView, "alpha", 0f, 1f)); Log.w(TAG, "Started Deprecated Animation on position " + position); //Execute the animations AnimatorSet set = new AnimatorSet(); set.playTogether(animators); set.setInterpolator(mInterpolator); set.setDuration(mDuration); set.addListener(new HelperAnimatorListener(itemView.hashCode())); if (mEntryStep) { set.setStartDelay(calculateAnimationDelay(position)); } set.start(); mAnimators.put(itemView.hashCode(), set); //Animate only during initial loading? if (onlyEntryAnimation && mLastAnimatedPosition >= mMaxChildViews) { shouldAnimate = false; } } mAnimatorNotifierObserver.clearNotified(); mLastAnimatedPosition = position; }
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 ww w . j a v a 2 s . co m AnimationUtils.loadInterpolator(DesignerNewsStory.this, android.R.interpolator.fast_out_slow_in)); show.playTogether(reveal, background, position, fadeOutFab); show.start(); }
From source file:com.b44t.ui.Components.PasscodeView.java
private void shakeTextView(final float x, final int num) { if (num == 6) { return;/*from w ww. ja v a 2s .c o m*/ } AnimatorSet AnimatorSet = new AnimatorSet(); AnimatorSet.playTogether(ObjectAnimator.ofFloat(passcodeTextView, "translationX", AndroidUtilities.dp(x))); AnimatorSet.setDuration(50); AnimatorSet.addListener(new AnimatorListenerAdapterProxy() { @Override public void onAnimationEnd(Animator animation) { shakeTextView(num == 5 ? 0 : -x, num + 1); } }); 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 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 w ww.j a v a 2s . com*/ }
From source file:com.conferenceengineer.android.iosched.ui.SessionDetailFragment.java
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) private void setOrAnimateIconTo(final ImageView imageView, final int imageResId, boolean animate) { if (UIUtils.hasICS() && imageView.getTag() != null) { if (imageView.getTag() instanceof Animator) { Animator anim = (Animator) imageView.getTag(); anim.end();/*from ww w . j a va 2s . c o m*/ imageView.setAlpha(1f); } } animate = animate && UIUtils.hasICS(); if (animate) { int duration = getResources().getInteger(android.R.integer.config_shortAnimTime); Animator outAnimator = ObjectAnimator.ofFloat(imageView, View.ALPHA, 0f); outAnimator.setDuration(duration / 2); outAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { imageView.setImageResource(imageResId); } }); AnimatorSet inAnimator = new AnimatorSet(); inAnimator.setDuration(duration); inAnimator.playTogether(ObjectAnimator.ofFloat(imageView, View.ALPHA, 1f), ObjectAnimator.ofFloat(imageView, View.SCALE_X, 0f, 1f), ObjectAnimator.ofFloat(imageView, View.SCALE_Y, 0f, 1f)); AnimatorSet set = new AnimatorSet(); set.playSequentially(outAnimator, inAnimator); set.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { imageView.setTag(null); } }); imageView.setTag(set); set.start(); } else { mHandler.post(new Runnable() { @Override public void run() { imageView.setImageResource(imageResId); } }); } }
From source file:com.google.android.apps.santatracker.village.Village.java
private void setIsDay(final boolean isDay, boolean smoothTransition) { ObjectAnimator sunAnim = ObjectAnimator.ofInt(this, "sunOffset", sunOffset, isDay ? 0 : mViewHeight); sunAnim.setInterpolator(new AnticipateOvershootInterpolator()); sunAnim.setDuration(smoothTransition ? ImageWithAlphaAndSize.ANIM_DURATION : 0); sunAnim.addListener(new Animator.AnimatorListener() { @Override//from www .j av a 2 s . c o m public void onAnimationStart(Animator animation) { if (isDay) { mImageSun.setAlpha(ImageWithAlphaAndSize.OPAQUE); } } @Override public void onAnimationEnd(Animator animation) { if (!isDay) { mImageSun.setAlpha(ImageWithAlphaAndSize.INVISIBLE); } } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }); AnimatorSet dayAnims = new AnimatorSet(); dayAnims.playTogether( // Day values mImageSkyDay.fadeTransition(isDay, smoothTransition), mImageMountainsDay.fadeTransition(isDay, smoothTransition), mPaintMountainsDay.fadeTransition(isDay, smoothTransition)); ObjectAnimator moonAnim = ObjectAnimator.ofInt(this, "moonOffset", moonOffset, isDay ? -mViewHeight : 0); moonAnim.setInterpolator(new AnticipateOvershootInterpolator()); moonAnim.setDuration(smoothTransition ? ImageWithAlphaAndSize.ANIM_DURATION : 0); moonAnim.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { if (!isDay) { mImageMoon.setAlpha(ImageWithAlphaAndSize.OPAQUE); } } @Override public void onAnimationEnd(Animator animation) { if (isDay) { mImageMoon.setAlpha(ImageWithAlphaAndSize.INVISIBLE); } } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }); AnimatorSet nightAnims = new AnimatorSet(); nightAnims.playTogether( // Night values mImageSkyNight.fadeTransition(!isDay, !isDay && smoothTransition), mImageMountainsNight.fadeTransition(!isDay, !isDay && smoothTransition), mPaintMountainsNight.fadeTransition(!isDay, !isDay && smoothTransition)); // When going to the day, delay night animation till after day time has kicked in if (isDay) { nightAnims.setStartDelay(ImageWithAlphaAndSize.ANIM_DURATION); } mFinalAnimations = nightAnims; sunAnim.start(); dayAnims.start(); moonAnim.start(); nightAnims.start(); }
From source file:io.plaidapp.designernews.ui.story.StoryActivity.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, io.plaidapp.R.color.designer_news), ContextCompat.getColor(this, io.plaidapp.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(StoryActivity.this)); show.playTogether(reveal, background, position, fadeOutFab); show.start();/* w w w . j av a 2s . c o m*/ }
From source file:orbin.deskclock.timer.TimerFragment.java
/** * @param timerToRemove the timer to be removed during the animation *//*from w w w .ja v a 2 s . c o m*/ private void animateTimerRemove(final Timer timerToRemove) { final long duration = UiDataModel.getUiDataModel().getShortAnimationDuration(); final Animator fadeOut = ObjectAnimator.ofFloat(mViewPager, ALPHA, 1, 0); fadeOut.setDuration(duration); fadeOut.setInterpolator(new DecelerateInterpolator()); fadeOut.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { DataModel.getDataModel().removeTimer(timerToRemove); Events.sendTimerEvent(R.string.action_delete, R.string.label_deskclock); } }); final Animator fadeIn = ObjectAnimator.ofFloat(mViewPager, ALPHA, 0, 1); fadeIn.setDuration(duration); fadeIn.setInterpolator(new AccelerateInterpolator()); final AnimatorSet animatorSet = new AnimatorSet(); animatorSet.play(fadeOut).before(fadeIn); animatorSet.start(); }
From source file:com.google.android.apps.muzei.MuzeiActivity.java
private void updateUiMode() { // TODO: this should really just use fragment transactions and transitions int newUiMode = UI_MODE_INTRO; if (mWallpaperActive) { newUiMode = UI_MODE_TUTORIAL;//from ww w. j av a2 s. c om if (mSeenTutorial) { newUiMode = UI_MODE_ART_DETAIL; } } if (mUiMode == newUiMode) { return; } // Crossfade between main containers final View oldContainerView = getMainContainerForUiMode(mUiMode); final View newContainerView = getMainContainerForUiMode(newUiMode); if (oldContainerView != null) { oldContainerView.animate().alpha(0).setDuration(1000).withEndAction(new Runnable() { @Override public void run() { oldContainerView.setVisibility(View.GONE); } }); } if (newContainerView != null) { if (newContainerView.getAlpha() == 1) { newContainerView.setAlpha(0); } newContainerView.setVisibility(View.VISIBLE); newContainerView.animate().alpha(1).setDuration(1000).withEndAction(null); } // Special work if (newUiMode == UI_MODE_INTRO) { final View activateButton = findViewById(R.id.activate_muzei_button); activateButton.setAlpha(0); final AnimatedMuzeiLogoFragment logoFragment = (AnimatedMuzeiLogoFragment) getFragmentManager() .findFragmentById(R.id.animated_logo_fragment); logoFragment.reset(); logoFragment.setOnFillStartedCallback(new Runnable() { @Override public void run() { activateButton.animate().alpha(1f).setDuration(500); } }); mHandler.postDelayed(new Runnable() { @Override public void run() { logoFragment.start(); } }, 1000); } if (mUiMode == UI_MODE_INTRO || newUiMode == UI_MODE_INTRO) { FragmentManager fm = getSupportFragmentManager(); Fragment demoFragment = fm.findFragmentById(R.id.demo_view_container); if (newUiMode == UI_MODE_INTRO && demoFragment == null) { fm.beginTransaction() .add(R.id.demo_view_container, MuzeiRendererFragment.createInstance(true, true)).commit(); } else if (newUiMode != UI_MODE_INTRO && demoFragment != null) { fm.beginTransaction().remove(demoFragment).commit(); } } if (newUiMode == UI_MODE_TUTORIAL) { float animateDistance = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 100, getResources().getDisplayMetrics()); View mainTextView = findViewById(R.id.tutorial_main_text); mainTextView.setAlpha(0); mainTextView.setTranslationY(-animateDistance / 5); View subTextView = findViewById(R.id.tutorial_sub_text); subTextView.setAlpha(0); subTextView.setTranslationY(-animateDistance / 5); final View affordanceView = findViewById(R.id.tutorial_icon_affordance); affordanceView.setAlpha(0); affordanceView.setTranslationY(animateDistance); View iconTextView = findViewById(R.id.tutorial_icon_text); iconTextView.setAlpha(0); iconTextView.setTranslationY(animateDistance); AnimatorSet set = new AnimatorSet(); set.setStartDelay(500); set.setDuration(250); set.playTogether(ObjectAnimator.ofFloat(mainTextView, View.ALPHA, 1f), ObjectAnimator.ofFloat(subTextView, View.ALPHA, 1f)); set.start(); set = new AnimatorSet(); set.setStartDelay(2000); // Bug in older versions where set.setInterpolator didn't work Interpolator interpolator = new OvershootInterpolator(); ObjectAnimator a1 = ObjectAnimator.ofFloat(affordanceView, View.TRANSLATION_Y, 0); ObjectAnimator a2 = ObjectAnimator.ofFloat(iconTextView, View.TRANSLATION_Y, 0); ObjectAnimator a3 = ObjectAnimator.ofFloat(mainTextView, View.TRANSLATION_Y, 0); ObjectAnimator a4 = ObjectAnimator.ofFloat(subTextView, View.TRANSLATION_Y, 0); a1.setInterpolator(interpolator); a2.setInterpolator(interpolator); a3.setInterpolator(interpolator); a4.setInterpolator(interpolator); set.setDuration(500).playTogether(ObjectAnimator.ofFloat(affordanceView, View.ALPHA, 1f), ObjectAnimator.ofFloat(iconTextView, View.ALPHA, 1f), a1, a2, a3, a4); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { set.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { ImageView emanateView = (ImageView) findViewById(R.id.tutorial_icon_emanate); AnimatedVectorDrawable avd = (AnimatedVectorDrawable) getResources() .getDrawable(R.drawable.avd_tutorial_icon_emanate, getTheme()); emanateView.setImageDrawable(avd); avd.start(); } }); } set.start(); } mPanScaleProxyView.setVisibility(newUiMode == UI_MODE_ART_DETAIL ? View.VISIBLE : View.GONE); mUiMode = newUiMode; maybeUpdateArtDetailOpenedClosed(); }
From source file:com.itsronald.widget.ViewPagerIndicator.java
@Nullable private Animator pageChangeAnimator(final int lastPageIndex, final int newPageIndex) { final IndicatorDotPathView dotPath = getDotPathForPageChange(lastPageIndex, newPageIndex); final IndicatorDotView lastDot = getDotForPage(lastPageIndex); if (dotPath == null || lastDot == null) { final String warning = dotPath == null ? "dotPath is null!" : "lastDot is null!"; Log.w(TAG, warning);// w w w .ja v a2 s . co m return null; } final Animator connectPathAnimator = dotPath.connectPathAnimator(); connectPathAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { dotPath.setVisibility(VISIBLE); lastDot.setVisibility(INVISIBLE); } }); final long dotSlideDuration = DOT_SLIDE_ANIM_DURATION; final Animator selectedDotSlideAnimator = selectedDotSlideAnimator(newPageIndex, dotSlideDuration, 0); final int pathDirection = getPathDirectionForPageChange(lastPageIndex, newPageIndex); final Animator retreatPathAnimator = dotPath.retreatConnectedPathAnimator(pathDirection); final Animator dotRevealAnimator = lastDot.revealAnimator(); dotRevealAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { dotPath.setVisibility(INVISIBLE); } }); final AnimatorSet animatorSet = new AnimatorSet(); animatorSet.play(connectPathAnimator).before(selectedDotSlideAnimator); animatorSet.play(retreatPathAnimator).after(selectedDotSlideAnimator); animatorSet.play(dotRevealAnimator).with(retreatPathAnimator); return animatorSet; }