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:ca.zadrox.dota2esportticker.ui.LiveContentView.java

@Override
public void setPlayerItem(int playerSlot, int itemSlot, int resId) {
    ImageView imageView = (ImageView) mPlayerLayouts[playerSlot].findViewById(itemViewIds[itemSlot]);
    switch (resId) {
    case 0:/*from   w  w  w  .  jav a 2 s .c om*/
        imageView.animate().setDuration(200).alpha(0).setInterpolator(new AccelerateInterpolator());
    default:
        imageView.setImageResource(resId);
        imageView.animate().setDuration(200).alpha(1).setInterpolator(new DecelerateInterpolator());
    }
}

From source file:orbin.deskclock.timer.TimerFragment.java

/**
 * @param toView one of {@link #mTimersView} or {@link #mCreateTimerView}
 * @param timerToRemove the timer to be removed during the animation; {@code null} if no timer
 *      should be removed//from   w w  w.ja  v a 2 s.co m
 */
private void animateToView(View toView, final Timer timerToRemove) {
    if (mCurrentView == toView) {
        throw new IllegalStateException("toView is already the current view");
    }

    final boolean toTimers = toView == mTimersView;

    // Avoid double-taps by enabling/disabling the set of buttons active on the new view.
    updateFab(DISABLE_BUTTONS);

    final long duration = UiDataModel.getUiDataModel().getShortAnimationDuration();
    final Animator rotateFrom = ObjectAnimator.ofFloat(mCurrentView, SCALE_X, 1, 0);
    rotateFrom.setDuration(duration);
    rotateFrom.setInterpolator(new DecelerateInterpolator());
    rotateFrom.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            if (timerToRemove != null) {
                DataModel.getDataModel().removeTimer(timerToRemove);
                Events.sendTimerEvent(R.string.action_delete, R.string.label_deskclock);
            }

            mCurrentView.setScaleX(1);
            if (toTimers) {
                showTimersView(FAB_AND_BUTTONS_SHRINK_AND_EXPAND);
            } else {
                showCreateTimerView(FAB_AND_BUTTONS_SHRINK_AND_EXPAND);
            }
        }
    });

    final Animator rotateTo = ObjectAnimator.ofFloat(toView, SCALE_X, 0, 1);
    rotateTo.setDuration(duration);
    rotateTo.setInterpolator(new AccelerateInterpolator());

    final AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.play(rotateFrom).before(rotateTo);
    animatorSet.start();
}

From source file:com.shizhefei.view.largeimage.LargeImageView.java

public void smoothScale(float newScale, int centerX, int centerY) {
    if (mScale > newScale) {
        if (accelerateInterpolator == null) {
            accelerateInterpolator = new AccelerateInterpolator();
        }//from   ww  w.j  ava2s.  c om
        scaleHelper.startScale(mScale, newScale, centerX, centerY, accelerateInterpolator);
    } else {
        if (decelerateInterpolator == null) {
            decelerateInterpolator = new DecelerateInterpolator();
        }
        scaleHelper.startScale(mScale, newScale, centerX, centerY, decelerateInterpolator);
    }
    notifyInvalidate();
}

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 {//from  w  w w  . j a v  a2s .co 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.stasbar.knowyourself.timer.TimerFragment.java

/**
 * @param toView        one of {@link #mTimersView} or {@link #mCreateTimerView}
 * @param timerToRemove the timer to be removed during the animation; {@code null} if no timer
 *                      should be removed
 *//*from  w  w w .  j  a  v  a 2 s  .  c  om*/
private void animateToView(View toView, final Timer timerToRemove) {
    if (mCurrentView == toView) {
        return;
    }

    final boolean toTimers = toView == mTimersView;

    final long duration = UiDataModel.getUiDataModel().getShortAnimationDuration();
    final Animator rotateFrom = ObjectAnimator.ofFloat(mCurrentView, SCALE_X, 1, 0);
    rotateFrom.setDuration(duration);
    rotateFrom.setInterpolator(new DecelerateInterpolator());
    rotateFrom.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            if (timerToRemove != null) {
                DataModel.getDataModel().removeTimer(timerToRemove);
                ((MainActivity) getActivity()).stopActivity(activityItem, timerToRemove);
            }

            mCurrentView.setScaleX(1);
            if (toTimers) {
                showTimersView();
            } else {
                showCreateTimerView();
            }

        }
    });

    final Animator rotateTo = ObjectAnimator.ofFloat(toView, SCALE_X, 0, 1);
    rotateTo.setDuration(duration);
    rotateTo.setInterpolator(new AccelerateInterpolator());

    final AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.play(rotateFrom).before(rotateTo);
    animatorSet.start();
}

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

/**
 * @param toView one of {@link #mTimersView} or {@link #mCreateTimerView}
 * @param timerToRemove the timer to be removed during the animation; {@code null} if no timer
 *      should be removed//  w  w w.  j ava2s  .co  m
 */
private void animateToView(View toView, final Timer timerToRemove) {
    if (mCurrentView == toView) {
        throw new IllegalStateException("toView is already the current view");
    }

    final boolean toTimers = toView == mTimersView;

    // Avoid double-taps by enabling/disabling the set of buttons active on the new view.
    updateFab(UpdateType.DISABLE_BUTTONS);

    final long duration = UiDataModel.getUiDataModel().getShortAnimationDuration();
    final Animator rotateFrom = ObjectAnimator.ofFloat(mCurrentView, SCALE_X, 1, 0);
    rotateFrom.setDuration(duration);
    rotateFrom.setInterpolator(new DecelerateInterpolator());
    rotateFrom.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            if (timerToRemove != null) {
                DataModel.getDataModel().removeTimer(timerToRemove);
                Events.sendTimerEvent(com.wizardsofm.deskclock.R.string.action_delete,
                        com.wizardsofm.deskclock.R.string.label_deskclock);
            }

            mCurrentView.setScaleX(1);
            if (toTimers) {
                showTimersView(UpdateType.FAB_AND_BUTTONS_SHRINK_AND_EXPAND);
            } else {
                showCreateTimerView(UpdateType.FAB_AND_BUTTONS_SHRINK_AND_EXPAND);
            }
        }
    });

    final Animator rotateTo = ObjectAnimator.ofFloat(toView, SCALE_X, 0, 1);
    rotateTo.setDuration(duration);
    rotateTo.setInterpolator(new AccelerateInterpolator());

    final AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.play(rotateFrom).before(rotateTo);
    animatorSet.start();
}

From source file:io.bunnyblue.noticedog.app.lockscreen.ui.LockScreenWidget.java

void changeState(WidgetState nextState) {
    Log.d(TAG, "Switching state from: " + this.currentState + " to: " + nextState);
    LayoutParams layoutParams;/*ww  w  . j  a v a 2s  .c om*/
    switch (nextState) {
    case stateShown:
        this.widgetView.clearAnimation();
        this.widgetView.setX(0.0f);
        this.widgetView.setAlpha(0.0f);
        this.widgetView.animate().alpha(0.0f).setDuration(0).withEndAction(new Runnable() {
            public void run() {
                LockScreenWidget.this.widgetView.animate().alpha(DefaultRetryPolicy.DEFAULT_BACKOFF_MULT)
                        .setDuration(200).setInterpolator(new DecelerateInterpolator())
                        .withEndAction(new Runnable() {
                            public void run() {
                                LockScreenWidget.this.enableTouchOnRootView(true);
                                LockScreenWidget.this.currentState = WidgetState.stateShown;
                            }
                        });
            }
        });
        this.currentState = WidgetState.stateInterpolatingToShown;
        return;
    case stateUnlockToContinueShown:
        enableTouchOnRootView(false);
        this.unlockToContinueView = ((LayoutInflater) this.context
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE))
                        .inflate(R.layout.lockscreen_unlock_to_continue_view, null);
        addToFullscreenView(this.unlockToContinueView);
        ViewGroup.LayoutParams layoutParams2 = this.unlockToContinueView.getLayoutParams();
        layoutParams2.width = -1;
        this.unlockToContinueView.setLayoutParams(layoutParams2);
        this.unlockToContinueView.setAlpha(0.0f);
        this.widgetView.clearAnimation();
        this.widgetView.animate().alpha(0.0f).setDuration(200).setInterpolator(new AccelerateInterpolator())
                .withEndAction(new Runnable() {
                    public void run() {
                        LockScreenWidget.this.unlockToContinueView.animate()
                                .alpha(DefaultRetryPolicy.DEFAULT_BACKOFF_MULT).setDuration(200)
                                .setStartDelay(100).setInterpolator(new DecelerateInterpolator())
                                .withEndAction(new Runnable() {
                                    public void run() {
                                        LockScreenWidget.this.currentState = WidgetState.stateUnlockToContinueShown;
                                    }
                                });
                    }
                });
        this.currentState = WidgetState.stateInterpolatingToUnlockToContinueShown;
        return;
    case stateUnlockToContinueHidden:
        enableTouchOnRootView(false);
        this.widgetView.clearAnimation();
        this.unlockToContinueView.clearAnimation();
        this.unlockToContinueView.animate().alpha(0.0f).setDuration(200)
                .setInterpolator(new AccelerateInterpolator()).withEndAction(new Runnable() {
                    public void run() {
                        LockScreenWidget.this.widgetView.animate()
                                .alpha(DefaultRetryPolicy.DEFAULT_BACKOFF_MULT).setDuration(200)
                                .setStartDelay(100).setInterpolator(new DecelerateInterpolator())
                                .withEndAction(new Runnable() {
                                    public void run() {
                                        LockScreenWidget.this.currentState = WidgetState.stateShown;
                                        LockScreenWidget.this.clearFullscreenView();
                                        LockScreenWidget.this.unlockToContinueView = null;
                                        LockScreenWidget.this.enableTouchOnRootView(true);
                                        LockScreenWidget.this.currentState = WidgetState.stateShown;
                                    }
                                });
                    }
                });
        this.currentState = WidgetState.stateInterpolatingToUnlockToContinueHidden;
        return;
    case stateCleared:
        enableTouchOnRootView(false);
        this.widgetView.clearAnimation();
        this.widgetView.animate().alpha(0.0f).setDuration(200).setInterpolator(new AccelerateInterpolator())
                .withEndAction(new Runnable() {
                    public void run() {
                        if (LockScreenWidget.this.listener != null) {
                            LockScreenWidget.this.listener.onWidgetCleared();
                        }
                        LockScreenWidget.this.currentState = WidgetState.stateCleared;
                    }
                });
        this.currentState = WidgetState.stateInterpolatingToCleared;
        return;
    case stateMoving:
        this.widgetView.clearAnimation();
        layoutParams = (LayoutParams) this.rootView.getLayoutParams();
        this.screenshotView = duplicateView(this.widgetView);
        this.screenshotView.setY((float) layoutParams.y);
        Log.d(TAG, "Setting widget view screenshot to Y position = " + layoutParams.y);
        addToFullscreenView(this.screenshotView);
        this.widgetView.animate().alpha(0.0f).setDuration(0).setStartDelay(100);
        this.screenshotView.animate().scaleX(RELOCATE_WINDOW_SCALE).scaleY(RELOCATE_WINDOW_SCALE)
                .setDuration(200).withEndAction(new Runnable() {
                    public void run() {
                        LockScreenWidget.this.currentState = WidgetState.stateMoving;
                    }
                });
        this.screenshotView.performHapticFeedback(3, 2);
        this.currentState = WidgetState.stateInterpolatingToMoving;
        return;
    case stateStopMoving:
        WindowManager windowManager = (WindowManager) this.context.getSystemService("window");
        layoutParams = (LayoutParams) this.rootView.getLayoutParams();
        layoutParams.y = (int) this.screenshotView.getY();
        windowManager.updateViewLayout(this.rootView, layoutParams);
        this.screenshotView.setScaleY(RELOCATE_WINDOW_SCALE);
        this.screenshotView.setScaleX(RELOCATE_WINDOW_SCALE);
        this.screenshotView.animate().scaleY(DefaultRetryPolicy.DEFAULT_BACKOFF_MULT)
                .scaleX(DefaultRetryPolicy.DEFAULT_BACKOFF_MULT).setDuration(200).withEndAction(new Runnable() {
                    public void run() {
                        LockScreenWidget.this.widgetView.animate()
                                .alpha(DefaultRetryPolicy.DEFAULT_BACKOFF_MULT).setDuration(0)
                                .withEndAction(new Runnable() {
                                    public void run() {
                                        LockScreenWidget.this.clearFullscreenView();
                                        LockScreenWidget.this.screenshotView = null;
                                        LockScreenWidget.this.currentState = WidgetState.stateShown;
                                    }
                                });
                    }
                });
        ((Settings) GuiceModule.get().getInstance(Settings.class))
                .updateLockscreenWidgetY(this.screenshotView.getY());
        this.currentState = WidgetState.stateInterpolatingToStopMoving;
        Log.d(TAG, "Restoring widget view at Y position = " + layoutParams.y + " with height = "
                + layoutParams.height);
        return;
    case stateHidden:
        enableTouchOnRootView(false);
        this.widgetView.clearAnimation();
        this.widgetView.animate().alpha(0.0f).setDuration(200).setInterpolator(new AccelerateInterpolator())
                .withEndAction(new Runnable() {
                    public void run() {
                        LockScreenWidget.this.enableTouchOnRootView(false);
                        LockScreenWidget.this.currentState = WidgetState.stateHidden;
                    }
                });
        this.currentState = WidgetState.stateInterpolatingToHidden;
        return;
    case stateTerminated:
        enableTouchOnRootView(false);
        this.widgetView.clearAnimation();
        this.fullscreenView.clearAnimation();
        if (this.unlockToContinueView != null) {
            this.unlockToContinueView.clearAnimation();
            this.unlockToContinueView.animate().alpha(0.0f).setDuration(200)
                    .setInterpolator(new AccelerateInterpolator());
        }
        this.widgetView.animate().alpha(0.0f).setDuration(200).setInterpolator(new AccelerateInterpolator())
                .withEndAction(new Runnable() {
                    public void run() {
                        WindowManager wm = (WindowManager) LockScreenWidget.this.context
                                .getSystemService("window");
                        try {
                            wm.removeView(LockScreenWidget.this.fullscreenView);
                        } catch (Exception e) {
                        }
                        try {
                            wm.removeView(LockScreenWidget.this.rootView);
                        } catch (Exception e2) {
                        }
                        LockScreenWidget.this.widgetView = null;
                        LockScreenWidget.this.screenshotView = null;
                        LockScreenWidget.this.unlockToContinueView = null;
                        LockScreenWidget.this.fullscreenView = null;
                        LockScreenWidget.this.rootView = null;
                        LockScreenWidget.this.context = null;
                        LockScreenWidget.this.currentState = WidgetState.stateTerminated;
                    }
                });
        this.currentState = WidgetState.stateInterpolatingToTerminated;
        return;
    default:
        return;
    }
}

From source file:android.support.v17.leanback.app.PlaybackSupportFragment.java

private void loadOtherRowAnimator() {
    final AnimatorUpdateListener updateListener = new AnimatorUpdateListener() {
        @Override/* w w  w. j  a  va 2s .  c o m*/
        public void onAnimationUpdate(ValueAnimator arg0) {
            if (getVerticalGridView() == null) {
                return;
            }
            final float fraction = (Float) arg0.getAnimatedValue();
            final int count = getVerticalGridView().getChildCount();
            for (int i = 0; i < count; i++) {
                View view = getVerticalGridView().getChildAt(i);
                if (getVerticalGridView().getChildAdapterPosition(view) > 0) {
                    view.setAlpha(fraction);
                    view.setTranslationY((float) mAnimationTranslateY * (1f - fraction));
                }
            }
        }
    };

    Context context = getContext();
    mOtherRowFadeInAnimator = loadAnimator(context, R.animator.lb_playback_controls_fade_in);
    mOtherRowFadeInAnimator.addUpdateListener(updateListener);
    mOtherRowFadeInAnimator.setInterpolator(mLogDecelerateInterpolator);

    mOtherRowFadeOutAnimator = loadAnimator(context, R.animator.lb_playback_controls_fade_out);
    mOtherRowFadeOutAnimator.addUpdateListener(updateListener);
    mOtherRowFadeOutAnimator.setInterpolator(new AccelerateInterpolator());
}

From source file:com.zyk.launcher.AsyncTaskCallback.java

@Override
public void onClick(View v) {
    // When we have exited all apps or are in transition, disregard clicks
    if (!mLauncher.isAllAppsVisible() || mLauncher.getWorkspace().isSwitchingState()
            || !(v instanceof PagedViewWidget))
        return;//from   w  w w  .ja  v  a  2 s.  c o m

    // Let the user know that they have to long press to add a widget
    if (mWidgetInstructionToast != null) {
        mWidgetInstructionToast.cancel();
    }
    mWidgetInstructionToast = Toast.makeText(getContext(), R.string.long_press_widget_to_add,
            Toast.LENGTH_SHORT);
    mWidgetInstructionToast.show();

    // Create a little animation to show that the widget can move
    float offsetY = getResources().getDimensionPixelSize(R.dimen.dragViewOffsetY);
    final ImageView p = (ImageView) v.findViewById(R.id.widget_preview);
    AnimatorSet bounce = LauncherAnimUtils.createAnimatorSet();
    ValueAnimator tyuAnim = LauncherAnimUtils.ofFloat(p, "translationY", offsetY);
    tyuAnim.setDuration(125);
    ValueAnimator tydAnim = LauncherAnimUtils.ofFloat(p, "translationY", 0f);
    tydAnim.setDuration(100);
    bounce.play(tyuAnim).before(tydAnim);
    bounce.setInterpolator(new AccelerateInterpolator());
    bounce.start();
}

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

/**
 * @param timerToRemove the timer to be removed during the animation
 */// w w  w .  j a  v a2  s.c  om
private void animateTimerRemove(final Timer timerToRemove) {
    final long duration = UiDataModel.getUiDataModel().getShortAnimationDuration();

    final Animator fadeOut = ObjectAnimator.ofFloat(mViewPager, ALPHA, 1, 0);
    fadeOut.setDuration(duration);
    fadeOut.setInterpolator(new DecelerateInterpolator());
    fadeOut.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            DataModel.getDataModel().removeTimer(timerToRemove);
            Events.sendTimerEvent(com.androidinspain.deskclock.R.string.action_delete,
                    com.androidinspain.deskclock.R.string.label_deskclock);
        }
    });

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

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