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:eu.davidea.flexibleadapter.FlexibleAnimatorAdapter.java
/** * Animates the view based on the custom animator list built with {@link #getAnimators(View, int, boolean)}. *///from w w w. ja v a 2s .c om 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:Main.java
public static void animatePhotoLike(final ImageView likeBg, final ImageView likeIcon) { likeBg.setVisibility(View.VISIBLE); likeIcon.setVisibility(View.VISIBLE); likeBg.setScaleY(0.1f);/*w ww . j av a 2 s .c om*/ likeBg.setScaleX(0.1f); likeBg.setAlpha(1f); likeIcon.setScaleY(0.1f); likeIcon.setScaleX(0.1f); AnimatorSet animatorSet = new AnimatorSet(); ObjectAnimator bgScaleYAnim = ObjectAnimator.ofFloat(likeBg, "scaleY", 0.1f, 1f); bgScaleYAnim.setDuration(200); bgScaleYAnim.setInterpolator(DECCELERATE_INTERPOLATOR); ObjectAnimator bgScaleXAnim = ObjectAnimator.ofFloat(likeBg, "scaleX", 0.1f, 1f); bgScaleXAnim.setDuration(200); bgScaleXAnim.setInterpolator(DECCELERATE_INTERPOLATOR); ObjectAnimator bgAlphaAnim = ObjectAnimator.ofFloat(likeBg, "alpha", 1f, 0f); bgAlphaAnim.setDuration(200); bgAlphaAnim.setStartDelay(150); bgAlphaAnim.setInterpolator(DECCELERATE_INTERPOLATOR); ObjectAnimator imgScaleUpYAnim = ObjectAnimator.ofFloat(likeIcon, "scaleY", 0.1f, 1f); imgScaleUpYAnim.setDuration(300); imgScaleUpYAnim.setInterpolator(DECCELERATE_INTERPOLATOR); ObjectAnimator imgScaleUpXAnim = ObjectAnimator.ofFloat(likeIcon, "scaleX", 0.1f, 1f); imgScaleUpXAnim.setDuration(300); imgScaleUpXAnim.setInterpolator(DECCELERATE_INTERPOLATOR); ObjectAnimator imgScaleDownYAnim = ObjectAnimator.ofFloat(likeIcon, "scaleY", 1f, 0f); imgScaleDownYAnim.setDuration(300); imgScaleDownYAnim.setInterpolator(ACCELERATE_INTERPOLATOR); ObjectAnimator imgScaleDownXAnim = ObjectAnimator.ofFloat(likeIcon, "scaleX", 1f, 0f); imgScaleDownXAnim.setDuration(300); imgScaleDownXAnim.setInterpolator(ACCELERATE_INTERPOLATOR); animatorSet.playTogether(bgScaleYAnim, bgScaleXAnim, bgAlphaAnim, imgScaleUpYAnim, imgScaleUpXAnim); animatorSet.play(imgScaleDownYAnim).with(imgScaleDownXAnim).after(imgScaleUpYAnim); animatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { resetLikeAnimationState(likeBg, likeIcon); } }); animatorSet.start(); }
From source file:com.hamzahrmalik.calculator2.Calculator.java
@Override public void onTextSizeChanged(final TextView textView, float oldSize) { if (mCurrentState != CalculatorState.INPUT) { // Only animate text changes that occur from user input. return;//from w w w. ja va 2 s. c om } // Calculate the values needed to perform the scale and translation // animations, // maintaining the same apparent baseline for the displayed text. final float textScale = oldSize / textView.getTextSize(); final float translationX = (1.0f - textScale) * (textView.getWidth() / 2.0f - textView.getPaddingEnd()); final float translationY = (1.0f - textScale) * (textView.getHeight() / 2.0f - textView.getPaddingBottom()); final AnimatorSet animatorSet = new AnimatorSet(); animatorSet.playTogether(ObjectAnimator.ofFloat(textView, View.SCALE_X, textScale, 1.0f), ObjectAnimator.ofFloat(textView, View.SCALE_Y, textScale, 1.0f), ObjectAnimator.ofFloat(textView, View.TRANSLATION_X, translationX, 0.0f), ObjectAnimator.ofFloat(textView, View.TRANSLATION_Y, translationY, 0.0f)); animatorSet.setDuration(getResources().getInteger(android.R.integer.config_mediumAnimTime)); animatorSet.setInterpolator(new AccelerateDecelerateInterpolator()); animatorSet.start(); }
From source file:com.rukiasoft.androidapps.cocinaconroll.ui.RecipeListRecyclerViewAdapter.java
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) private void flipCard(final View card) { final View front = frontCard; final View back = backCard; final AnimatorSet flipCard = (card.getRotationY() == 0) ? (AnimatorSet) AnimatorInflater.loadAnimator(mContext, R.animator.card_flip_rotate_half) : (AnimatorSet) AnimatorInflater.loadAnimator(mContext, R.animator.card_flip_rotate_full); final AnimatorSet disappear = (AnimatorSet) AnimatorInflater.loadAnimator(mContext, R.animator.view_disappear);//from w ww.j a v a 2 s . c o m //final AnimatorSet flipPositive = (AnimatorSet) AnimatorInflater.loadAnimator(mContext, R.animator.card_flip_rotate_full); final AnimatorSet appear = (AnimatorSet) AnimatorInflater.loadAnimator(mContext, R.animator.view_appear); flipCard.setTarget(card); disappear.setTarget(front); //flipPositive.setTarget(card); appear.setTarget(back); //setLeftIn.setTarget(backView); flipCard.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { disappear.start(); appear.start(); back.setVisibility(View.VISIBLE); back.setAlpha(0); } @Override public void onAnimationEnd(Animator animation) { front.setVisibility(View.INVISIBLE); } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }); flipCard.start(); }
From source file:MainActivity.java
private void zoomFromThumbnail(final ImageView imageViewThumb) { if (mCurrentAnimator != null) { mCurrentAnimator.cancel();//from w w w.j a v a2 s. co m } final Rect startBounds = new Rect(); final Rect finalBounds = new Rect(); final Point globalOffset = new Point(); imageViewThumb.getGlobalVisibleRect(startBounds); findViewById(R.id.frameLayout).getGlobalVisibleRect(finalBounds, globalOffset); mImageViewExpanded .setImageBitmap(loadSampledResource(R.drawable.image, finalBounds.height(), finalBounds.width())); startBounds.offset(-globalOffset.x, -globalOffset.y); finalBounds.offset(-globalOffset.x, -globalOffset.y); float startScale; if ((float) finalBounds.width() / finalBounds.height() > (float) startBounds.width() / startBounds.height()) { startScale = (float) startBounds.height() / finalBounds.height(); float startWidth = startScale * finalBounds.width(); float deltaWidth = (startWidth - startBounds.width()) / 2; startBounds.left -= deltaWidth; startBounds.right += deltaWidth; } else { startScale = (float) startBounds.width() / finalBounds.width(); float startHeight = startScale * finalBounds.height(); float deltaHeight = (startHeight - startBounds.height()) / 2; startBounds.top -= deltaHeight; startBounds.bottom += deltaHeight; } imageViewThumb.setVisibility(View.GONE); mImageViewExpanded.setVisibility(View.VISIBLE); mImageViewExpanded.setPivotX(0f); mImageViewExpanded.setPivotY(0f); AnimatorSet animatorSet = new AnimatorSet(); animatorSet.play(ObjectAnimator.ofFloat(mImageViewExpanded, View.X, startBounds.left, finalBounds.left)) .with(ObjectAnimator.ofFloat(mImageViewExpanded, View.Y, startBounds.top, finalBounds.top)) .with(ObjectAnimator.ofFloat(mImageViewExpanded, View.SCALE_X, startScale, 1f)) .with(ObjectAnimator.ofFloat(mImageViewExpanded, View.SCALE_Y, startScale, 1f)); animatorSet.setDuration(1000); animatorSet.setInterpolator(new AccelerateInterpolator()); animatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mCurrentAnimator = null; } @Override public void onAnimationCancel(Animator animation) { mCurrentAnimator = null; } }); animatorSet.start(); mCurrentAnimator = animatorSet; }
From source file:com.nexus.nsnik.randomno.view.fragments.CoinTossFragment.java
private void animateCoin(Integer integer) { float scale = mResources.getDisplayMetrics().density; mCoinImage.setCameraDistance(8000 * scale); final AnimatorSet coinFlipOut = (AnimatorSet) AnimatorInflater.loadAnimator(getActivity(), R.animator.flip_out);/*from www . jav a 2s .c om*/ final AnimatorSet coinFlipIn = (AnimatorSet) AnimatorInflater.loadAnimator(getActivity(), R.animator.flip_in); final AnimatorSet textFlipOut = (AnimatorSet) AnimatorInflater.loadAnimator(getActivity(), R.animator.flip_out); final AnimatorSet textFlipIn = (AnimatorSet) AnimatorInflater.loadAnimator(getActivity(), R.animator.flip_in); coinFlipOut.setTarget(mCoinImage); coinFlipIn.setTarget(mCoinImage); textFlipIn.setTarget(mCoinText); textFlipOut.setTarget(mCoinText); textFlipOut.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animator) { } @Override public void onAnimationEnd(Animator animator) { setCoinFace(integer); coinFlipIn.start(); textFlipIn.start(); } @Override public void onAnimationCancel(Animator animator) { } @Override public void onAnimationRepeat(Animator animator) { } }); coinFlipOut.start(); textFlipOut.start(); }
From source file:io.vit.vitio.Fragments.Today.TodayFragment.java
private void animateView() { PowerManager powerManager = (PowerManager) getActivity().getSystemService(Context.POWER_SERVICE); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && powerManager.isPowerSaveMode()) { return;/*from w w w .ja v a2s . c o m*/ } //float dimension = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 200, getResources().getDisplayMetrics()); ObjectAnimator objectAnimatorX = ObjectAnimator.ofFloat(ocassionImage, "scaleX", 1f, 0.8f); ObjectAnimator objectAnimatorY = ObjectAnimator.ofFloat(ocassionImage, "scaleY", 1f, 0.8f); objectAnimatorX.setDuration(6000); objectAnimatorY.setDuration(6000); AnimatorSet animatorSet = new AnimatorSet(); animatorSet.playTogether(objectAnimatorX, objectAnimatorY); animatorSet.setInterpolator(new LinearInterpolator()); objectAnimatorX.setRepeatCount(ObjectAnimator.INFINITE); objectAnimatorX.setRepeatMode(ObjectAnimator.REVERSE); objectAnimatorY.setRepeatCount(ObjectAnimator.INFINITE); objectAnimatorY.setRepeatMode(ObjectAnimator.REVERSE); animatorSet.start(); objectAnimatorX.start(); }
From source file:com.ferdi2005.secondgram.AndroidUtilities.java
public static void shakeView(final View view, final float x, final int num) { if (num == 6) { view.setTranslationX(0);/*from w w w . j av a 2s . com*/ return; } AnimatorSet animatorSet = new AnimatorSet(); animatorSet.playTogether(ObjectAnimator.ofFloat(view, "translationX", AndroidUtilities.dp(x))); animatorSet.setDuration(50); animatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { shakeView(view, num == 5 ? 0 : -x, num + 1); } }); animatorSet.start(); }
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 w w w.ja v a2 s.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:im.ene.ribbon.FixedActionTabView.java
@Override protected void onStatusChanged(final boolean expanded, final int size, final boolean animate) { if (!animate) { updateLayoutOnAnimation(1, expanded); setIconTranslation(expanded ? 0 : (paddingTopInactive - paddingTopActive)); return;//from www. j a v a2 s . c o m } final AnimatorSet set = new AnimatorSet(); set.setDuration(animationDuration); set.setInterpolator(interpolator); final ValueAnimator textScaleAnimator = ObjectAnimator.ofFloat(this, "textScale", expanded ? TEXT_SCALE_ACTIVE : 1); textScaleAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(final ValueAnimator animation) { final float fraction = animation.getAnimatedFraction(); updateLayoutOnAnimation(fraction, expanded); } }); final ValueAnimator iconTranslationAnimator = ObjectAnimator.ofFloat(this, "iconTranslation", expanded ? 0 : (paddingTopInactive - paddingTopActive)); set.playTogether(textScaleAnimator, iconTranslationAnimator); set.start(); }