List of usage examples for android.animation ObjectAnimator setStartDelay
@Override public void setStartDelay(long startDelay)
From source file:ch.gianulli.flashcards.ui.Flashcard.java
private void expandButtonBar() { mButtonBarShowing = true;//from ww w.j a v a 2 s. c om mButtonBar.setVisibility(View.VISIBLE); mButtonBar.setAlpha(0.0f); final int startingHeight = mCardView.getHeight(); final ViewTreeObserver observer = mCardView.getViewTreeObserver(); observer.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { @Override public boolean onPreDraw() { // We don't want to continue getting called for every listview drawing. if (observer.isAlive()) { observer.removeOnPreDrawListener(this); } final int endingHeight = mCardView.getHeight(); final int distance = endingHeight - startingHeight; mCardView.getLayoutParams().height = startingHeight; mCardView.requestLayout(); ValueAnimator heightAnimator = ValueAnimator.ofFloat(0f, 1f).setDuration(300); heightAnimator.setInterpolator(new DecelerateInterpolator()); heightAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animator) { Float value = (Float) animator.getAnimatedValue(); mCardView.getLayoutParams().height = (int) (value * distance + startingHeight); mCardView.requestLayout(); } }); heightAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mCardView.getLayoutParams().height = ViewGroup.LayoutParams.WRAP_CONTENT; } }); mButtonBar.setLayerType(View.LAYER_TYPE_HARDWARE, null); ObjectAnimator alphaAnimator = ObjectAnimator.ofFloat(mButtonBar, "alpha", 0.0f, 1.0f); alphaAnimator.setInterpolator(new DecelerateInterpolator()); alphaAnimator.setDuration(300); alphaAnimator.setStartDelay(100); AnimatorSet set = new AnimatorSet(); set.playTogether(heightAnimator, alphaAnimator); set.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mButtonBar.setLayerType(View.LAYER_TYPE_SOFTWARE, null); } }); set.start(); return false; } }); }
From source file:com.waz.zclient.ui.cursor.CursorLayout.java
private ObjectAnimator getShowToolbarAnimator(View view, float fromValue, float toValue) { ObjectAnimator animator = ObjectAnimator.ofFloat(view, View.TRANSLATION_Y, fromValue, toValue); animator.setDuration(cursorToolbarAnimationDuration); animator.setStartDelay(getResources().getInteger(R.integer.animation_delay_short)); animator.setInterpolator(new Expo.EaseOut()); return animator; }
From source file:com.waz.zclient.views.menus.ConfirmationMenu.java
public void animateToShow(boolean show) { if (show) {// w w w. j a v a 2 s .c o m confirmed = false; cancelled = false; // Init views and post animations to get measured height of message container backgroundView.setAlpha(0); messageContainerView.setVisibility(INVISIBLE); setVisibility(VISIBLE); messageContainerView.post(new Runnable() { @Override public void run() { ObjectAnimator showBackgroundAnimator = ObjectAnimator.ofFloat(backgroundView, View.ALPHA, 0, 1); showBackgroundAnimator.setInterpolator(new Quart.EaseOut()); showBackgroundAnimator .setDuration(getResources().getInteger(R.integer.framework_animation_duration_short)); ObjectAnimator showMessageAnimator = ObjectAnimator.ofFloat(messageContainerView, View.TRANSLATION_Y, messageContainerView.getMeasuredHeight(), 0); showMessageAnimator.setInterpolator(new Expo.EaseOut()); showMessageAnimator .setDuration(getResources().getInteger(R.integer.framework_animation_duration_medium)); showMessageAnimator.setStartDelay(getResources() .getInteger(R.integer.framework_animation__confirmation_menu__show_message_delay)); showMessageAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { messageContainerView.setVisibility(VISIBLE); } }); AnimatorSet showSet = new AnimatorSet(); showSet.playTogether(showBackgroundAnimator, showMessageAnimator); showSet.setDuration(getResources() .getInteger(R.integer.background_accent_color_transition_animation_duration)); showSet.start(); } }); } else { ObjectAnimator hideBackgroundAnimator = ObjectAnimator.ofFloat(backgroundView, View.ALPHA, 1, 0); hideBackgroundAnimator.setInterpolator(new Quart.EaseOut()); hideBackgroundAnimator .setDuration(getResources().getInteger(R.integer.framework_animation_duration_short)); hideBackgroundAnimator.setStartDelay(getResources() .getInteger(R.integer.framework_animation__confirmation_menu__hide_background_delay)); hideBackgroundAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { setVisibility(GONE); boolean checkboxIsSelected = checkBoxView.getVisibility() == VISIBLE && checkBoxView.isSelected(); if (callback != null) { callback.onHideAnimationEnd(confirmed, cancelled, checkboxIsSelected); } } }); ObjectAnimator hideMessageAnimator = ObjectAnimator.ofFloat(messageContainerView, View.TRANSLATION_Y, 0, messageContainerView.getMeasuredHeight()); hideMessageAnimator.setInterpolator(new Expo.EaseIn()); hideMessageAnimator .setDuration(getResources().getInteger(R.integer.framework_animation_duration_medium)); AnimatorSet hideSet = new AnimatorSet(); hideSet.playTogether(hideMessageAnimator, hideBackgroundAnimator); hideSet.start(); } }
From source file:com.waz.zclient.pages.main.conversation.views.row.footer.FooterViewController.java
private ObjectAnimator getViewTextViewAnimator(final View view, boolean animateIn, float to) { ObjectAnimator animator = ObjectAnimator.ofFloat(view, View.TRANSLATION_Y, to); animator.setDuration(/* ww w . j a v a 2 s. c o m*/ context.getResources().getInteger(com.waz.zclient.ui.R.integer.wire__animation__duration__short)); if (animateIn) { animator.setInterpolator(new Expo.EaseOut()); } else { animator.setInterpolator(new Expo.EaseIn()); } if (animateIn) { animator.setStartDelay( context.getResources().getInteger(com.waz.zclient.ui.R.integer.animation_delay_short)); animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { view.setVisibility(View.VISIBLE); } }); } else { animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationCancel(Animator animation) { view.setVisibility(View.GONE); } @Override public void onAnimationEnd(Animator animation) { view.setVisibility(View.GONE); } }); } return animator; }
From source file:com.sinyuk.jianyimaterial.widgets.FloatingToolbar.java
private void showDefaultImpl() { int rootWidth = mRoot.getWidth(); setScaleX(0f);//from w ww . jav a 2 s.co 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:me.lizheng.deckview.views.DeckChildView.java
/** * Animates this task view as it enters recents */// ww w.j ava2s. co m void startEnterRecentsAnimation(final ViewAnimation.TaskViewEnterContext ctx) { Log.i(getClass().getSimpleName(), "startEnterRecentsAnimation"); final DeckChildViewTransform transform = ctx.currentTaskTransform; int startDelay = 0; if (mConfig.launchedFromHome) { Log.i(getClass().getSimpleName(), "mConfig.launchedFromHome false"); // Animate the tasks up int frontIndex = (ctx.currentStackViewCount - ctx.currentStackViewIndex - 1); int delay = mConfig.transitionEnterFromHomeDelay + frontIndex * mConfig.taskViewEnterFromHomeStaggerDelay; setScaleX(transform.scale); setScaleY(transform.scale); ObjectAnimator animator = ObjectAnimator.ofFloat(this, "TranslationY", getTranslationY(), transform.translationY); animator.addUpdateListener(ctx.updateListener); animator.setDuration( mConfig.taskViewEnterFromHomeDuration + frontIndex * mConfig.taskViewEnterFromHomeStaggerDelay); animator.setStartDelay(delay); animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { // Decrement the post animation trigger ctx.postAnimationTrigger.decrement(); } }); animator.start(); ctx.postAnimationTrigger.increment(); startDelay = delay; } // Enable the focus animations from this point onwards so that they aren't affected by the // window transitions postDelayed(new Runnable() { @Override public void run() { enableFocusAnimations(); } }, startDelay); }
From source file:com.mojtaba.materialdatetimepicker.date.DatePickerDialog.java
private void setCurrentView(final int viewIndex) { switch (viewIndex) { case MONTH_AND_DAY_VIEW: ObjectAnimator pulseAnimator = Utils.getPulseAnimator(mMonthAndDayView, 0.9f, 1.05f); if (mDelayAnimation) { pulseAnimator.setStartDelay(ANIMATION_DELAY); mDelayAnimation = false;/*from w w w.j a va2s . c om*/ } mDayPickerView.onDateChanged(); if (mCurrentView != viewIndex) { mMonthAndDayView.setSelected(true); mYearView.setSelected(false); mAnimator.setDisplayedChild(MONTH_AND_DAY_VIEW); mCurrentView = viewIndex; } pulseAnimator.start(); String dayString = LanguageUtils.getPersianNumbers(mPersianCalendar.getPersianLongDate()); mAnimator.setContentDescription(mDayPickerDescription + ": " + dayString); Utils.tryAccessibilityAnnounce(mAnimator, mSelectDay); break; case YEAR_VIEW: pulseAnimator = Utils.getPulseAnimator(mYearView, 0.85f, 1.1f); if (mDelayAnimation) { pulseAnimator.setStartDelay(ANIMATION_DELAY); mDelayAnimation = false; } mYearPickerView.onDateChanged(); if (mCurrentView != viewIndex) { mMonthAndDayView.setSelected(false); mYearView.setSelected(true); mAnimator.setDisplayedChild(YEAR_VIEW); mCurrentView = viewIndex; } pulseAnimator.start(); String yearString = LanguageUtils.getPersianNumbers(String.valueOf(mPersianCalendar.getPersianYear())); mAnimator.setContentDescription(mYearPickerDescription + ": " + yearString); Utils.tryAccessibilityAnnounce(mAnimator, mSelectYear); break; } }
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 {/*www . j a v a 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.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;// w ww . j ava 2s. c o 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 ww . ja v a 2 s . c om // 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); } }; }); }