List of usage examples for android.animation ObjectAnimator setDuration
@Override @NonNull public ObjectAnimator setDuration(long duration)
From source file:com.boko.vimusic.ui.activities.AudioPlayerActivity.java
/** * @param v/*from w ww.j a v a 2 s.c o m*/ * The view to animate * @param alpha * The alpha to apply */ private void fade(final View v, final float alpha) { final ObjectAnimator fade = ObjectAnimator.ofFloat(v, "alpha", alpha); fade.setInterpolator( AnimationUtils.loadInterpolator(this, android.R.anim.accelerate_decelerate_interpolator)); fade.setDuration(400); fade.start(); }
From source file:com.android.clear.reminder.ItemAnimator.java
@Override public boolean animateMove(final ViewHolder holder, int fromX, int fromY, int toX, int toY) { endAnimation(holder);/*from w w w .j a va 2s .c o m*/ final int deltaX = toX - fromX; final int deltaY = toY - fromY; final long moveDuration = getMoveDuration(); if (deltaX == 0 && deltaY == 0) { dispatchMoveFinished(holder); return false; } final View view = holder.itemView; final float prevTranslationX = view.getTranslationX(); final float prevTranslationY = view.getTranslationY(); view.setTranslationX(-deltaX); view.setTranslationY(-deltaY); final ObjectAnimator moveAnimator; if (deltaX != 0 && deltaY != 0) { final PropertyValuesHolder moveX = PropertyValuesHolder.ofFloat(TRANSLATION_X, 0f); final PropertyValuesHolder moveY = PropertyValuesHolder.ofFloat(TRANSLATION_Y, 0f); moveAnimator = ObjectAnimator.ofPropertyValuesHolder(holder.itemView, moveX, moveY); } else if (deltaX != 0) { final PropertyValuesHolder moveX = PropertyValuesHolder.ofFloat(TRANSLATION_X, 0f); moveAnimator = ObjectAnimator.ofPropertyValuesHolder(holder.itemView, moveX); } else { final PropertyValuesHolder moveY = PropertyValuesHolder.ofFloat(TRANSLATION_Y, 0f); moveAnimator = ObjectAnimator.ofPropertyValuesHolder(holder.itemView, moveY); } moveAnimator.setDuration(moveDuration); moveAnimator.setInterpolator(AnimatorUtils.INTERPOLATOR_FAST_OUT_SLOW_IN); moveAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animator) { dispatchMoveStarting(holder); } @Override public void onAnimationEnd(Animator animator) { animator.removeAllListeners(); mAnimators.remove(holder); view.setTranslationX(prevTranslationX); view.setTranslationY(prevTranslationY); dispatchMoveFinished(holder); } }); mMoveAnimatorsList.add(moveAnimator); mAnimators.put(holder, moveAnimator); return true; }
From source file:com.sysdata.widget.accordion.ItemAnimator.java
@Override public boolean animateMove(final ViewHolder holder, int fromX, int fromY, int toX, int toY) { endAnimation(holder);/*from w w w . ja va2 s . c om*/ final int deltaX = toX - fromX; final int deltaY = toY - fromY; final long moveDuration = getMoveDuration(); if (deltaX == 0 && deltaY == 0) { dispatchMoveFinished(holder); return false; } final View view = holder.itemView; final float prevTranslationX = view.getTranslationX(); final float prevTranslationY = view.getTranslationY(); view.setTranslationX(-deltaX); view.setTranslationY(-deltaY); final ObjectAnimator moveAnimator; if (deltaX != 0 && deltaY != 0) { final PropertyValuesHolder moveX = PropertyValuesHolder.ofFloat(TRANSLATION_X, 0f); final PropertyValuesHolder moveY = PropertyValuesHolder.ofFloat(TRANSLATION_Y, 0f); moveAnimator = ObjectAnimator.ofPropertyValuesHolder(holder.itemView, moveX, moveY); } else if (deltaX != 0) { final PropertyValuesHolder moveX = PropertyValuesHolder.ofFloat(TRANSLATION_X, 0f); moveAnimator = ObjectAnimator.ofPropertyValuesHolder(holder.itemView, moveX); } else { final PropertyValuesHolder moveY = PropertyValuesHolder.ofFloat(TRANSLATION_Y, 0f); moveAnimator = ObjectAnimator.ofPropertyValuesHolder(holder.itemView, moveY); } moveAnimator.setDuration(moveDuration); moveAnimator.setInterpolator(new FastOutSlowInInterpolator()); moveAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animator) { dispatchMoveStarting(holder); } @Override public void onAnimationEnd(Animator animator) { animator.removeAllListeners(); mAnimators.remove(holder); view.setTranslationX(prevTranslationX); view.setTranslationY(prevTranslationY); dispatchMoveFinished(holder); } }); mMoveAnimatorsList.add(moveAnimator); mAnimators.put(holder, moveAnimator); return true; }
From source file:com.itsronald.widget.IndicatorDotPathView.java
/** * Animation: fill out the connecting center dot path to form a straight path between the two * dots./*ww w . j a v a2 s.c om*/ * * @return An animator that grows pathCenter to the appropriate height. */ @NonNull private Animator centerSegmentGrowAnimator() { final float fromScale = 0f, toScale = 1f; final ObjectAnimator growAnimator; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { final PropertyValuesHolder scaleYProperty = PropertyValuesHolder.ofFloat(View.SCALE_Y, fromScale, toScale); growAnimator = ObjectAnimator.ofPropertyValuesHolder(centerSegment, scaleYProperty); } else { growAnimator = ObjectAnimator.ofFloat(centerSegment, "scaleY", fromScale, toScale); } // Start growing when the two ends of the path meet in the middle. final long animationDuration = PATH_STRETCH_ANIM_DURATION / 4; growAnimator.setStartDelay(animationDuration); growAnimator.setDuration(animationDuration); growAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { super.onAnimationStart(animation); centerSegment.setVisibility(VISIBLE); } }); return growAnimator; }
From source file:com.nihaskalam.progressbuttonlibrary.CircularProgressButton.java
private void animateIdleStateButtonAfterClick() { int textColorChangeDuration = 10; ObjectAnimator colorAnim = ObjectAnimator.ofInt(this, "textColor", getNormalColor(this.getTextColors()), mIdleStateTextColorAfterClick); colorAnim.setDuration(textColorChangeDuration); colorAnim.setEvaluator(new ArgbEvaluator()); colorAnim.start();/* w w w . j ava2 s .c o m*/ ObjectAnimator colorAnim1 = ObjectAnimator.ofInt(this, "textColor", mIdleStateTextColorAfterClick, getNormalColor(this.getTextColors())); colorAnim1.setDuration(0); colorAnim1.setStartDelay(IDLE_STATE_ANIMATION_DURATION_AFTER_CLICK - textColorChangeDuration); colorAnim1.setEvaluator(new ArgbEvaluator()); colorAnim1.setInterpolator(new BounceInterpolator()); colorAnim1.start(); ObjectAnimator bgAnim = ObjectAnimator.ofInt(this, "backgroundColor", getNormalColor(mIdleColorState), mIdleStateBackgroundColorAfterClick); bgAnim.setDuration(0); bgAnim.setEvaluator(new ArgbEvaluator()); bgAnim.start(); int textSizeAnimationDuration = 150; ValueAnimator animator = ValueAnimator.ofFloat(textSize, textSize - textSize / 4); animator.setDuration(textSizeAnimationDuration); animator.setRepeatCount(1); animator.setRepeatMode(ValueAnimator.REVERSE); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { float animatedValue = (float) valueAnimator.getAnimatedValue(); setTextSize(animatedValue); } }); animator.start(); }
From source file:com.box.myview.MyTopSnackBar.TSnackbar.java
/** * @param drawable/* w w w . j a v a 2 s. c o m*/ * @param left * @param right * @return */ public TSnackbar addIconProgressLoading(Drawable drawable, boolean left, boolean right) { final ObjectAnimator animator = ObjectAnimator.ofInt(drawable, "level", 0, 10000); animator.setDuration(1000); animator.setInterpolator(new LinearInterpolator()); animator.setRepeatCount(ValueAnimator.INFINITE); animator.setRepeatMode(ValueAnimator.INFINITE); mView.setBackgroundColor(mContext.getResources().getColor(Prompt.SUCCESS.getBackgroundColor())); if (left) { mView.getMessageView().setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null); } if (right) { mView.getMessageView().setCompoundDrawablesWithIntrinsicBounds(null, null, drawable, null); } animator.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { if (mCallback != null) { mCallback.onShown(TSnackbar.this); } SnackbarManager.getInstance().onShown(mManagerCallback); } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }); animator.start(); return this; }
From source file:com.adityarathi.muo.ui.activities.NowPlayingActivity.java
/** * Smoothly scrolls the seekbar to the indicated position. *//*w w w . j av a 2 s. c om*/ private void smoothScrollSeekbar(int progress) { ObjectAnimator animation = ObjectAnimator.ofInt(mSeekbar, "progress", progress); animation.setDuration(200); animation.setInterpolator(new DecelerateInterpolator()); animation.start(); }
From source file:org.namelessrom.devicecontrol.modules.appmanager.BaseAppListFragment.java
public void loadApps(final boolean animate) { if (mIsLoading) { return;//from w w w . ja va 2s . c o m } mIsLoading = true; mProgressContainer.post(new Runnable() { @Override public void run() { mProgressContainer.setVisibility(View.VISIBLE); if (animate) { final ObjectAnimator anim = ObjectAnimator.ofFloat(mProgressContainer, "alpha", 0f, 1f); anim.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { new LoadApps().execute(); } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }); anim.setDuration(ANIM_DURATION); anim.start(); } else { mProgressContainer.setAlpha(1f); new LoadApps().execute(); } } }); }
From source file:com.serenegiant.aceparrot.BaseFragment.java
/** * 01??(View)??/*from ww w . j av a 2s. c o m*/ * @param target * @param startDelay */ @SuppressLint("NewApi") protected final void fadeIn(final View target, final long duration, final long startDelay) { // if (DEBUG) Log.v(TAG, "fadeIn:target=" + target); if (target == null) return; target.clearAnimation(); target.setVisibility(View.VISIBLE); target.setTag(R.id.anim_type, ANIM_FADE_IN); // ??? target.setScaleX(1.0f); target.setScaleY(1.0f); target.setAlpha(0.0f); final ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(target, "alpha", 0f, 1f); objectAnimator.addListener(mAnimatorListener); if (BuildCheck.isJellyBeanMR2()) objectAnimator.setAutoCancel(true); // API >= 18 ??????Animator???? objectAnimator.setDuration(duration > 0 ? duration : 500); // 0.5??? objectAnimator.setStartDelay(startDelay > 0 ? startDelay : 0); // ??? objectAnimator.start(); // }
From source file:io.plaidapp.core.ui.FeedAdapter.java
private void bindDribbbleShotHolder(final Shot shot, final DribbbleShotHolder holder, int position) { final Images.ImageSize imageSize = shot.getImages().bestSize(); GlideApp.with(host).load(shot.getImages().best()).listener(new RequestListener<Drawable>() { @Override//from w ww. j a v a 2 s . co m public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) { if (!shot.getHasFadedIn()) { holder.image.setHasTransientState(true); final ObservableColorMatrix cm = new ObservableColorMatrix(); final ObjectAnimator saturation = ObjectAnimator.ofFloat(cm, ObservableColorMatrix.SATURATION, 0f, 1f); saturation.addUpdateListener(valueAnimator -> { // just animating the color matrix does not invalidate the // drawable so need this update listener. Also have to create a // new CMCF as the matrix is immutable :( holder.image.setColorFilter(new ColorMatrixColorFilter(cm)); }); saturation.setDuration(2000L); saturation.setInterpolator(getFastOutSlowInInterpolator(host)); saturation.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { holder.image.clearColorFilter(); holder.image.setHasTransientState(false); } }); saturation.start(); shot.setHasFadedIn(true); } return false; } @Override public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) { return false; } }).placeholder(shotLoadingPlaceholders[position % shotLoadingPlaceholders.length]) .diskCacheStrategy(DiskCacheStrategy.DATA).fitCenter() .transition(DrawableTransitionOptions.withCrossFade()) .override(imageSize.getWidth(), imageSize.getHeight()) .into(new DribbbleTarget(holder.image, false)); // need both placeholder & background to prevent seeing through shot as it fades in holder.image.setBackground(shotLoadingPlaceholders[position % shotLoadingPlaceholders.length]); holder.image.setDrawBadge(shot.getAnimated()); // need a unique transition name per shot, let's use it's url holder.image.setTransitionName(shot.getHtmlUrl()); shotPreloadSizeProvider.setView(holder.image); }