List of usage examples for android.animation ObjectAnimator setDuration
@Override @NonNull public ObjectAnimator setDuration(long duration)
From source file:com.gitstudy.rili.liarbry.CalendarLayout.java
/** * ??/*from w w w .j av a 2 s .c om*/ */ final void initStatus() { if (mContentView == null) { return; } if ((mDefaultStatus == STATUS_SHRINK || mCalendarShowMode == CALENDAR_SHOW_MODE_ONLY_WEEK_VIEW) && mCalendarShowMode != CALENDAR_SHOW_MODE_ONLY_MONTH_VIEW) { post(new Runnable() { @Override public void run() { ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(mContentView, "translationY", mContentView.getTranslationY(), -mContentViewTranslateY); objectAnimator.setDuration(0); objectAnimator.addUpdateListener(new AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { float currentValue = (Float) animation.getAnimatedValue(); float percent = currentValue * 1.0f / mContentViewTranslateY; mMonthView.setTranslationY(mViewPagerTranslateY * percent); isAnimating = true; } }); objectAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); isAnimating = false; showWeek(); } }); objectAnimator.start(); } }); } else { if (mDelegate.mViewChangeListener == null) { return; } post(new Runnable() { @Override public void run() { mDelegate.mViewChangeListener.onViewChange(true); } }); } }
From source file:com.sinyuk.jianyimaterial.widgets.FloatingToolbar.java
private void showDefaultImpl() { int rootWidth = mRoot.getWidth(); setScaleX(0f);/*from w ww. ja v a 2 s . c o m*/ float endFabX; if (mFabOriginalX > rootWidth / 2f) { endFabX = rootWidth / 2f + (mFabOriginalX - rootWidth / 2f) / 4f; } else { endFabX = rootWidth / 2f - (mFabOriginalX - rootWidth / 2f) / 4f; } if (mFab != null) { PropertyValuesHolder xProperty = PropertyValuesHolder.ofFloat(X, endFabX); PropertyValuesHolder yProperty = PropertyValuesHolder.ofFloat(Y, mFabOriginalY * 1.05f); PropertyValuesHolder scaleXProperty = PropertyValuesHolder.ofFloat(SCALE_X, 0); PropertyValuesHolder scaleYProperty = PropertyValuesHolder.ofFloat(SCALE_Y, 0); ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(mFab, xProperty, yProperty, scaleXProperty, scaleYProperty); animator.setDuration(FAB_MORPH_DURATION); animator.setInterpolator(new AccelerateInterpolator()); animator.start(); } ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(this, "scaleX", 1f); objectAnimator.setDuration(CIRCULAR_REVEAL_DURATION); objectAnimator.setStartDelay(CIRCULAR_REVEAL_DELAY); objectAnimator.setInterpolator(new AccelerateDecelerateInterpolator()); objectAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { super.onAnimationStart(animation); setVisibility(View.VISIBLE); mFab.setVisibility(View.INVISIBLE); } @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); mMorphing = false; } }); objectAnimator.start(); }
From source file:com.sinyuk.jianyimaterial.widgets.FloatingToolbar.java
@TargetApi(21) private void hideLollipopImpl() { int rootWidth = mRoot.getWidth(); float controlX; if (mFabOriginalX > rootWidth / 2f) { controlX = mFabOriginalX * 0.98f; } else {/*from w w w .j a va 2 s . c o m*/ controlX = mFabOriginalX * 1.02f; } final Path path = new Path(); path.moveTo(mFab.getX(), mFab.getY()); final float x2 = controlX; final float y2 = getY(); path.quadTo(x2, y2, mFabOriginalX, mFabOriginalY + getTranslationY()); ObjectAnimator anim = ObjectAnimator.ofFloat(mFab, View.X, View.Y, path); anim.setInterpolator(new AccelerateDecelerateInterpolator()); anim.setDuration(FAB_UNMORPH_DURATION); anim.setStartDelay(FAB_UNMORPH_DELAY); anim.start(); /** * Animate FAB elevation back to 6dp */ anim = ObjectAnimator.ofFloat(mFab, View.TRANSLATION_Z, 0); anim.setInterpolator(new AccelerateDecelerateInterpolator()); anim.setDuration(FAB_UNMORPH_DURATION); anim.setStartDelay(FAB_UNMORPH_DELAY); anim.start(); /** * Restore alpha of FAB drawable */ Drawable drawable = mFab.getDrawable(); if (drawable != null) { anim = ObjectAnimator.ofPropertyValuesHolder(drawable, PropertyValuesHolder.ofInt("alpha", 255)); anim.setInterpolator(new AccelerateDecelerateInterpolator()); anim.setDuration(FAB_UNMORPH_DURATION); anim.setStartDelay(FAB_UNMORPH_DELAY); anim.start(); } Animator toolbarReveal = ViewAnimationUtils.createCircularReveal(this, getWidth() / 2, getHeight() / 2, (float) (Math.hypot(getWidth() / 2, getHeight() / 2)), (float) mFab.getWidth() / 2f); toolbarReveal.setTarget(this); toolbarReveal.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); setVisibility(View.INVISIBLE); mFab.setVisibility(View.VISIBLE); mMorphing = false; } }); toolbarReveal.setDuration(CIRCULAR_UNREVEAL_DURATION); toolbarReveal.setInterpolator(new AccelerateInterpolator()); toolbarReveal.setStartDelay(CIRCULAR_UNREVEAL_DELAY); toolbarReveal.start(); /** * Animate FloatingToolbar animation back to 6dp */ anim = ObjectAnimator.ofFloat(this, View.TRANSLATION_Z, 0); anim.setDuration(CIRCULAR_UNREVEAL_DURATION); anim.setStartDelay(CIRCULAR_UNREVEAL_DELAY); anim.start(); }
From source file:com.sinyuk.jianyimaterial.widgets.FloatingToolbar.java
@TargetApi(21) private void showLollipopImpl() { int rootWidth = mRoot.getWidth(); float endFabX; float controlX; if (mFabOriginalX > rootWidth / 2f) { endFabX = rootWidth / 2f + (mFabOriginalX - rootWidth / 2f) / 4f; controlX = mFabOriginalX * 0.98f; } else {//from ww w. ja v a 2 s.co m endFabX = rootWidth / 2f - (mFabOriginalX - rootWidth / 2f) / 4f; controlX = mFabOriginalX * 1.02f; } /** * Animate FAB movement */ final Path path = new Path(); path.moveTo(mFab.getX(), mFab.getY()); final float x2 = controlX; final float y2 = getY(); path.quadTo(x2, y2, endFabX, getY()); ObjectAnimator anim = ObjectAnimator.ofFloat(mFab, View.X, View.Y, path); anim.setInterpolator(new AccelerateDecelerateInterpolator()); anim.setDuration(FAB_MORPH_DURATION); anim.start(); /** * Fade FAB drawable */ Drawable drawable = mFab.getDrawable(); if (drawable != null) { anim = ObjectAnimator.ofPropertyValuesHolder(drawable, PropertyValuesHolder.ofInt("alpha", 0)); anim.setInterpolator(new AccelerateDecelerateInterpolator()); anim.setDuration((long) (FAB_MORPH_DURATION / 3f)); anim.start(); } /** * Animate FAB elevation to 8dp */ anim = ObjectAnimator.ofFloat(mFab, View.TRANSLATION_Z, dpToPixels(2)); anim.setInterpolator(new AccelerateDecelerateInterpolator()); anim.setDuration(FAB_MORPH_DURATION); anim.start(); /** * Create circular reveal */ Animator toolbarReveal = ViewAnimationUtils.createCircularReveal(this, getWidth() / 2, getHeight() / 2, (float) mFab.getWidth() / 2f, (float) (Math.hypot(getWidth() / 2, getHeight() / 2))); toolbarReveal.setDuration(CIRCULAR_REVEAL_DURATION); toolbarReveal.setTarget(this); toolbarReveal.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { super.onAnimationStart(animation); mFab.setVisibility(View.INVISIBLE); setVisibility(View.VISIBLE); } @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); mMorphing = false; } }); toolbarReveal.setInterpolator(new AccelerateInterpolator()); toolbarReveal.setStartDelay(CIRCULAR_REVEAL_DELAY); toolbarReveal.start(); /** * Animate FloatingToolbar elevation to 8dp */ anim = ObjectAnimator.ofFloat(this, View.TRANSLATION_Z, dpToPixels(2)); anim.setDuration(CIRCULAR_REVEAL_DURATION); anim.setStartDelay(CIRCULAR_REVEAL_DELAY); anim.start(); }
From source file:io.github.douglasjunior.androidSimpleTooltip.SimpleTooltip.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) private synchronized void startFloatingAnimation() { final String property = mGravity == Gravity.TOP || mGravity == Gravity.BOTTOM ? "translationY" : "translationX"; final ObjectAnimator anim1 = ObjectAnimator.ofFloat(mContentLayout, property, -mAnimationPadding, mAnimationPadding);/*from w w w . java2 s. co m*/ anim1.setDuration(mAnimationDuration); anim1.setInterpolator(new AccelerateDecelerateInterpolator()); final ObjectAnimator anim2 = ObjectAnimator.ofFloat(mContentLayout, property, mAnimationPadding, -mAnimationPadding); anim2.setDuration(mAnimationDuration); anim2.setInterpolator(new AccelerateDecelerateInterpolator()); AnimatorSet set = new AnimatorSet(); set.playSequentially(anim1, anim2); set.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { if (isShowing()) { animation.start(); } } }); mAnimator = set; mAnimator.start(); }
From source file:com.luanthanhthai.android.liteworkouttimer.TimerFragment.java
/** * Property Animation/*from w w w .j a v a2 s .c om*/ * Animation for timer text slide to center */ public void animSlideClockToCenter() { timerClockView.animate().setDuration(animTimerDuration); if (getOrientation() == Configuration.ORIENTATION_PORTRAIT) { timerClockView.animate().y(yCenterValue); } else { ObjectAnimator scaleUpY = ObjectAnimator.ofFloat(timerClockView, "scaleY", 1.5f); ObjectAnimator scaleUpX = ObjectAnimator.ofFloat(timerClockView, "scaleX", 1.5f); scaleUpY.setDuration(animTimerDuration); scaleUpX.setDuration(animTimerDuration); AnimatorSet scaleUp = new AnimatorSet(); scaleUp.play(scaleUpX).with(scaleUpY); timerClockView.animate().y(yCenterValue); scaleUp.start(); } }
From source file:com.luanthanhthai.android.liteworkouttimer.TimerFragment.java
/** * Property Animation/* w ww. j a v a2 s.c o m*/ * Animation for timer clock slide up to original position */ public void animSlideClockUp() { timerClockView.animate().setDuration(animTimerDuration); if (getOrientation() == Configuration.ORIENTATION_PORTRAIT) { timerClockView.animate().y(yOriginalValue); } else { ObjectAnimator scaleDownY = ObjectAnimator.ofFloat(timerClockView, "scaleY", 1f); ObjectAnimator scaleDownX = ObjectAnimator.ofFloat(timerClockView, "scaleX", 1f); scaleDownY.setDuration(animTimerDuration); scaleDownX.setDuration(animTimerDuration); AnimatorSet scaleDown = new AnimatorSet(); scaleDown.play(scaleDownX).with(scaleDownY); timerClockView.animate().y(yOriginalValue); scaleDown.start(); } }
From source file:com.android.tv.settings.dialog.SettingsLayoutFragment.java
private void fadeIn(View v) { ObjectAnimator alphaAnimator = ObjectAnimator.ofFloat(v, "alpha", FADE_IN_ALPHA_START, FADE_IN_ALPHA_FINISH);/*from ww w. j a v a 2s .com*/ alphaAnimator .setDuration(v.getContext().getResources().getInteger(android.R.integer.config_mediumAnimTime)); alphaAnimator.start(); }
From source file:com.android.tv.settings.dialog.SettingsLayoutFragment.java
private void performEntryTransition() { final View dialogView = getView(); final View contentView = (View) dialogView.getTag(R.id.content_fragment); final View actionContainerView = dialogView.findViewById(R.id.action_fragment); mIntroAnimationInProgress = true;/*from ww w.j a v a2 s . co m*/ // Fade out the old activity. getActivity().overridePendingTransition(0, R.anim.lb_dialog_fade_out); int bgColor = contentView.getContext().getResources().getColor(R.color.lb_dialog_activity_background); final ColorDrawable bgDrawable = new ColorDrawable(); bgDrawable.setColor(bgColor); bgDrawable.setAlpha(0); dialogView.setBackground(bgDrawable); dialogView.setVisibility(View.INVISIBLE); // We need to defer the remainder of the animation preparation until the first layout has // occurred, as we don't yet know the final location of the icon. contentView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { contentView.getViewTreeObserver().removeOnGlobalLayoutListener(this); // if we buildLayer() at this time, the texture is // actually not created delay a little so we can make // sure all hardware layer is created before animation, // in that way we can avoid the jittering of start // animation contentView.postOnAnimationDelayed(mEntryAnimationRunnable, mAnimateDelay); } Runnable mEntryAnimationRunnable = new Runnable() { @Override public void run() { if (!isAdded()) { // We have been detached before this could run, so just bail. return; } dialogView.setVisibility(View.VISIBLE); // Fade in the activity background protection ObjectAnimator oa = ObjectAnimator.ofInt(bgDrawable, "alpha", 255); oa.setDuration(mAnimateInDuration); oa.setStartDelay(mSecondaryAnimateDelay); oa.setInterpolator(new DecelerateInterpolator(1.0f)); oa.start(); boolean isRtl = ViewCompat.getLayoutDirection(contentView) == View.LAYOUT_DIRECTION_RTL; int startDist = isRtl ? mSlideInDistance : -mSlideInDistance; int endDist = isRtl ? -actionContainerView.getMeasuredWidth() : actionContainerView.getMeasuredWidth(); // Fade in and slide in the ContentFragment TextViews from the start. prepareAndAnimateView((View) contentView.getTag(R.id.title), startDist, false); prepareAndAnimateView((View) contentView.getTag(R.id.breadcrumb), startDist, false); prepareAndAnimateView((View) contentView.getTag(R.id.description), startDist, false); // Fade in and slide in the ActionFragment from the end. prepareAndAnimateView(actionContainerView, endDist, false); prepareAndAnimateView((View) contentView.getTag(R.id.icon), startDist, true); } }; }); }
From source file:com.yekertech.tvbarsetting.dialog.SettingsLayoutFragment.java
private void performEntryTransition() { final View dialogView = getView(); final View contentView = (View) dialogView.getTag(R.id.content_fragment); final View actionContainerView = dialogView.findViewById(R.id.action_fragment); mIntroAnimationInProgress = true;//from w w w . jav a2 s .c o m // Fade out the old activity. getActivity().overridePendingTransition(0, R.anim.lb_dialog_fade_out); int bgColor = contentView.getContext().getColor(R.color.lb_dialog_activity_background); final ColorDrawable bgDrawable = new ColorDrawable(); bgDrawable.setColor(bgColor); bgDrawable.setAlpha(0); dialogView.setBackground(bgDrawable); dialogView.setVisibility(View.INVISIBLE); // We need to defer the remainder of the animation preparation until the first layout has // occurred, as we don't yet know the final location of the icon. contentView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { contentView.getViewTreeObserver().removeOnGlobalLayoutListener(this); // if we buildLayer() at this time, the texture is // actually not created delay a little so we can make // sure all hardware layer is created before animation, // in that way we can avoid the jittering of start // animation contentView.postOnAnimationDelayed(mEntryAnimationRunnable, mAnimateDelay); } final Runnable mEntryAnimationRunnable = new Runnable() { @Override public void run() { if (!isAdded()) { // We have been detached before this could run, so just bail. return; } dialogView.setVisibility(View.VISIBLE); // Fade in the activity background protection ObjectAnimator oa = ObjectAnimator.ofInt(bgDrawable, "alpha", 255); oa.setDuration(mAnimateInDuration); oa.setStartDelay(mSecondaryAnimateDelay); oa.setInterpolator(new DecelerateInterpolator(1.0f)); oa.start(); boolean isRtl = ViewCompat.getLayoutDirection(contentView) == ViewCompat.LAYOUT_DIRECTION_RTL; int startDist = isRtl ? mSlideInDistance : -mSlideInDistance; int endDist = isRtl ? -actionContainerView.getMeasuredWidth() : actionContainerView.getMeasuredWidth(); // Fade in and slide in the ContentFragment TextViews from the start. prepareAndAnimateView((View) contentView.getTag(R.id.title), startDist, false); prepareAndAnimateView((View) contentView.getTag(R.id.breadcrumb), startDist, false); prepareAndAnimateView((View) contentView.getTag(R.id.description), startDist, false); // Fade in and slide in the ActionFragment from the end. prepareAndAnimateView(actionContainerView, endDist, false); prepareAndAnimateView((View) contentView.getTag(R.id.icon), startDist, true); } }; }); }