List of usage examples for android.animation AnimatorSet setStartDelay
@Override public void setStartDelay(long startDelay)
From source file:com.example.linhdq.test.install.InstallActivity.java
private void startInstallAnimation() { mTip1.setAlpha(0);/*from w w w. j av a 2s.c o m*/ mTip2.setAlpha(0); mTip3.setAlpha(0); mYoutube.setAlpha(0); ObjectAnimator anim1 = ObjectAnimator.ofFloat(mTip1, "alpha", 1); ObjectAnimator anim2 = ObjectAnimator.ofFloat(mTip2, "alpha", 1); ObjectAnimator anim3 = ObjectAnimator.ofFloat(mTip3, "alpha", 1); ObjectAnimator anim4 = ObjectAnimator.ofFloat(mYoutube, "alpha", 1); AnimatorSet set = new AnimatorSet(); set.setStartDelay(300); set.setDuration(600); set.playTogether(anim1, anim2, anim3, anim4); set.start(); mFairyAnimation.start(); }
From source file:com.dalingge.gankio.common.widgets.recyclerview.anim.adapter.helper.ViewAnimator.java
/** * Animates given View.//from w ww . j a v a 2 s. c o m * * @param view the View that should be animated. */ private void animateView(final int position, @NonNull final View view, @NonNull final Animator[] animators) { if (mAnimationStartMillis == -1) { mAnimationStartMillis = SystemClock.uptimeMillis(); } ViewCompat.setAlpha(view, 0); AnimatorSet set = new AnimatorSet(); set.playTogether(animators); set.setStartDelay(calculateAnimationDelay(position)); set.setDuration(mAnimationDurationMillis); set.start(); mAnimators.put(view.hashCode(), set); }
From source file:com.xianxiaotao.copyandstudy.xcopy.recycleranim.adapter.helper.ViewAnimator.java
/** * Animates given View.// w w w.j a v a2 s . c o m * * @param view the View that should be animated. */ @TargetApi(Build.VERSION_CODES.HONEYCOMB) private void animateView(final int position, @NonNull final View view, @NonNull final Animator[] animators) { if (mAnimationStartMillis == -1) { mAnimationStartMillis = SystemClock.uptimeMillis(); } ViewCompat.setAlpha(view, 0); AnimatorSet set = new AnimatorSet(); set.playTogether(animators); set.setStartDelay(calculateAnimationDelay(position)); set.setDuration(mAnimationDurationMillis); set.start(); mAnimators.put(view.hashCode(), set); }
From source file:com.devilyang.musicstation.swinginadapters.AnimationAdapter.java
private void animateView(int position, ViewGroup parent, View view) { if (mAnimationStartMillis == -1) { mAnimationStartMillis = System.currentTimeMillis(); }//from ww w . j a v a 2 s . c o m // ViewDragHelper.setAlpha(view, 0); view.setAlpha(0); Animator[] childAnimators; if (mDecoratedBaseAdapter instanceof AnimationAdapter) { childAnimators = ((AnimationAdapter) mDecoratedBaseAdapter).getAnimators(parent, view); } else { childAnimators = new Animator[0]; } Animator[] animators = getAnimators(parent, view); Animator alphaAnimator = ObjectAnimator.ofFloat(view, "alpha", 0, 1); AnimatorSet set = new AnimatorSet(); set.playTogether(concatAnimators(childAnimators, animators, alphaAnimator)); set.setStartDelay(calculateAnimationDelay()); set.setDuration(getAnimationDurationMillis()); set.start(); mAnimators.put(view.hashCode(), set); }
From source file:la.marsave.fullscreentest.MainActivity.java
/** * This method animates the image fragment into the foreground by both * scaling and rotating the fragment's view, while also removing the * previously added translucent dark hover view. Upon the completion of * this animation, the image fragment regains focus since this method is * called from the onBackStackChanged method. *///from ww w. j ava 2 s.c o m public void slideForward() { View movingFragmentView = mInfiniteViewPager; PropertyValuesHolder rotateX = PropertyValuesHolder.ofFloat("rotationX", 40f); PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat("scaleX", 1.0f); PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat("scaleY", 1.0f); ObjectAnimator movingFragmentAnimator = ObjectAnimator.ofPropertyValuesHolder(movingFragmentView, rotateX, scaleX, scaleY); ObjectAnimator darkHoverViewAnimator = ObjectAnimator.ofFloat(mDarkHoverView, "alpha", 0.5f, 0.0f); ObjectAnimator movingFragmentRotator = ObjectAnimator.ofFloat(movingFragmentView, "rotationX", 0); movingFragmentRotator.setStartDelay(getResources().getInteger(R.integer.half_slide_up_down_duration)); AnimatorSet s = new AnimatorSet(); s.playTogether(movingFragmentAnimator, movingFragmentRotator, darkHoverViewAnimator); s.setStartDelay(getResources().getInteger(R.integer.slide_up_down_duration)); s.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mIsAnimating = false; } }); s.start(); }
From source file:org.cyanogenmod.designertools.ui.CreditsActivity.java
private void animateContent() { View avatar1 = findViewById(R.id.avatar1); avatar1.setScaleX(0);/*from ww w. j av a 2s .c o m*/ avatar1.setScaleY(0); avatar1.setVisibility(View.VISIBLE); View text1 = findViewById(R.id.text1); text1.setAlpha(0); text1.setVisibility(View.VISIBLE); View avatar2 = findViewById(R.id.avatar2); avatar2.setScaleX(0); avatar2.setScaleY(0); avatar2.setVisibility(View.VISIBLE); View text2 = findViewById(R.id.text2); text2.setAlpha(0); text2.setVisibility(View.VISIBLE); View avatar3 = findViewById(R.id.avatar3); avatar3.setScaleX(0); avatar3.setScaleY(0); avatar3.setVisibility(View.VISIBLE); View text3 = findViewById(R.id.text3); text3.setAlpha(0); text3.setVisibility(View.VISIBLE); View avatar4 = findViewById(R.id.avatar4); avatar4.setScaleX(0); avatar4.setScaleY(0); avatar4.setVisibility(View.VISIBLE); View text4 = findViewById(R.id.text4); text4.setAlpha(0); text4.setVisibility(View.VISIBLE); Interpolator interpolator = new FastOutSlowInInterpolator(); long duration = 375L; long delay = duration / 3; AnimatorSet anim1 = new AnimatorSet(); anim1.play(ObjectAnimator.ofFloat(avatar1, "scaleX", 1f)) .with(ObjectAnimator.ofFloat(avatar1, "scaleY", 1f)) .with(ObjectAnimator.ofFloat(text1, "alpha", 1f)); anim1.setDuration(duration); anim1.setInterpolator(interpolator); AnimatorSet anim2 = new AnimatorSet(); anim2.play(ObjectAnimator.ofFloat(avatar2, "scaleX", 1f)) .with(ObjectAnimator.ofFloat(avatar2, "scaleY", 1f)) .with(ObjectAnimator.ofFloat(text2, "alpha", 1f)); anim2.setDuration(duration); anim2.setInterpolator(interpolator); anim2.setStartDelay(delay); AnimatorSet anim3 = new AnimatorSet(); anim3.play(ObjectAnimator.ofFloat(avatar3, "scaleX", 1f)) .with(ObjectAnimator.ofFloat(avatar3, "scaleY", 1f)) .with(ObjectAnimator.ofFloat(text3, "alpha", 1f)); anim3.setDuration(duration); anim3.setInterpolator(interpolator); anim3.setStartDelay(delay * 2); AnimatorSet anim4 = new AnimatorSet(); anim4.play(ObjectAnimator.ofFloat(avatar4, "scaleX", 1f)) .with(ObjectAnimator.ofFloat(avatar4, "scaleY", 1f)) .with(ObjectAnimator.ofFloat(text4, "alpha", 1f)); anim4.setDuration(duration); anim4.setInterpolator(interpolator); anim4.setStartDelay(delay * 3); AnimatorSet set = new AnimatorSet(); set.play(anim1).with(anim2); set.play(anim2).with(anim3); set.play(anim3).with(anim4); set.start(); }
From source file:com.grepsound.activities.MainActivity.java
/** * This method animates the image fragment into the foreground by both * scaling and rotating the fragment's view, while also removing the * previously added translucent dark hover view. Upon the completion of * this animation, the image fragment regains focus since this method is * called from the onBackStackChanged method. *///from w ww .j a va 2s. com public void slideForward(Animator.AnimatorListener listener) { View movingFragmentView = mMainFrag.getView(); PropertyValuesHolder rotateX = PropertyValuesHolder.ofFloat("rotationX", 40f); PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat("scaleX", 1.0f); PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat("scaleY", 1.0f); ObjectAnimator movingFragmentAnimator = ObjectAnimator.ofPropertyValuesHolder(movingFragmentView, rotateX, scaleX, scaleY); ObjectAnimator darkHoverViewAnimator = ObjectAnimator.ofFloat(mDarkHoverView, "alpha", 0.5f, 0.0f); ObjectAnimator movingFragmentRotator = ObjectAnimator.ofFloat(movingFragmentView, "rotationX", 0); movingFragmentRotator.setStartDelay(getResources().getInteger(R.integer.half_slide_up_down_duration)); AnimatorSet s = new AnimatorSet(); s.playTogether(movingFragmentAnimator, movingFragmentRotator, darkHoverViewAnimator); s.setStartDelay(getResources().getInteger(R.integer.slide_up_down_duration)); s.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mIsAnimating = false; } }); s.start(); }
From source file:eu.davidea.flexibleadapter.FlexibleAnimatorAdapter.java
/** * Animates the view based on the custom animator list built with {@link #getAnimators(View, int, boolean)}. *//*from ww w . j a va 2 s . c o m*/ public final void animateView(final View itemView, int position, boolean isSelected) { //FIXME: first completed visible item on rotation gets high delay // if (DEBUG) // Log.v(TAG, "shouldAnimate=" + shouldAnimate // + " isFastScroll=" + isFastScroll // + " isNotified=" + mAnimatorNotifierObserver.isPositionNotified() // + " isReverseEnabled=" + isReverseEnabled // + (!isReverseEnabled ? " Pos>AniPos=" + (position > mLastAnimatedPosition) : "") // ); if (shouldAnimate && !isFastScroll && !mAnimatorNotifierObserver.isPositionNotified() && (isReverseEnabled || (!isReverseEnabled && position > mLastAnimatedPosition))) { //Cancel animation is necessary when fling cancelExistingAnimation(itemView); //Retrieve user animators List<Animator> animators = getAnimators(itemView, position, isSelected); //Add Alpha animator if not yet ViewCompat.setAlpha(itemView, 0); if (!animatorsUsed.contains(AnimatorEnum.ALPHA)) addAlphaAnimator(animators, itemView, 0f); //Clear animators since the new item might have different animations animatorsUsed.clear(); //Execute the animations all together AnimatorSet set = new AnimatorSet(); set.playTogether(animators); //TODO: Animate with Solution 1 or 2? //set.setStartDelay(calculateAnimationDelay1(position)); set.setStartDelay(calculateAnimationDelay2(position)); set.setInterpolator(mInterpolator); set.setDuration(mDuration); set.addListener(new HelperAnimatorListener(itemView.hashCode())); set.start(); if (DEBUG) Log.v(TAG, "Started Animation on position " + position + " animatorsUsed=" + animatorsUsed); mAnimators.put(itemView.hashCode(), set); } if (mAnimatorNotifierObserver.isPositionNotified()) mAnimatorNotifierObserver.clearNotified(); mLastAnimatedPosition = position; }
From source file:android.support.v17.leanback.app.OnboardingSupportFragment.java
private Animator createAnimator(View view, boolean fadeIn, int slideDirection, long startDelay) { boolean isLtr = getView().getLayoutDirection() == View.LAYOUT_DIRECTION_LTR; boolean slideRight = (isLtr && slideDirection == Gravity.END) || (!isLtr && slideDirection == Gravity.START) || slideDirection == Gravity.RIGHT; Animator fadeAnimator;//from www.j av a 2s . c o m Animator slideAnimator; if (fadeIn) { fadeAnimator = ObjectAnimator.ofFloat(view, View.ALPHA, 0.0f, 1.0f); slideAnimator = ObjectAnimator.ofFloat(view, View.TRANSLATION_X, slideRight ? sSlideDistance : -sSlideDistance, 0); fadeAnimator.setInterpolator(HEADER_APPEAR_INTERPOLATOR); slideAnimator.setInterpolator(HEADER_APPEAR_INTERPOLATOR); } else { fadeAnimator = ObjectAnimator.ofFloat(view, View.ALPHA, 1.0f, 0.0f); slideAnimator = ObjectAnimator.ofFloat(view, View.TRANSLATION_X, 0, slideRight ? sSlideDistance : -sSlideDistance); fadeAnimator.setInterpolator(HEADER_DISAPPEAR_INTERPOLATOR); slideAnimator.setInterpolator(HEADER_DISAPPEAR_INTERPOLATOR); } fadeAnimator.setDuration(HEADER_ANIMATION_DURATION_MS); fadeAnimator.setTarget(view); slideAnimator.setDuration(HEADER_ANIMATION_DURATION_MS); slideAnimator.setTarget(view); AnimatorSet animator = new AnimatorSet(); animator.playTogether(fadeAnimator, slideAnimator); if (startDelay > 0) { animator.setStartDelay(startDelay); } return animator; }
From source file:com.hannesdorfmann.FeedAdapter.java
private void bindDesignerNewsStory(final Story story, final DesignerNewsStoryHolder holder) { holder.title.setText(story.title);//from w ww . jav a 2s . co m holder.itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { CustomTabActivityHelper.openCustomTab(host, DesignerNewsStory.getCustomTabIntent(host, story, null).build(), Uri.parse(story.url)); } }); holder.comments.setText(String.valueOf(story.comment_count)); holder.comments.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View commentsView) { final Intent intent = new Intent(); intent.setClass(host, DesignerNewsStory.class); intent.putExtra(DesignerNewsStory.EXTRA_STORY, story); final ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(host, Pair.create(holder.itemView, host.getString(R.string.transition_story_title_background)), Pair.create(holder.itemView, host.getString(R.string.transition_story_background))); host.startActivity(intent, options.toBundle()); } }); if (pocketIsInstalled) { holder.pocket.setImageAlpha(178); // grumble... no xml setter, grumble... holder.pocket.setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View view) { final ImageButton pocketButton = (ImageButton) view; // actually add to pocket PocketUtils.addToPocket(host, story.url); // setup for anim holder.itemView.setHasTransientState(true); ((ViewGroup) pocketButton.getParent().getParent()).setClipChildren(false); final int initialLeft = pocketButton.getLeft(); final int initialTop = pocketButton.getTop(); final int translatedLeft = (holder.itemView.getWidth() - pocketButton.getWidth()) / 2; final int translatedTop = initialTop - ((holder.itemView.getHeight() - pocketButton.getHeight()) / 2); final ArcMotion arc = new ArcMotion(); // animate the title & pocket icon up, scale the pocket icon up PropertyValuesHolder pvhTitleUp = PropertyValuesHolder.ofFloat(View.TRANSLATION_Y, -(holder.itemView.getHeight() / 5)); PropertyValuesHolder pvhTitleFade = PropertyValuesHolder.ofFloat(View.ALPHA, 0.54f); Animator titleMoveFadeOut = ObjectAnimator.ofPropertyValuesHolder(holder.title, pvhTitleUp, pvhTitleFade); Animator pocketMoveUp = ObjectAnimator.ofFloat(pocketButton, View.TRANSLATION_X, View.TRANSLATION_Y, arc.getPath(initialLeft, initialTop, translatedLeft, translatedTop)); PropertyValuesHolder pvhPocketScaleUpX = PropertyValuesHolder.ofFloat(View.SCALE_X, 3f); PropertyValuesHolder pvhPocketScaleUpY = PropertyValuesHolder.ofFloat(View.SCALE_Y, 3f); Animator pocketScaleUp = ObjectAnimator.ofPropertyValuesHolder(pocketButton, pvhPocketScaleUpX, pvhPocketScaleUpY); ObjectAnimator pocketFadeUp = ObjectAnimator.ofInt(pocketButton, ViewUtils.IMAGE_ALPHA, 255); AnimatorSet up = new AnimatorSet(); up.playTogether(titleMoveFadeOut, pocketMoveUp, pocketScaleUp, pocketFadeUp); up.setDuration(300); up.setInterpolator( AnimationUtils.loadInterpolator(host, android.R.interpolator.fast_out_slow_in)); // animate everything back into place PropertyValuesHolder pvhTitleMoveUp = PropertyValuesHolder.ofFloat(View.TRANSLATION_Y, 0f); PropertyValuesHolder pvhTitleFadeUp = PropertyValuesHolder.ofFloat(View.ALPHA, 1f); Animator titleMoveFadeIn = ObjectAnimator.ofPropertyValuesHolder(holder.title, pvhTitleMoveUp, pvhTitleFadeUp); Animator pocketMoveDown = ObjectAnimator.ofFloat(pocketButton, View.TRANSLATION_X, View.TRANSLATION_Y, arc.getPath(translatedLeft, translatedTop, 0, 0)); PropertyValuesHolder pvhPocketScaleDownX = PropertyValuesHolder.ofFloat(View.SCALE_X, 1f); PropertyValuesHolder pvhPocketScaleDownY = PropertyValuesHolder.ofFloat(View.SCALE_Y, 1f); Animator pvhPocketScaleDown = ObjectAnimator.ofPropertyValuesHolder(pocketButton, pvhPocketScaleDownX, pvhPocketScaleDownY); ObjectAnimator pocketFadeDown = ObjectAnimator.ofInt(pocketButton, ViewUtils.IMAGE_ALPHA, 138); AnimatorSet down = new AnimatorSet(); down.playTogether(titleMoveFadeIn, pocketMoveDown, pvhPocketScaleDown, pocketFadeDown); down.setDuration(300); down.setInterpolator( AnimationUtils.loadInterpolator(host, android.R.interpolator.fast_out_slow_in)); down.setStartDelay(500); // play it AnimatorSet upDown = new AnimatorSet(); upDown.playSequentially(up, down); // clean up upDown.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { ((ViewGroup) pocketButton.getParent().getParent()).setClipChildren(true); holder.itemView.setHasTransientState(false); } }); upDown.start(); } }); } }