List of usage examples for android.view.animation AccelerateDecelerateInterpolator AccelerateDecelerateInterpolator
public AccelerateDecelerateInterpolator()
From source file:com.twotoasters.jazzylistview.JazzyHelper.java
private void doJazzinessImpl(View item, int position, int scrollDirection) { ViewPropertyAnimatorCompat animator = ViewCompat.animate(item).setDuration(DURATION) .setInterpolator(new AccelerateDecelerateInterpolator()); scrollDirection = scrollDirection > 0 ? 1 : -1; mTransitionEffect.initView(item, position, scrollDirection); mTransitionEffect.setupAnimation(item, position, scrollDirection, animator); animator.start();/*www. j a va 2 s. com*/ }
From source file:ly.apps.android.rest.client.example.activities.MainActivity.java
/** * animates a view like a swing//from w w w . j a v a 2 s .c o m * * @param view the view that will be animated * @param bounce the bounces of the animation */ private void iconFall(final View view, final int bounce) { int newdegrees = bounce; if (bounce % 2 == 0) { newdegrees *= -1; } animate(view).setDuration(bounce * 20).rotation(newdegrees) .setInterpolator(new AccelerateDecelerateInterpolator()) .setListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animator) { } @Override public void onAnimationEnd(Animator animator) { if (bounce > 0) { iconFall(view, bounce - 1); } } @Override public void onAnimationCancel(Animator animator) { } @Override public void onAnimationRepeat(Animator animator) { } }).start(); }
From source file:com.nomapp.nomapp_beta.RecipePreview.FillGapBaseActivity.java
private void changeHeaderBackgroundHeightAnimated(boolean shouldShowGap, boolean animated) { if (mGapIsChanging) { return;//from ww w. j a va 2 s . c o m } final int heightOnGapShown = mHeaderBar.getHeight(); final int heightOnGapHidden = mHeaderBar.getHeight() + mActionBarSize; final float from = mHeaderBackground.getLayoutParams().height; final float to; if (shouldShowGap) { if (!mGapHidden) { // Already shown return; } to = heightOnGapShown; } else { if (mGapHidden) { // Already hidden return; } to = heightOnGapHidden; } if (animated) { ViewPropertyAnimator.animate(mHeaderBackground).cancel(); ValueAnimator a = ValueAnimator.ofFloat(from, to); a.setDuration(100); a.setInterpolator(new AccelerateDecelerateInterpolator()); a.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { float height = (float) animation.getAnimatedValue(); changeHeaderBackgroundHeight(height, to, heightOnGapHidden); } }); a.start(); } else { changeHeaderBackgroundHeight(to, to, heightOnGapHidden); } }
From source file:android.support.v7.app.MediaRouteControllerDialog.java
public MediaRouteControllerDialog(Context context, int theme) { super(MediaRouterThemeHelper.createThemedContext(context, theme), theme); mContext = getContext();//from w w w . ja va 2s .c o m mControllerCallback = new MediaControllerCallback(); mRouter = MediaRouter.getInstance(mContext); mCallback = new MediaRouterCallback(); mRoute = mRouter.getSelectedRoute(); setMediaSession(mRouter.getMediaSessionToken()); mVolumeGroupListPaddingTop = mContext.getResources() .getDimensionPixelSize(R.dimen.mr_controller_volume_group_list_padding_top); mAccessibilityManager = (AccessibilityManager) mContext.getSystemService(Context.ACCESSIBILITY_SERVICE); if (android.os.Build.VERSION.SDK_INT >= 21) { mLinearOutSlowInInterpolator = AnimationUtils.loadInterpolator(context, R.interpolator.mr_linear_out_slow_in); mFastOutSlowInInterpolator = AnimationUtils.loadInterpolator(context, R.interpolator.mr_fast_out_slow_in); } mAccelerateDecelerateInterpolator = new AccelerateDecelerateInterpolator(); }
From source file:com.dean.phonesafe.ui.SlideSwitch.java
public void moveToDest(final boolean toRight) { ValueAnimator toDestAnim = ValueAnimator.ofInt(frontRect_left, toRight ? max_left : min_left); toDestAnim.setDuration(500);/*from w w w .j a va 2s . com*/ toDestAnim.setInterpolator(new AccelerateDecelerateInterpolator()); toDestAnim.start(); toDestAnim.addUpdateListener(new AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { frontRect_left = (Integer) animation.getAnimatedValue(); alpha = (int) (255 * (float) frontRect_left / (float) max_left); invalidateView(); } }); toDestAnim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { if (toRight) { isOpen = true; if (listener != null) listener.open(); frontRect_left_begin = max_left; } else { isOpen = false; if (listener != null) listener.close(); frontRect_left_begin = min_left; } } }); }
From source file:co.dift.ui.SwipeToAction.java
private void resetPosition() { if (frontView == null) { return;/*from w w w . j a v a 2s . c om*/ } final View animated = touchedView; frontView.animate().setDuration(getResetAnimationDuration()) .setInterpolator(new AccelerateDecelerateInterpolator()) .setListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { runningAnimationsOn.add(animated); } @Override public void onAnimationEnd(Animator animation) { runningAnimationsOn.remove(animated); checkQueue(); swipeListener.resetComplete(); } @Override public void onAnimationCancel(Animator animation) { runningAnimationsOn.remove(animated); } @Override public void onAnimationRepeat(Animator animation) { runningAnimationsOn.add(animated); } }).x(frontViewX); }
From source file:com.audionote.widget.SlideSwitch.java
public void moveToDest(final boolean toRight) { ValueAnimator toDestAnim = ValueAnimator.ofInt(frontRect_left, toRight ? max_left : min_left); toDestAnim.setDuration(200);/*from w w w. j a va2 s .co m*/ toDestAnim.setInterpolator(new AccelerateDecelerateInterpolator()); toDestAnim.start(); toDestAnim.addUpdateListener(new AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { frontRect_left = (Integer) animation.getAnimatedValue(); alpha = (int) (255 * (float) frontRect_left / (float) max_left); invalidateView(); } }); toDestAnim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { if (toRight) { isOpen = true; if (listener != null) listener.open(); frontRect_left_begin = max_left; } else { isOpen = false; if (listener != null) listener.close(); frontRect_left_begin = min_left; } } }); }
From source file:com.sinyuk.jianyimaterial.widgets.FloatingToolbar.java
public void show() { if (mFab == null) { throw new IllegalStateException( "FloatingActionButton not attached." + "Please, use attachFab(FloatingActionButton fab)."); }/*from w w w. j a v a 2s . c o m*/ if (mMorphing) { return; } mMorphed = true; mMorphing = true; if (mMenuLayout != null) { mMenuLayout.setAlpha(0f); mMenuLayout.setScaleX(0.7f); } if (mCustomView != null) { mCustomView.setAlpha(0f); mCustomView.setScaleX(0.7f); } /** * Place view a bit closer to the fab */ float startRevealX; if (mFabOriginalX > getWidth() / 2f) { startRevealX = mOriginalX + (mFabOriginalX - mOriginalX) / 4f; } else { startRevealX = mOriginalX - (mFabOriginalX - mOriginalX) / 4f; } setX(startRevealX); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { showLollipopImpl(); } else { showDefaultImpl(); } if (mMenuLayout != null) { mMenuLayout.animate().alpha(1).scaleX(1f).setDuration(MENU_ANIMATION_DURATION) .setStartDelay(MENU_ANIMATION_DELAY).setInterpolator(new AccelerateDecelerateInterpolator()); } if (mCustomView != null) { mCustomView.animate().alpha(1).scaleX(1).setDuration(MENU_ANIMATION_DURATION) .setStartDelay(MENU_ANIMATION_DELAY).setInterpolator(new AccelerateDecelerateInterpolator()); } /** * Move FloatingToolbar to the original position */ animate().x(mOriginalX).setStartDelay(CIRCULAR_REVEAL_DELAY).setDuration(CIRCULAR_REVEAL_DURATION / 2) .setInterpolator(new AccelerateDecelerateInterpolator()); }
From source file:com.awt.supark.LayoutHandler.java
public void smallButtonPressed(final View view, final MainActivity act) { if (!act.pullUp && !act.pullUpStarted) { // If it isn't already up act.pullUpStarted = true;//from w w w . j a v a 2s .c o m // Declaring animator ValueAnimator animation = ValueAnimator.ofFloat(1f, 0.17f); // ****** UI ELEMENTS FADING OUT ANIMATION ****** // Sets the animation properties animation.setDuration(act.layoutFadeOutDuration); animation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { float value = (float) animation.getAnimatedValue(); // Fades out contentLinear and all buttons, except the one that is pressed act.contentLinear.setAlpha(value); if (view.getId() != R.id.buttonMap) { act.btnMap.setAlpha(value); } if (view.getId() != R.id.buttonCars) { act.btnCars.setAlpha(value); } if (view.getId() != R.id.buttonStatistics) { act.btnStatistics.setAlpha(value); } if (view.getId() != R.id.buttonEtc) { act.btnEtc.setAlpha(value); } } }); animation.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { // Sets the visibility of the other layout and contentlinear act.contentLinear.setVisibility(View.GONE); act.otherContent.setVisibility(View.VISIBLE); // ****** BUTTON PULL UP ANIMATION ****** // Declaring animator ValueAnimator nextAnimation = ValueAnimator.ofFloat(1f, 0f); // Sets the animation properties nextAnimation.setDuration(act.layoutPullUpDuration); nextAnimation.setInterpolator(new AccelerateDecelerateInterpolator()); nextAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { float value = (float) animation.getAnimatedValue(); // Sets weight of the two layouts, this makes one smaller and the other bigger act.tableRowTopHalf .setLayoutParams(new TableRow.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, value)); act.otherContent.setLayoutParams( new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, 1 - value)); } }); // ****** LAYOUT PULL UP ANIMATION ****** nextAnimation.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { act.otherContentHandler(view); // Takes care of including new views act.otherContent.startAnimation(act.anim_slide_up_fade_in); // Animates the new activity act.pullUp = true; // Changing the pull up status indicator act.pullUpStarted = false; } @Override public void onAnimationCancel(Animator animation) { act.pullUpStarted = false; act.otherContent.setVisibility(View.GONE); } @Override public void onAnimationRepeat(Animator animation) { } }); nextAnimation.start(); } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }); animation.start(); } else if (view.getId() == act.openedLayout) { act.pullDown(); // If there is a layout already pulled up we have to pull it down } else if (act.pullUp && (act.openedLayout != 0) && !act.pullUpStarted) { act.pullUpStarted = true; // To prevent more than one highlight // Changing highlight from previous to current button ValueAnimator animation = ValueAnimator.ofFloat(0.17f, 1f); animation.setDuration(act.smallButtonHighlightChangeDuration); animation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { float value = (float) animation.getAnimatedValue(); act.findViewById(view.getId()).setAlpha(value); act.findViewById(act.openedLayout).setAlpha(1.17f - value); } }); animation.start(); // Fades out current layout act.otherContent.startAnimation(act.anim_fade_out); act.anim_fade_out.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { act.otherContentHandler(view); // Switches the layout to the new one act.otherContent.startAnimation(act.anim_slide_up_fade_in); // Fades in the new layout act.pullUpStarted = false; } @Override public void onAnimationRepeat(Animation animation) { } }); } }
From source file:androidx.mediarouter.app.MediaRouteControllerDialog.java
public MediaRouteControllerDialog(Context context, int theme) { super(context = MediaRouterThemeHelper.createThemedDialogContext(context, theme, true), MediaRouterThemeHelper.createThemedDialogStyle(context)); mContext = getContext();// w w w. j a v a2 s . c o m mControllerCallback = new MediaControllerCallback(); mRouter = MediaRouter.getInstance(mContext); mCallback = new MediaRouterCallback(); mRoute = mRouter.getSelectedRoute(); setMediaSession(mRouter.getMediaSessionToken()); mVolumeGroupListPaddingTop = mContext.getResources() .getDimensionPixelSize(R.dimen.mr_controller_volume_group_list_padding_top); mAccessibilityManager = (AccessibilityManager) mContext.getSystemService(Context.ACCESSIBILITY_SERVICE); if (android.os.Build.VERSION.SDK_INT >= 21) { mLinearOutSlowInInterpolator = AnimationUtils.loadInterpolator(context, R.interpolator.mr_linear_out_slow_in); mFastOutSlowInInterpolator = AnimationUtils.loadInterpolator(context, R.interpolator.mr_fast_out_slow_in); } mAccelerateDecelerateInterpolator = new AccelerateDecelerateInterpolator(); }