Example usage for android.view.animation AccelerateInterpolator AccelerateInterpolator

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

Introduction

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

Prototype

public AccelerateInterpolator() 

Source Link

Usage

From source file:com.adityarathi.muo.ui.activities.NowPlayingActivity.java

/**
 * Animates the play button to a pause button.
 *///from   w w  w. j av a2 s  .  c o  m
private void animatePlayToPause() {

    //Check to make sure the current icon is the play icon.
    if (mPlayPauseButton.getId() != R.drawable.ic_play)
        return;

    //Fade out the play button.
    final ScaleAnimation scaleOut = new ScaleAnimation(1.0f, 0.0f, 1.0f, 0.0f, mPlayPauseButton.getWidth() / 2,
            mPlayPauseButton.getHeight() / 2);
    scaleOut.setDuration(150);
    scaleOut.setInterpolator(new AccelerateInterpolator());

    //Scale in the pause button.
    final ScaleAnimation scaleIn = new ScaleAnimation(0.0f, 1.0f, 0.0f, 1.0f, mPlayPauseButton.getWidth() / 2,
            mPlayPauseButton.getHeight() / 2);
    scaleIn.setDuration(150);
    scaleIn.setInterpolator(new DecelerateInterpolator());

    scaleOut.setAnimationListener(new Animation.AnimationListener() {

        @Override
        public void onAnimationStart(Animation animation) {

        }

        @Override
        public void onAnimationEnd(Animation animation) {
            mPlayPauseButton.setImageResource(R.drawable.ic_play);
            mPlayPauseButton.setPadding(0, 0, 0, 0);
            mPlayPauseButton.startAnimation(scaleIn);
        }

        @Override
        public void onAnimationRepeat(Animation animation) {

        }

    });

    scaleIn.setAnimationListener(new Animation.AnimationListener() {

        @Override
        public void onAnimationStart(Animation animation) {

        }

        @Override
        public void onAnimationEnd(Animation animation) {
            mPlayPauseButton.setScaleX(1.0f);
            mPlayPauseButton.setScaleY(1.0f);
            mPlayPauseButton.setId(R.drawable.ic_play);
        }

        @Override
        public void onAnimationRepeat(Animation animation) {

        }

    });

    mPlayPauseButton.startAnimation(scaleOut);
}

From source file:org.michaelbel.bottomsheet.BottomSheet.java

@Override
public void dismiss() {
    if (dismissed) {
        return;/*from w ww.  j a v a 2 s.  c  o m*/
    }

    dismissed = true;
    cancelSheetAnimation();

    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.playTogether(
            ObjectAnimator.ofFloat(containerView, "translationY",
                    containerView.getMeasuredHeight() + Utils.dp(getContext(), 10)),
            ObjectAnimator.ofInt(backDrawable, "alpha", 0));
    if (useFastDismiss) {
        int height = containerView.getMeasuredHeight();
        animatorSet.setDuration(
                Math.max(60, (int) (180 * (height - containerView.getTranslationY()) / (float) height)));
        useFastDismiss = false;
    } else {
        animatorSet.setDuration(180);
    }
    animatorSet.setInterpolator(new AccelerateInterpolator());
    animatorSet.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            if (currentSheetAnimation != null && currentSheetAnimation.equals(animation)) {
                currentSheetAnimation = null;
                handler.post(new Runnable() {
                    @Override
                    public void run() {
                        try {
                            dismissInternal();
                        } catch (Exception e) {
                            Log.e(TAG, e.getMessage());
                        }
                    }
                });
            }
        }

        @Override
        public void onAnimationCancel(Animator animation) {
            super.onAnimationCancel(animation);
            if (currentSheetAnimation != null && currentSheetAnimation.equals(animation)) {
                currentSheetAnimation = null;
            }
        }
    });
    animatorSet.start();
    currentSheetAnimation = animatorSet;

    if (bottomSheetCallBack != null) {
        bottomSheetCallBack.onClose();
    }
}

From source file:com.sinyuk.jianyimaterial.widgets.FloatingToolbar.java

private void hideDefaultImpl() {
    ViewCompat.animate(mFab).x(mFabOriginalX).y(mFabOriginalY).scaleX(1f).scaleY(1f)
            .setStartDelay(FAB_UNMORPH_DELAY).setDuration(FAB_UNMORPH_DURATION)
            .setInterpolator(new AccelerateInterpolator())
            .setListener(new ViewPropertyAnimatorListenerAdapter() {
                @Override/*from ww  w.  j  av a  2s .c om*/
                public void onAnimationStart(View view) {
                    super.onAnimationStart(view);
                    mFab.setVisibility(View.VISIBLE);
                    ViewCompat.animate(mFab).setListener(null);
                }
            });

    ViewCompat.animate(this).scaleX(0f).setDuration(CIRCULAR_UNREVEAL_DURATION)
            .setStartDelay(CIRCULAR_UNREVEAL_DELAY).setInterpolator(new AccelerateDecelerateInterpolator())
            .setListener(new ViewPropertyAnimatorListenerAdapter() {

                @Override
                public void onAnimationEnd(View view) {
                    super.onAnimationEnd(view);
                    setVisibility(View.INVISIBLE);
                    ViewCompat.animate(FloatingToolbar.this).setListener(null);
                    mMorphing = false;
                }
            });
}

From source file:org.sufficientlysecure.keychain.ui.BackupCodeFragment.java

private static void animateFlashText(final TextView[] textViews, int color1, int color2,
        boolean staySecondColor) {

    ValueAnimator anim = ValueAnimator.ofObject(new ArgbEvaluator(), color1, color2);
    anim.addUpdateListener(new AnimatorUpdateListener() {
        @Override//from  w  ww.  j a  v  a2  s  . c om
        public void onAnimationUpdate(ValueAnimator animator) {
            for (TextView textView : textViews) {
                textView.setTextColor((Integer) animator.getAnimatedValue());
            }
        }
    });
    anim.setRepeatMode(ValueAnimator.REVERSE);
    anim.setRepeatCount(staySecondColor ? 4 : 5);
    anim.setDuration(180);
    anim.setInterpolator(new AccelerateInterpolator());
    anim.start();

}

From source file:com.adityarathi.muo.ui.activities.NowPlayingActivity.java

/**
 * Animates the pause button to a play button.
 *///from www.ja v  a2  s. co  m
private void animatePauseToPlay() {

    //Check to make sure the current icon is the pause icon.
    if (mPlayPauseButton.getId() != R.drawable.ic_play)
        return;

    //Scale out the pause button.
    final ScaleAnimation scaleOut = new ScaleAnimation(1.0f, 0.0f, 1.0f, 0.0f, mPlayPauseButton.getWidth() / 2,
            mPlayPauseButton.getHeight() / 2);
    scaleOut.setDuration(150);
    scaleOut.setInterpolator(new AccelerateInterpolator());

    //Scale in the play button.
    final ScaleAnimation scaleIn = new ScaleAnimation(0.0f, 1.0f, 0.0f, 1.0f, mPlayPauseButton.getWidth() / 2,
            mPlayPauseButton.getHeight() / 2);
    scaleIn.setDuration(150);
    scaleIn.setInterpolator(new DecelerateInterpolator());

    scaleOut.setAnimationListener(new Animation.AnimationListener() {

        @Override
        public void onAnimationStart(Animation animation) {

        }

        @Override
        public void onAnimationEnd(Animation animation) {
            mPlayPauseButton.setImageResource(R.drawable.ic_play);
            mPlayPauseButton.setPadding(0, 0, -5, 0);
            mPlayPauseButton.startAnimation(scaleIn);
        }

        @Override
        public void onAnimationRepeat(Animation animation) {

        }

    });

    scaleIn.setAnimationListener(new Animation.AnimationListener() {

        @Override
        public void onAnimationStart(Animation animation) {

        }

        @Override
        public void onAnimationEnd(Animation animation) {
            mPlayPauseButton.setScaleX(1.0f);
            mPlayPauseButton.setScaleY(1.0f);
            mPlayPauseButton.setId(R.drawable.ic_play);
        }

        @Override
        public void onAnimationRepeat(Animation animation) {

        }

    });

    mPlayPauseButton.startAnimation(scaleOut);
}

From source file:de.tap.easy_xkcd.Activities.MainActivity.java

private void animateToolbar(int translation) {
    View view;/* w  w  w.  j a v a 2  s.  c o m*/
    for (int i = 2; i < toolbar.getChildCount(); i++) {
        view = toolbar.getChildAt(i);
        view.setTranslationY(translation);
        view.animate().setStartDelay(50 * (i + 1)).setDuration(70 * (i + 1)).translationY(0);
    }
    toolbar.getChildAt(0).setAlpha(0);
    toolbar.getChildAt(0).animate().alpha(1).setDuration(200).setInterpolator(new AccelerateInterpolator());
}

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

/**
 * @param timerToRemove the timer to be removed during the animation
 *///from w w  w .  ja va  2  s. com
private void animateTimerRemove(final Timer timerToRemove) {
    final Animator fadeOut = ObjectAnimator.ofFloat(mViewPager, ALPHA, 1, 0);
    fadeOut.setDuration(mShortAnimationDuration);
    fadeOut.setInterpolator(new DecelerateInterpolator());
    fadeOut.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            DataModel.getDataModel().removeTimer(timerToRemove);
            Events.sendTimerEvent(R.string.action_delete, R.string.label_deskclock);
        }
    });

    final Animator fadeIn = ObjectAnimator.ofFloat(mViewPager, ALPHA, 0, 1);
    fadeIn.setDuration(mShortAnimationDuration);
    fadeIn.setInterpolator(new AccelerateInterpolator());

    final AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.play(fadeOut).before(fadeIn);
    animatorSet.start();
}

From source file:com.example.myronlg.cardviewpagerdemo.MultiCardViewPager.java

void initViewPager() {

    getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
        @Override/*from   ww  w  . j  a va2 s  . com*/
        public void onGlobalLayout() {
            itemScrollOffset = (int) (getClientWidth() * mAdapter.getPageWidth(0));
            //                int maxScrollX = (int) (2*getClientWidth()*mAdapter.getPageWidth(0) + (mAdapter.getCount() - 2) * getClientWidth() * mAdapter.getPageWidth(1) - getWidth() + getClientWidth()*0.5F);
            maxScrollX = (int) (getClientWidth() * (2 * mAdapter.getPageWidth(0)
                    + (mAdapter.getCount() - 2) * mAdapter.getPageWidth(1) - 1 + 0.0F));
            minScrollX = (int) (-getClientWidth() * 0.0F);
            //                itemScrollOffset = 0;
            getViewTreeObserver().removeOnGlobalLayoutListener(this);
        }
    });

    setWillNotDraw(false);
    setDescendantFocusability(FOCUS_AFTER_DESCENDANTS);
    setFocusable(true);
    final Context context = getContext();
    mScroller = new Scroller(context, sInterpolator);

    myScroller = new Scroller(context, new AccelerateInterpolator());
    final ViewConfiguration configuration = ViewConfiguration.get(context);
    final float density = context.getResources().getDisplayMetrics().density;

    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
    mMinimumVelocity = (int) (MIN_FLING_VELOCITY * density);
    mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
    mLeftEdge = new EdgeEffectCompat(context);
    mRightEdge = new EdgeEffectCompat(context);

    mFlingDistance = (int) (MIN_DISTANCE_FOR_FLING * density);
    mCloseEnough = (int) (CLOSE_ENOUGH * density);
    mDefaultGutterSize = (int) (DEFAULT_GUTTER_SIZE * density);

    ViewCompat.setAccessibilityDelegate(this, new MyAccessibilityDelegate());

    if (ViewCompat.getImportantForAccessibility(this) == ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_AUTO) {
        ViewCompat.setImportantForAccessibility(this, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES);
    }
}

From source file:com.geecko.QuickLyric.adapter.IntroScreenSlidePagerAdapter.java

public void exitAction() {
    Animation slideOut = new TranslateAnimation(0f, -2000f, 0f, 0f);
    slideOut.setInterpolator(new AccelerateInterpolator());
    slideOut.setDuration(700);//from  w  w  w .ja va2s  . c  o  m

    slideOut.setAnimationListener(new Animation.AnimationListener() {
        public void onAnimationEnd(Animation animation) {
            IntroScreenSlidePagerAdapter.this.onAnimationEnd();
        }

        public void onAnimationRepeat(Animation animation) {
        }

        public void onAnimationStart(Animation animation) {
        }
    });
    if (mActivity instanceof AboutActivity)
        ((AboutActivity) mActivity).setStatusBarColor(null);
    else
        MainActivity.setStatusBarColor(mActivity.getWindow(), mActivity.getTheme(), null);
    MainActivity.setNavBarColor(mActivity.getWindow(), mActivity.getTheme(), null);
    ((RelativeLayout) mPager.getParent()).startAnimation(slideOut);
}

From source file:com.taobao.weex.ui.animation.WXAnimationModule.java

private static @Nullable Interpolator createTimeInterpolator(@NonNull WXAnimationBean animation) {
    String interpolator = animation.timingFunction;
    if (!TextUtils.isEmpty(interpolator)) {
        switch (interpolator) {
        case WXAnimationBean.EASE_IN:
            return new AccelerateInterpolator();
        case WXAnimationBean.EASE_OUT:
            return new DecelerateInterpolator();
        case WXAnimationBean.EASE_IN_OUT:
            return new AccelerateDecelerateInterpolator();
        case WXAnimationBean.LINEAR:
            return new LinearInterpolator();
        default:/*from  w w w  .  jav  a2 s  . c  o  m*/
            //Parse cubic-bezier
            try {
                SingleFunctionParser<Float> parser = new SingleFunctionParser<>(animation.timingFunction,
                        new SingleFunctionParser.FlatMapper<Float>() {
                            @Override
                            public Float map(String raw) {
                                return Float.parseFloat(raw);
                            }
                        });
                List<Float> params = parser.parse(WXAnimationBean.CUBIC_BEZIER);
                if (params != null && params.size() == WXAnimationBean.NUM_CUBIC_PARAM) {
                    return PathInterpolatorCompat.create(params.get(0), params.get(1), params.get(2),
                            params.get(3));
                } else {
                    return null;
                }
            } catch (RuntimeException e) {
                return null;
            }
        }
    }
    return null;
}