Example usage for android.view.animation DecelerateInterpolator DecelerateInterpolator

List of usage examples for android.view.animation DecelerateInterpolator DecelerateInterpolator

Introduction

In this page you can find the example usage for android.view.animation DecelerateInterpolator DecelerateInterpolator.

Prototype

public DecelerateInterpolator() 

Source Link

Usage

From source file:com.nadmm.airports.ActivityBase.java

protected void onActionBarAutoShowOrHide(boolean shown) {
    for (View view : mHideableHeaderViews) {
        if (shown) {
            view.animate().translationY(0).setDuration(HEADER_HIDE_ANIM_DURATION)
                    .setInterpolator(new DecelerateInterpolator());
        } else {//from  www  . j a  v  a  2  s.  c  o m
            int offset = (int) view.getTag(R.id.AUTOHIDE_OFFSET);
            view.animate().translationY(-offset).setDuration(HEADER_HIDE_ANIM_DURATION)
                    .setInterpolator(new DecelerateInterpolator());
        }
    }
}

From source file:com.rbware.github.androidcouchpotato.widget.AbstractMediaItemPresenter.java

/**
 * Each media item row can have multiple focusable elements; the details on the left and a set
 * of optional custom actions on the right.
 * The selector is a highlight that moves to highlight to cover whichever views is in focus.
 *
 * @param selectorView the selector view used to highlight an individual element within a row.
 * @param focusChangedView The component within the media row whose focus got changed.
 * @param layoutAnimator the ValueAnimator producing animation frames for the selector's width
 *                       and x-translation, generated by this method and stored for the each
 *                       {@link ViewHolder}.
 * @param isDetails Whether the changed-focused view is for a media item details (true) or
 *                  an action (false).//from w w  w .  j a  va 2s.  c  o m
 */
static ValueAnimator updateSelector(final View selectorView, View focusChangedView,
        ValueAnimator layoutAnimator, boolean isDetails) {
    int animationDuration = focusChangedView.getContext().getResources()
            .getInteger(android.R.integer.config_shortAnimTime);
    DecelerateInterpolator interpolator = new DecelerateInterpolator();

    int layoutDirection = ViewCompat.getLayoutDirection(selectorView);
    if (!focusChangedView.hasFocus()) {
        // if neither of the details or action views are in focus (ie. another row is in focus),
        // animate the selector out.
        selectorView.animate().cancel();
        selectorView.animate().alpha(0f).setDuration(animationDuration).setInterpolator(interpolator).start();
        // keep existing layout animator
        return layoutAnimator;
    } else {
        // cancel existing layout animator
        if (layoutAnimator != null) {
            layoutAnimator.cancel();
            layoutAnimator = null;
        }
        float currentAlpha = selectorView.getAlpha();
        selectorView.animate().alpha(1f).setDuration(animationDuration).setInterpolator(interpolator).start();

        final ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) selectorView.getLayoutParams();
        ViewGroup rootView = (ViewGroup) selectorView.getParent();
        sTempRect.set(0, 0, focusChangedView.getWidth(), focusChangedView.getHeight());
        rootView.offsetDescendantRectToMyCoords(focusChangedView, sTempRect);
        if (isDetails) {
            if (layoutDirection == View.LAYOUT_DIRECTION_RTL) {
                sTempRect.right += rootView.getHeight();
                sTempRect.left -= rootView.getHeight() / 2;
            } else {
                sTempRect.left -= rootView.getHeight();
                sTempRect.right += rootView.getHeight() / 2;
            }
        }
        final int targetLeft = sTempRect.left;
        final int targetWidth = sTempRect.width();
        final float deltaWidth = lp.width - targetWidth;
        final float deltaLeft = lp.leftMargin - targetLeft;

        if (deltaLeft == 0f && deltaWidth == 0f) {
            // no change needed
        } else if (currentAlpha == 0f) {
            // change selector to the proper width and marginLeft without animation.
            lp.width = targetWidth;
            lp.leftMargin = targetLeft;
            selectorView.requestLayout();
        } else {
            // animate the selector to the proper width and marginLeft.
            layoutAnimator = ValueAnimator.ofFloat(0f, 1f);
            layoutAnimator.setDuration(animationDuration);
            layoutAnimator.setInterpolator(interpolator);

            layoutAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                @Override
                public void onAnimationUpdate(ValueAnimator valueAnimator) {
                    // Set width to the proper width for this animation step.
                    float fractionToEnd = 1f - valueAnimator.getAnimatedFraction();
                    lp.leftMargin = Math.round(targetLeft + deltaLeft * fractionToEnd);
                    lp.width = Math.round(targetWidth + deltaWidth * fractionToEnd);
                    selectorView.requestLayout();
                }
            });
            layoutAnimator.start();
        }
        return layoutAnimator;

    }
}

From source file:ca.zadrox.dota2esportticker.ui.BaseActivity.java

protected void onActionBarAutoShowOrHide(boolean shown) {
    if (mStatusBarColorAnimator != null) {
        mStatusBarColorAnimator.cancel();
    }//from w  ww. jav a2  s .  co  m
    mStatusBarColorAnimator = ObjectAnimator
            .ofInt((mDrawerLayout != null) ? mDrawerLayout : mLUtils,
                    (mDrawerLayout != null) ? "statusBarBackgroundColor" : "statusBarColor",
                    shown ? Color.BLACK : mNormalStatusBarColor, shown ? mNormalStatusBarColor : Color.BLACK)
            .setDuration(250);
    if (mDrawerLayout != null) {
        mStatusBarColorAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator valueAnimator) {
                ViewCompat.postInvalidateOnAnimation(mDrawerLayout);
            }
        });
    }
    mStatusBarColorAnimator.setEvaluator(ARGB_EVALUATOR);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.L) {
        mStatusBarColorAnimator.start();
    }

    updateSwipeRefreshProgressBarTop();

    for (View view : mHideableHeaderViews) {
        if (shown) {
            view.animate().translationY(0).alpha(1).setDuration(HEADER_HIDE_ANIM_DURATION)
                    .setInterpolator(new DecelerateInterpolator());
        } else {
            view.animate().translationY(-UIUtils.calculateActionBarSize(this)).alpha(1)
                    .setDuration(HEADER_HIDE_ANIM_DURATION).setInterpolator(new DecelerateInterpolator());
        }
    }
}

From source file:com.google.android.apps.santatracker.village.Village.java

private void showEasterEgg() {
    ObjectAnimator anim = ObjectAnimator.ofFloat(mImageUfo, "size", 0f, 1.0f);
    anim.setInterpolator(new DecelerateInterpolator());
    anim.setDuration(ImageWithAlphaAndSize.ANIM_DURATION);
    anim.start();/* ww  w. j a  v  a  2 s .  co m*/
    mImageUfo.setAlpha(ImageWithAlphaAndSize.OPAQUE);
    // [ANALYTICS EVENT]: Village Click
    AnalyticsManager.sendEvent(R.string.analytics_event_category_village,
            R.string.analytics_event_village_unlock_easteregg);
}

From source file:org.mariotaku.twidere.fragment.support.AccountsDashboardFragment.java

private void onAccountSelected(AccountProfileImageViewHolder holder, final ParcelableAccount account) {
    if (mSwitchAccountAnimationPlaying)
        return;// ww  w. ja  v  a 2 s. c om
    final ImageView snapshotView = mFloatingProfileImageSnapshotView;
    final ShapedImageView profileImageView = mAccountProfileImageView;
    final ShapedImageView clickedImageView = holder.getIconView();

    // Reset snapshot view position
    snapshotView.setPivotX(0);
    snapshotView.setPivotY(0);
    snapshotView.setTranslationX(0);
    snapshotView.setTranslationY(0);

    final Matrix matrix = new Matrix();
    final RectF sourceBounds = new RectF(), destBounds = new RectF(), snapshotBounds = new RectF();
    getLocationOnScreen(clickedImageView, sourceBounds);
    getLocationOnScreen(profileImageView, destBounds);
    getLocationOnScreen(snapshotView, snapshotBounds);
    final float finalScale = destBounds.width() / sourceBounds.width();
    final Bitmap snapshotBitmap = TransitionUtils.createViewBitmap(clickedImageView, matrix,
            new RectF(0, 0, sourceBounds.width(), sourceBounds.height()));
    final ViewGroup.LayoutParams lp = snapshotView.getLayoutParams();
    lp.width = clickedImageView.getWidth();
    lp.height = clickedImageView.getHeight();
    snapshotView.setLayoutParams(lp);
    // Copied from MaterialNavigationDrawer: https://github.com/madcyph3r/AdvancedMaterialDrawer/
    AnimatorSet set = new AnimatorSet();
    set.play(ObjectAnimator.ofFloat(snapshotView, View.TRANSLATION_X, sourceBounds.left - snapshotBounds.left,
            destBounds.left - snapshotBounds.left))
            .with(ObjectAnimator.ofFloat(snapshotView, View.TRANSLATION_Y,
                    sourceBounds.top - snapshotBounds.top, destBounds.top - snapshotBounds.top))
            .with(ObjectAnimator.ofFloat(snapshotView, View.SCALE_X, 1, finalScale))
            .with(ObjectAnimator.ofFloat(snapshotView, View.SCALE_Y, 1, finalScale))
            .with(ObjectAnimator.ofFloat(profileImageView, View.ALPHA, 1, 0))
            .with(ObjectAnimator.ofFloat(clickedImageView, View.SCALE_X, 0, 1))
            .with(ObjectAnimator.ofFloat(clickedImageView, View.SCALE_Y, 0, 1));
    final long animationTransition = 400;
    set.setDuration(animationTransition);
    set.setInterpolator(new DecelerateInterpolator());
    set.addListener(new AnimatorListener() {

        private Drawable clickedDrawable;
        private int[] clickedColors;

        @Override
        public void onAnimationStart(Animator animation) {
            snapshotView.setVisibility(View.VISIBLE);
            snapshotView.setImageBitmap(snapshotBitmap);
            final Drawable profileDrawable = profileImageView.getDrawable();
            clickedDrawable = clickedImageView.getDrawable();
            clickedColors = clickedImageView.getBorderColors();
            final ParcelableAccount oldSelectedAccount = mAccountsAdapter.getSelectedAccount();
            mImageLoader.displayDashboardProfileImage(clickedImageView, oldSelectedAccount.profile_image_url,
                    profileDrawable);
            //                mImageLoader.displayDashboardProfileImage(profileImageView,
            //                        account.profile_image_url, clickedDrawable);
            clickedImageView.setBorderColors(profileImageView.getBorderColors());
            mSwitchAccountAnimationPlaying = true;
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            finishAnimation();
        }

        @Override
        public void onAnimationCancel(Animator animation) {
            finishAnimation();
        }

        @Override
        public void onAnimationRepeat(Animator animation) {

        }

        private void finishAnimation() {
            final Editor editor = mPreferences.edit();
            editor.putLong(KEY_DEFAULT_ACCOUNT_ID, account.account_id);
            editor.apply();
            mAccountsAdapter.setSelectedAccountId(account.account_id);
            mAccountOptionsAdapter.setSelectedAccount(account);
            updateAccountOptionsSeparatorLabel(clickedDrawable);
            snapshotView.setVisibility(View.INVISIBLE);
            snapshotView.setImageDrawable(null);
            profileImageView.setImageDrawable(clickedDrawable);
            profileImageView.setBorderColors(clickedColors);
            profileImageView.setAlpha(1f);
            clickedImageView.setScaleX(1);
            clickedImageView.setScaleY(1);
            clickedImageView.setAlpha(1f);
            mSwitchAccountAnimationPlaying = false;
        }
    });
    set.start();
}

From source file:com.android.deskclock.timer.TimerFullScreenFragment.java

private void gotoSetupView() {
    if (mLastVisibleView == null || mLastVisibleView.getId() == R.id.timer_setup) {
        mTimerSetup.setVisibility(View.VISIBLE);
        mTimerSetup.setScaleX(1f);//from   ww w  .j  a  va 2 s .  c  o m
        mTimersListPage.setVisibility(View.GONE);
    } else {
        // Animate
        ObjectAnimator a = ObjectAnimator.ofFloat(mTimersListPage, View.SCALE_X, 1f, 0f);
        a.setInterpolator(new AccelerateInterpolator());
        a.setDuration(125);
        a.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                mTimersListPage.setVisibility(View.GONE);
                mTimerSetup.setScaleX(0);
                mTimerSetup.setVisibility(View.VISIBLE);
                ObjectAnimator b = ObjectAnimator.ofFloat(mTimerSetup, View.SCALE_X, 0f, 1f);
                b.setInterpolator(new DecelerateInterpolator());
                b.setDuration(225);
                b.start();
            }
        });
        a.start();

    }
    stopClockTicks();
    mTimerSetup.updateDeleteButtonAndDivider();
    mLastVisibleView = mTimerSetup;
}

From source file:org.mariotaku.twidere.fragment.AccountsDashboardFragment.java

private void onAccountSelected(AccountProfileImageViewHolder holder, @NonNull final ParcelableAccount account) {
    if (mSwitchAccountAnimationPlaying)
        return;//from w  w  w . j  a v  a 2s  .  c o  m
    final ImageView snapshotView = mFloatingProfileImageSnapshotView;
    final ShapedImageView profileImageView = mAccountProfileImageView;
    final ShapedImageView clickedImageView = holder.getIconView();

    // Reset snapshot view position
    snapshotView.setPivotX(0);
    snapshotView.setPivotY(0);
    snapshotView.setTranslationX(0);
    snapshotView.setTranslationY(0);

    final Matrix matrix = new Matrix();
    final RectF sourceBounds = new RectF(), destBounds = new RectF(), snapshotBounds = new RectF();
    getLocationOnScreen(clickedImageView, sourceBounds);
    getLocationOnScreen(profileImageView, destBounds);
    getLocationOnScreen(snapshotView, snapshotBounds);
    final float finalScale = destBounds.width() / sourceBounds.width();
    final Bitmap snapshotBitmap = TransitionUtils.createViewBitmap(clickedImageView, matrix,
            new RectF(0, 0, sourceBounds.width(), sourceBounds.height()));
    final ViewGroup.LayoutParams lp = snapshotView.getLayoutParams();
    lp.width = clickedImageView.getWidth();
    lp.height = clickedImageView.getHeight();
    snapshotView.setLayoutParams(lp);
    // Copied from MaterialNavigationDrawer: https://github.com/madcyph3r/AdvancedMaterialDrawer/
    AnimatorSet set = new AnimatorSet();
    set.play(ObjectAnimator.ofFloat(snapshotView, View.TRANSLATION_X, sourceBounds.left - snapshotBounds.left,
            destBounds.left - snapshotBounds.left))
            .with(ObjectAnimator.ofFloat(snapshotView, View.TRANSLATION_Y,
                    sourceBounds.top - snapshotBounds.top, destBounds.top - snapshotBounds.top))
            .with(ObjectAnimator.ofFloat(snapshotView, View.SCALE_X, 1, finalScale))
            .with(ObjectAnimator.ofFloat(snapshotView, View.SCALE_Y, 1, finalScale))
            .with(ObjectAnimator.ofFloat(profileImageView, View.ALPHA, 1, 0))
            .with(ObjectAnimator.ofFloat(clickedImageView, View.SCALE_X, 0, 1))
            .with(ObjectAnimator.ofFloat(clickedImageView, View.SCALE_Y, 0, 1));
    final long animationTransition = 400;
    set.setDuration(animationTransition);
    set.setInterpolator(new DecelerateInterpolator());
    set.addListener(new AnimatorListener() {

        private Drawable clickedDrawable;
        private int[] clickedColors;

        @Override
        public void onAnimationStart(Animator animation) {
            snapshotView.setVisibility(View.VISIBLE);
            snapshotView.setImageBitmap(snapshotBitmap);
            final Drawable profileDrawable = profileImageView.getDrawable();
            clickedDrawable = clickedImageView.getDrawable();
            clickedColors = clickedImageView.getBorderColors();
            final ParcelableAccount oldSelectedAccount = mAccountsAdapter.getSelectedAccount();
            if (oldSelectedAccount == null)
                return;
            mMediaLoader.displayDashboardProfileImage(clickedImageView, oldSelectedAccount, profileDrawable);
            clickedImageView.setBorderColors(profileImageView.getBorderColors());

            displayAccountBanner(account);

            mSwitchAccountAnimationPlaying = true;
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            finishAnimation();
        }

        @Override
        public void onAnimationCancel(Animator animation) {
            finishAnimation();
        }

        @Override
        public void onAnimationRepeat(Animator animation) {

        }

        private void finishAnimation() {
            final Editor editor = mPreferences.edit();
            editor.putString(KEY_DEFAULT_ACCOUNT_KEY, account.account_key.toString());
            editor.apply();
            mAccountsAdapter.setSelectedAccount(account);
            updateAccountActions();
            displayCurrentAccount(clickedDrawable);
            snapshotView.setVisibility(View.INVISIBLE);
            snapshotView.setImageDrawable(null);
            profileImageView.setImageDrawable(clickedDrawable);
            profileImageView.setBorderColors(clickedColors);
            profileImageView.setAlpha(1f);
            clickedImageView.setScaleX(1);
            clickedImageView.setScaleY(1);
            clickedImageView.setAlpha(1f);
            mSwitchAccountAnimationPlaying = false;
        }
    });
    set.start();

}

From source file:com.smc.tw.waltz.MainActivity.java

private void showToolbar() {
    getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
    mToolbar.animate().translationY(0).setInterpolator(new DecelerateInterpolator()).start();

    mToolbar.setVisibility(View.VISIBLE);

    mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);
}

From source file:com.fastbootmobile.encore.utils.Utils.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static Animator animateCircleReveal(final View view, final int cx, final int cy, final int startRadius,
        final int endRadius, final long duration, final long startDelay) {
    Animator animator = ViewAnimationUtils.createCircularReveal(view, cx, cy, startRadius, endRadius)
            .setDuration(duration);//from w  w w  .j  a  v  a 2s  .  c  o m
    animator.setStartDelay(startDelay);
    animator.setInterpolator(new DecelerateInterpolator());
    animator.addListener(new Animator.AnimatorListener() {
        @Override
        public void onAnimationStart(Animator animation) {
            view.setVisibility(View.VISIBLE);
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            if (startRadius > endRadius) {
                view.setVisibility(View.INVISIBLE);
            }
        }

        @Override
        public void onAnimationCancel(Animator animation) {

        }

        @Override
        public void onAnimationRepeat(Animator animation) {

        }
    });
    animator.start();

    return animator;
}

From source file:com.android.deskclock.timer.TimerFullScreenFragment.java

private void gotoTimersView() {
    if (mLastVisibleView == null || mLastVisibleView.getId() == R.id.timers_list_page) {
        mTimerSetup.setVisibility(View.GONE);
        mTimersListPage.setVisibility(View.VISIBLE);
        mTimersListPage.setScaleX(1f);//w  ww .  ja  va 2 s  . c  o  m
    } else {
        // Animate
        ObjectAnimator a = ObjectAnimator.ofFloat(mTimerSetup, View.SCALE_X, 1f, 0f);
        a.setInterpolator(new AccelerateInterpolator());
        a.setDuration(125);
        a.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                mTimerSetup.setVisibility(View.GONE);
                mTimersListPage.setScaleX(0);
                mTimersListPage.setVisibility(View.VISIBLE);
                ObjectAnimator b = ObjectAnimator.ofFloat(mTimersListPage, View.SCALE_X, 0f, 1f);
                b.setInterpolator(new DecelerateInterpolator());
                b.setDuration(225);
                b.start();
            }
        });
        a.start();
    }
    startClockTicks();
    mLastVisibleView = mTimersListPage;
}