List of usage examples for android.animation ObjectAnimator ofFloat
public static <T> ObjectAnimator ofFloat(T target, Property<T, Float> property, float... values)
From source file:com.sinyuk.jianyimaterial.widgets.FloatingToolbar.java
private void showDefaultImpl() { int rootWidth = mRoot.getWidth(); setScaleX(0f);/*w w w . j a va 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:fr.shywim.antoinedaniel.ui.fragment.SoundPagerFragment.java
@Override public void onScrollDown() { if (mFab != null) { if (mFabIsOpen) { closeFab(mFab);/*from w w w . ja v a 2 s .co m*/ } if (!mFabAnimDown) { if (mFabOriginalPosition == -1) { mFabOriginalPosition = mFab.getY(); mFabHiddenPosition = mFabOriginalPosition + mActivity.getResources().getDimension(R.dimen.fab_height) + mActivity.getResources().getDimension(R.dimen.fab_margin); } mFabAnimDown = true; mFabAnimUp = false; if (mFabAnim != null) { mFabAnim.cancel(); mFab.clearAnimation(); } mFabAnim = ObjectAnimator.ofFloat(mFab, "Y", mFabHiddenPosition); mFabAnim.setInterpolator(new AccelerateDecelerateInterpolator()); mFabAnim.start(); } } }
From source file:com.simas.vc.MainActivity.java
/** * Adds helper tooltips if they haven't yet been closed. Must be called after the toolbar is * set./*from w ww. j a va2 s.c o m*/ */ private void addTooltips() { getToolbar().addOnLayoutChangeListener(new View.OnLayoutChangeListener() { @Override public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { View concat = mToolbar.findViewById(R.id.action_concat); View add = mToolbar.findViewById(R.id.action_add_item); if (concat != null && add != null) { add.setOnClickListener(new View.OnClickListener() { private boolean mRotated; @Override public void onClick(View v) { ObjectAnimator animator = ObjectAnimator.ofFloat(v, "rotation", (mRotated = !mRotated) ? 360 : 0); animator.setDuration(300); animator.start(); } }); new Tooltip(MainActivity.this, concat, Utils.getString(R.string.help_concatenate)); new Tooltip(MainActivity.this, add, Utils.getString(R.string.help_add_item)); mToolbar.removeOnLayoutChangeListener(this); } } }); // Force re-draw getToolbar().requestLayout(); }
From source file:com.spatialnetworks.fulcrum.widget.DynamicListView.java
/** * This method determines whether the hover cell has been shifted far enough * to invoke a cell swap. If so, then the respective cell swap candidate is * determined and the data set is changed. Upon posting a notification of the * data set change, a layout is invoked to place the cells in the right place. * Using a ViewTreeObserver and a corresponding OnPreDrawListener, we can * offset the cell being swapped to where it previously was and then animate it to * its new position.// w w w.j av a 2 s . com */ private void handleCellSwitch() { final int deltaY = mLastEventY - mDownY; int deltaYTotal = mHoverCellOriginalBounds.top + mTotalOffset + deltaY; View belowView = getViewForID(mBelowItemId); View mobileView = getViewForID(mMobileItemId); View aboveView = getViewForID(mAboveItemId); boolean isBelow = (belowView != null) && (deltaYTotal > belowView.getTop()); boolean isAbove = (aboveView != null) && (deltaYTotal < aboveView.getTop()); if (isBelow || isAbove) { final long switchItemID = isBelow ? mBelowItemId : mAboveItemId; View switchView = isBelow ? belowView : aboveView; final int originalItem = getPositionForView(mobileView); swapElements(originalItem, getPositionForView(switchView)); // Josh mobileView.setVisibility(VISIBLE); ((BaseAdapter) getAdapter()).notifyDataSetChanged(); mDownY = mLastEventY; final int switchViewStartTop = switchView.getTop(); // Josh // mobileView.setVisibility(View.VISIBLE); // switchView.setVisibility(View.INVISIBLE); updateNeighborViewsForID(mMobileItemId); final ViewTreeObserver observer = getViewTreeObserver(); observer.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { public boolean onPreDraw() { observer.removeOnPreDrawListener(this); // Josh View mobileView = getViewForID(mMobileItemId); if (mobileView != null) { mobileView.setVisibility(INVISIBLE); } View switchView = getViewForID(switchItemID); mTotalOffset += deltaY; int switchViewNewTop = switchView.getTop(); int delta = switchViewStartTop - switchViewNewTop; switchView.setTranslationY(delta); ObjectAnimator animator = ObjectAnimator.ofFloat(switchView, View.TRANSLATION_Y, 0); animator.setDuration(MOVE_DURATION); animator.start(); return true; } }); } }
From source file:com.android.messaging.ui.conversationlist.ConversationListSwipeHelper.java
/** * Create and start an animator that animates the given view's translationX * from its current value to the value given by animateTo. *///w ww.jav a 2 s .c o m private ObjectAnimator getSwipeTranslationXAnimator(final ConversationListItemView itemView, final float animateTo, final long duration, final TimeInterpolator interpolator) { final ObjectAnimator animator = ObjectAnimator.ofFloat(itemView, "swipeTranslationX", animateTo); animator.setDuration(duration); animator.setInterpolator(interpolator); return animator; }
From source file:com.waz.zclient.pages.main.participants.ParticipantHeaderFragment.java
public void showCancelButton(boolean show, boolean animate) { if (closeButton == null || headerTopBorder == null) { return;//from w ww . j a v a 2 s .c o m } if (show) { if (!animate) { closeButton.setAlpha(1); } else { headerTopBorder.animate().alpha(0) .setDuration( getResources().getInteger(R.integer.open_close_button__alpha__animation_duration)) .setStartDelay(getResources().getInteger(R.integer.open_close_button__alpha__delay)) .start(); ObjectAnimator animator = ObjectAnimator.ofFloat(closeButton, View.ALPHA, 1); animator.setDuration( getResources().getInteger(R.integer.open_close_button__alpha__animation_duration)) .setStartDelay(getResources().getInteger(R.integer.open_close_button__alpha__delay)); animator.start(); } } else { if (!animate) { closeButton.setAlpha(0); } else { ObjectAnimator animator = ObjectAnimator.ofFloat(closeButton, View.ALPHA, 0); animator.setDuration( getResources().getInteger(R.integer.close_close_button__alpha__animation_duration)) .setStartDelay(getResources().getInteger(R.integer.close_close_button__alpha__delay)); animator.start(); headerTopBorder.animate().alpha(1) .setDuration( getResources().getInteger(R.integer.close_close_button__alpha__animation_duration)) .setStartDelay(getResources().getInteger(R.integer.close_close_button__alpha__delay)) .start(); } } }
From source file:com.androidinspain.deskclock.alarms.dataadapter.ExpandedAlarmViewHolder.java
private Animator createCollapsingAnimator(AlarmItemViewHolder newHolder, long duration) { arrow.setVisibility(View.INVISIBLE); clock.setVisibility(View.INVISIBLE); onOff.setVisibility(View.INVISIBLE); final boolean daysVisible = repeatDays.getVisibility() == View.VISIBLE; final int numberOfItems = countNumberOfItems(); final View oldView = itemView; final View newView = newHolder.itemView; final Animator backgroundAnimator = ObjectAnimator.ofPropertyValuesHolder(oldView, PropertyValuesHolder.ofInt(AnimatorUtils.BACKGROUND_ALPHA, 255, 0)); backgroundAnimator.setDuration(duration); final Animator boundsAnimator = AnimatorUtils.getBoundsAnimator(oldView, oldView, newView); boundsAnimator.setDuration(duration); boundsAnimator.setInterpolator(AnimatorUtils.INTERPOLATOR_FAST_OUT_SLOW_IN); final long shortDuration = (long) (duration * ANIM_SHORT_DURATION_MULTIPLIER); final Animator repeatAnimation = ObjectAnimator.ofFloat(repeat, View.ALPHA, 0f).setDuration(shortDuration); final Animator editLabelAnimation = ObjectAnimator.ofFloat(editLabel, View.ALPHA, 0f) .setDuration(shortDuration); final Animator repeatDaysAnimation = ObjectAnimator.ofFloat(repeatDays, View.ALPHA, 0f) .setDuration(shortDuration); final Animator vibrateAnimation = ObjectAnimator.ofFloat(vibrate, View.ALPHA, 0f) .setDuration(shortDuration); final Animator ringtoneAnimation = ObjectAnimator.ofFloat(ringtone, View.ALPHA, 0f) .setDuration(shortDuration); final Animator dismissAnimation = ObjectAnimator.ofFloat(preemptiveDismissButton, View.ALPHA, 0f) .setDuration(shortDuration); final Animator deleteAnimation = ObjectAnimator.ofFloat(delete, View.ALPHA, 0f).setDuration(shortDuration); final Animator hairLineAnimation = ObjectAnimator.ofFloat(hairLine, View.ALPHA, 0f) .setDuration(shortDuration); // Set the staggered delays; use the first portion (duration * (1 - 1/4 - 1/6)) of the time, // so that the final animation, with a duration of 1/4 the total duration, finishes exactly // before the collapsed holder begins expanding. long startDelay = 0L; final long delayIncrement = (long) (duration * ANIM_LONG_DELAY_INCREMENT_MULTIPLIER) / (numberOfItems - 1); deleteAnimation.setStartDelay(startDelay); if (preemptiveDismissButton.getVisibility() == View.VISIBLE) { startDelay += delayIncrement;//from w ww .j a v a 2 s . c om dismissAnimation.setStartDelay(startDelay); } hairLineAnimation.setStartDelay(startDelay); startDelay += delayIncrement; editLabelAnimation.setStartDelay(startDelay); startDelay += delayIncrement; vibrateAnimation.setStartDelay(startDelay); ringtoneAnimation.setStartDelay(startDelay); startDelay += delayIncrement; if (daysVisible) { repeatDaysAnimation.setStartDelay(startDelay); startDelay += delayIncrement; } repeatAnimation.setStartDelay(startDelay); final AnimatorSet animatorSet = new AnimatorSet(); animatorSet.playTogether(backgroundAnimator, boundsAnimator, repeatAnimation, repeatDaysAnimation, vibrateAnimation, ringtoneAnimation, editLabelAnimation, deleteAnimation, hairLineAnimation, dismissAnimation); return animatorSet; }
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(// w w w . j a v a2 s. co 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.hamzahrmalik.calculator2.Calculator.java
private void onResult(final String result) { // Calculate the values needed to perform the scale and translation // animations, // accounting for how the scale will affect the final position of the // text.//from w w w . j a v a 2 s.co m final float resultScale = mFormulaEditText.getVariableTextSize(result) / mResultEditText.getTextSize(); final float resultTranslationX = (1.0f - resultScale) * (mResultEditText.getWidth() / 2.0f - mResultEditText.getPaddingEnd()); final float resultTranslationY = (1.0f - resultScale) * (mResultEditText.getHeight() / 2.0f - mResultEditText.getPaddingBottom()) + (mFormulaEditText.getBottom() - mResultEditText.getBottom()) + (mResultEditText.getPaddingBottom() - mFormulaEditText.getPaddingBottom()); final float formulaTranslationY = -mFormulaEditText.getBottom(); // Use a value animator to fade to the final text color over the course // of the animation. final int resultTextColor = mResultEditText.getCurrentTextColor(); final int formulaTextColor = mFormulaEditText.getCurrentTextColor(); final ValueAnimator textColorAnimator = ValueAnimator.ofObject(new ArgbEvaluator(), resultTextColor, formulaTextColor); textColorAnimator.addUpdateListener(new AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { /* * mResultEditText.setTextColor((int) valueAnimator * .getAnimatedValue()); */ } }); final AnimatorSet animatorSet = new AnimatorSet(); animatorSet.playTogether(textColorAnimator, ObjectAnimator.ofFloat(mResultEditText, View.SCALE_X, resultScale), ObjectAnimator.ofFloat(mResultEditText, View.SCALE_Y, resultScale), ObjectAnimator.ofFloat(mResultEditText, View.TRANSLATION_X, resultTranslationX), ObjectAnimator.ofFloat(mResultEditText, View.TRANSLATION_Y, resultTranslationY), ObjectAnimator.ofFloat(mFormulaEditText, View.TRANSLATION_Y, formulaTranslationY)); animatorSet.setDuration(getResources().getInteger(android.R.integer.config_longAnimTime)); animatorSet.setInterpolator(new AccelerateDecelerateInterpolator()); animatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { mResultEditText.setText(result); } @Override public void onAnimationEnd(Animator animation) { // Reset all of the values modified during the animation. mResultEditText.setTextColor(resultTextColor); mResultEditText.setScaleX(1.0f); mResultEditText.setScaleY(1.0f); mResultEditText.setTranslationX(0.0f); mResultEditText.setTranslationY(0.0f); mFormulaEditText.setTranslationY(0.0f); // Finally update the formula to use the current result. mFormulaEditText.setText(result); setState(CalculatorState.RESULT); mCurrentAnimator = null; } }); mCurrentAnimator = animatorSet; animatorSet.start(); }
From source file:com.android.contacts.activities.PhotoSelectionActivity.java
private void closePhotoAndFinish() { mAnimationListener = new AnimatorListenerAdapter() { @Override// w ww . j a va 2 s . c o m public void onAnimationEnd(Animator animation) { // After the photo animates down, fade it away and finish. ObjectAnimator anim = ObjectAnimator.ofFloat(mPhotoView, "alpha", 0f) .setDuration(PHOTO_CONTRACT_DURATION); anim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { finishImmediatelyWithNoAnimation(); } }); anim.start(); } }; animatePhoto(mPhotoStartParams); animateAwayBackground(); }