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:arun.com.chromer.webheads.ui.views.BaseWebHead.java
@NonNull public Animator getRevealAnimator(@ColorInt final int newWebHeadColor) { revealView.clearAnimation();/*ww w.java2 s. co m*/ initRevealView(newWebHeadColor); final AnimatorSet animator = new AnimatorSet(); animator.playTogether(ObjectAnimator.ofFloat(revealView, "scaleX", 1f), ObjectAnimator.ofFloat(revealView, "scaleY", 1f), ObjectAnimator.ofFloat(revealView, "alpha", 1f)); revealView.setLayerType(LAYER_TYPE_HARDWARE, null); animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { webHeadColor = newWebHeadColor; updateBadgeColors(webHeadColor); if (indicator != null && circleBg != null && revealView != null) { circleBg.setColor(newWebHeadColor); indicator.setTextColor(getForegroundWhiteOrBlack(newWebHeadColor)); revealView.setLayerType(LAYER_TYPE_NONE, null); revealView.setScaleX(0f); revealView.setScaleY(0f); } } }); animator.setInterpolator(new LinearOutSlowInInterpolator()); animator.setDuration(250); return animator; }
From source file:com.joaquimley.faboptions.FabOptions.java
private void openCompatAnimation() { ObjectAnimator anim = ObjectAnimator.ofFloat(mBackground, "scaleX", 1.0f); anim.setDuration(30000); // duration 3 seconds anim.start();//w ww . j av a2 s. c o m }
From source file:com.joaquimley.faboptions.FabOptions.java
private void closeCompatAnimation() { ObjectAnimator anim = ObjectAnimator.ofFloat(mBackground, "scaleX", 0.0f); anim.setDuration(3000); anim.start(); animateButtons(false); }
From source file:com.androidinspain.deskclock.alarms.dataadapter.ExpandedAlarmViewHolder.java
@Override public Animator onAnimateChange(List<Object> payloads, int fromLeft, int fromTop, int fromRight, int fromBottom, long duration) { if (payloads == null || payloads.isEmpty() || !payloads.contains(ANIMATE_REPEAT_DAYS)) { return null; }//from w ww . ja va2s. co m final boolean isExpansion = repeatDays.getVisibility() == View.VISIBLE; final int height = repeatDays.getHeight(); setTranslationY(isExpansion ? -height : 0f, isExpansion ? -height : height); repeatDays.setVisibility(View.VISIBLE); repeatDays.setAlpha(isExpansion ? 0f : 1f); final AnimatorSet animatorSet = new AnimatorSet(); animatorSet.playTogether( AnimatorUtils.getBoundsAnimator(itemView, fromLeft, fromTop, fromRight, fromBottom, itemView.getLeft(), itemView.getTop(), itemView.getRight(), itemView.getBottom()), ObjectAnimator.ofFloat(repeatDays, View.ALPHA, isExpansion ? 1f : 0f), ObjectAnimator.ofFloat(repeatDays, TRANSLATION_Y, isExpansion ? 0f : -height), ObjectAnimator.ofFloat(ringtone, TRANSLATION_Y, 0f), ObjectAnimator.ofFloat(vibrate, TRANSLATION_Y, 0f), ObjectAnimator.ofFloat(editLabel, TRANSLATION_Y, 0f), ObjectAnimator.ofFloat(preemptiveDismissButton, TRANSLATION_Y, 0f), ObjectAnimator.ofFloat(hairLine, TRANSLATION_Y, 0f), ObjectAnimator.ofFloat(delete, TRANSLATION_Y, 0f), ObjectAnimator.ofFloat(arrow, TRANSLATION_Y, 0f)); animatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animator) { setTranslationY(0f, 0f); repeatDays.setAlpha(1f); repeatDays.setVisibility(isExpansion ? View.VISIBLE : View.GONE); itemView.requestLayout(); } }); animatorSet.setDuration(duration); animatorSet.setInterpolator(AnimatorUtils.INTERPOLATOR_FAST_OUT_SLOW_IN); return animatorSet; }
From source file:arun.com.chromer.webheads.ui.views.BaseWebHead.java
/** * Opposite of {@link #getRevealAnimator(int)}. Reveal goes from max scale to 0 appearing to be * revealing in.//from w w w . ja va 2 s. c o m * * @param newWebHeadColor New themeColor of reveal * @param start Runnable to run on start * @param end Runnable to run on end */ void revealInAnimation(@ColorInt final int newWebHeadColor, @NonNull final Runnable start, @NonNull final Runnable end) { if (revealView == null || circleBg == null) { start.run(); end.run(); } revealView.clearAnimation(); revealView.setColor(circleBg.getColor()); revealView.setScaleX(1f); revealView.setScaleY(1f); revealView.setAlpha(1f); circleBg.setColor(newWebHeadColor); final AnimatorSet animator = new AnimatorSet(); animator.playTogether(ObjectAnimator.ofFloat(revealView, "scaleX", 0f), ObjectAnimator.ofFloat(revealView, "scaleY", 0f)); revealView.setLayerType(LAYER_TYPE_HARDWARE, null); animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { start.run(); } @Override public void onAnimationEnd(Animator animation) { webHeadColor = newWebHeadColor; indicator.setTextColor(getForegroundWhiteOrBlack(newWebHeadColor)); revealView.setLayerType(LAYER_TYPE_NONE, null); revealView.setScaleX(0f); revealView.setScaleY(0f); end.run(); } }); animator.setInterpolator(new LinearOutSlowInInterpolator()); animator.setDuration(400); animator.setStartDelay(100); animator.start(); }
From source file:com.hamzahrmalik.calculator2.Calculator.java
private void reveal(View sourceView, int colorRes, AnimatorListener listener) { final ViewGroupOverlay groupOverlay = (ViewGroupOverlay) getWindow().getDecorView().getOverlay(); final Rect displayRect = new Rect(); mDisplayView.getGlobalVisibleRect(displayRect); // Make reveal cover the display and status bar. final View revealView = new View(this); revealView.setBottom(displayRect.bottom); revealView.setLeft(displayRect.left); revealView.setRight(displayRect.right); revealView.setBackgroundColor(getResources().getColor(colorRes)); groupOverlay.add(revealView);//from w w w. java 2 s. c om final int[] clearLocation = new int[2]; sourceView.getLocationInWindow(clearLocation); clearLocation[0] += sourceView.getWidth() / 2; clearLocation[1] += sourceView.getHeight() / 2; final int revealCenterX = clearLocation[0] - revealView.getLeft(); final int revealCenterY = clearLocation[1] - revealView.getTop(); final double x1_2 = Math.pow(revealView.getLeft() - revealCenterX, 2); final double x2_2 = Math.pow(revealView.getRight() - revealCenterX, 2); final double y_2 = Math.pow(revealView.getTop() - revealCenterY, 2); final float revealRadius = (float) Math.max(Math.sqrt(x1_2 + y_2), Math.sqrt(x2_2 + y_2)); final Animator alphaAnimator = ObjectAnimator.ofFloat(revealView, View.ALPHA, 0.0f); alphaAnimator.setDuration(getResources().getInteger(android.R.integer.config_mediumAnimTime)); final AnimatorSet animatorSet = new AnimatorSet(); animatorSet.setInterpolator(new AccelerateDecelerateInterpolator()); animatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animator) { groupOverlay.remove(revealView); mCurrentAnimator = null; } }); mResultEditText.setText(""); mFormulaEditText.setText(""); mCurrentAnimator = animatorSet; animatorSet.start(); }
From source file:fr.shywim.antoinedaniel.ui.fragment.SoundPagerFragment.java
@Override public void onScrollUp() { if (mFab != null) { if (mFabIsOpen) { closeFab(mFab);//from w w w . j a v a2 s .co m } if (!mFabAnimUp) { if (mFabOriginalPosition == -1) { mFabOriginalPosition = mFab.getY(); mFabHiddenPosition = mFabOriginalPosition + mActivity.getResources().getDimension(R.dimen.fab_height) + mActivity.getResources().getDimension(R.dimen.fab_margin); } mFabAnimUp = true; mFabAnimDown = false; if (mFabAnim != null) { mFabAnim.cancel(); mFab.clearAnimation(); } mFabAnim = ObjectAnimator.ofFloat(mFab, "Y", mFabOriginalPosition); mFabAnim.setInterpolator(new AccelerateDecelerateInterpolator()); mFabAnim.start(); } } }
From source file:com.dgnt.dominionCardPicker.view.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.//from ww w .j a v a2 s .c o m */ 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); if (switchView == null) { updateNeighborViewsForID(mMobileItemId); return; } swapElements(list, originalItem, getPositionForView(switchView)); ((BaseAdapter) getAdapter()).notifyDataSetChanged(); mDownY = mLastEventY; final int switchViewStartTop = switchView.getTop(); mobileView.setVisibility(View.VISIBLE); switchView.setVisibility(View.VISIBLE); updateNeighborViewsForID(mMobileItemId); final ViewTreeObserver observer = getViewTreeObserver(); observer.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { public boolean onPreDraw() { observer.removeOnPreDrawListener(this); 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.example.customview.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.//from w ww . jav a 2s . 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); if (switchView == null) { updateNeighborViewsForID(mMobileItemId); return; } if (getPositionForView(switchView) == mPanelList.size() - 1) { return; } swapElements(mPanelList, originalItem, getPositionForView(switchView)); ((BaseAdapter) getAdapter()).notifyDataSetChanged(); mDownY = mLastEventY; final int switchViewStartTop = switchView.getTop(); 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); 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.odoo.OdooActivity.java
private void accountBoxToggle() { ImageView boxIndicator = (ImageView) findViewById(R.id.expand_account_box_indicator); boxIndicator.setImageResource(mAccountBoxExpanded ? R.drawable.ic_drawer_accounts_collapse : R.drawable.ic_drawer_accounts_expand); int hideTranslateY = -mDrawerAccountContainer.getHeight() / 4; if (mAccountBoxExpanded && mDrawerAccountContainer.getTranslationY() == 0) { // initial setup mDrawerAccountContainer.setAlpha(0); mDrawerAccountContainer.setTranslationY(hideTranslateY); }//from www .ja va 2 s .co m AnimatorSet set = new AnimatorSet(); set.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mDrawerItemContainer.setVisibility(mAccountBoxExpanded ? View.INVISIBLE : View.VISIBLE); mDrawerAccountContainer.setVisibility(mAccountBoxExpanded ? View.VISIBLE : View.INVISIBLE); } @Override public void onAnimationCancel(Animator animation) { onAnimationEnd(animation); } }); if (mAccountBoxExpanded) { mDrawerAccountContainer.setVisibility(View.VISIBLE); AnimatorSet subSet = new AnimatorSet(); subSet.playTogether( ObjectAnimator.ofFloat(mDrawerAccountContainer, View.ALPHA, 1) .setDuration(DRAWER_ACCOUNT_BOX_ANIMATION_DURATION), ObjectAnimator.ofFloat(mDrawerAccountContainer, View.TRANSLATION_Y, 0) .setDuration(DRAWER_ACCOUNT_BOX_ANIMATION_DURATION)); set.playSequentially(ObjectAnimator.ofFloat(mDrawerItemContainer, View.ALPHA, 0) .setDuration(DRAWER_ACCOUNT_BOX_ANIMATION_DURATION), subSet); set.start(); } else { mDrawerItemContainer.setVisibility(View.VISIBLE); AnimatorSet subSet = new AnimatorSet(); subSet.playTogether( ObjectAnimator.ofFloat(mDrawerAccountContainer, View.ALPHA, 0) .setDuration(DRAWER_ACCOUNT_BOX_ANIMATION_DURATION), ObjectAnimator.ofFloat(mDrawerAccountContainer, View.TRANSLATION_Y, hideTranslateY) .setDuration(DRAWER_ACCOUNT_BOX_ANIMATION_DURATION)); set.playSequentially(subSet, ObjectAnimator.ofFloat(mDrawerItemContainer, View.ALPHA, 1) .setDuration(DRAWER_ACCOUNT_BOX_ANIMATION_DURATION)); set.start(); } set.start(); }