private void slideTo(int slideOffset, boolean forceInstant) { if (animator != null) { animator.cancel(); animator = null; } if (!forceInstant) { animator = ObjectAnimator.ofInt(this, "slideOffset", this.slideOffset, slideOffset); animator.setInterpolator(new FastOutSlowInInterpolator()); animator.setDuration(400); animator.start(); ViewCompat.postInvalidateOnAnimation(this); } else { this.slideOffset = slideOffset; requestLayout(); invalidate(); } }
@CallSuper public void onPageShow() { mShown = true; if (mFabRotation == ROTATION_GONE) { if (mFab.getVisibility() == View.VISIBLE) { mFab.hide(); } mFab.setOnClickListener(null); return; } mFab.setOnClickListener(mOnFabClickListener); if (mFab.getVisibility() != View.VISIBLE) { mFab.setRotation(mFabRotation); mFab.show(); } else if (Math.abs(mFab.getRotation() - mFabRotation) > 0.1f) { mFab.animate() .rotation(mFabRotation) .setDuration(300) .setInterpolator(new FastOutSlowInInterpolator()) .start(); } }
private ValueAnimator slideAnimator(int start, int end, final View v) { ValueAnimator animator = ValueAnimator.ofInt(start, end); animator.setInterpolator(new FastOutSlowInInterpolator()); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { //Update Height int value = (Integer) valueAnimator.getAnimatedValue(); ViewGroup.LayoutParams layoutParams = v.getLayoutParams(); layoutParams.height = value; v.setLayoutParams(layoutParams); } }); return animator; }
private static ValueAnimator slideAnimator(int start, int end, final View v) { ValueAnimator animator = ValueAnimator.ofInt(start, end); animator.setInterpolator(new FastOutSlowInInterpolator()); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { //Update Height int value = (Integer) valueAnimator.getAnimatedValue(); ViewGroup.LayoutParams layoutParams = v.getLayoutParams(); layoutParams.height = value; v.setLayoutParams(layoutParams); } }); return animator; }
private static ValueAnimator flipAnimator(boolean isFlipped, final View v) { if (v != null) { ValueAnimator animator = ValueAnimator.ofFloat(isFlipped ? -1f : 1f, isFlipped ? 1f : -1f); animator.setInterpolator(new FastOutSlowInInterpolator()); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { //Update Height v.setScaleY((Float) valueAnimator.getAnimatedValue()); } }); return animator; } return null; }
private AnimatorSet buildIndicatorAnimatorTowards(TextView tab) { ObjectAnimator xAnimator = ObjectAnimator.ofFloat(indicator, "X", indicator.getX(), tab.getX()); final ViewGroup.LayoutParams params = indicator.getLayoutParams(); ValueAnimator widthAnimator = ValueAnimator.ofInt(params.width, tab.getMeasuredWidth()); widthAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { params.width = (int) animation.getAnimatedValue(); indicator.setLayoutParams(params); } }); AnimatorSet set = new AnimatorSet(); set.setInterpolator(new FastOutSlowInInterpolator()); set.playTogether(xAnimator, widthAnimator); return set; }
private void onTaskFinished(@Nullable MaterialAboutList materialAboutList) { if (materialAboutList != null) { list = materialAboutList; adapter.swapData(list); if (shouldAnimate()) { recyclerView.animate() .alpha(1f) .translationY(0f) .setDuration(400) .setInterpolator(new FastOutSlowInInterpolator()).start(); } else { recyclerView.setAlpha(1f); recyclerView.setTranslationY(0f); } } else { finish();//?? why we remain here anyway? } }
@Override protected void onPostExecute(String s) { adapter.swapData(list); if (shouldAnimate()) { recyclerView.animate() .alpha(1f) .translationY(0f) .setDuration(400) .setInterpolator(new FastOutSlowInInterpolator()) .start(); } else { recyclerView.setAlpha(1f); recyclerView.setTranslationY(0f); } super.onPostExecute(s); fragmentContext = null; }
public FloatingOnTouchListener() { final WindowManager.LayoutParams params = (WindowManager.LayoutParams) mFloatingView.getLayoutParams(); fadeOut = ValueAnimator.ofFloat(params.alpha, 0.1F); fadeOut.setInterpolator(new FastOutSlowInInterpolator()); fadeOut.setDuration(100); fadeOut.addUpdateListener(valueAnimator -> { params.alpha = (float) valueAnimator.getAnimatedValue(); try { mWindowManager.updateViewLayout(mFloatingView, params); } catch (IllegalArgumentException ignore) { } }); fadeIn = fadeOut.clone(); fadeIn.setFloatValues(0.1F, params.alpha); fadeIn.setStartDelay(5000); }
public void resetStory() { getSupportActionBar().setTitle(story.getTitle()); overlay.setClickable(false); overlay.animate() .alpha(0.0F) .setDuration(200L) .setInterpolator(new FastOutSlowInInterpolator()) .start(); switch (StoryDataProcess.Category.getEnum(story.getCategory())) { case FILE: getSupportFragmentManager().beginTransaction() .replace(R.id.container, FileStoryFragment.getInstance(story, false)) .commit(); break; case TOPIC: getSupportFragmentManager().beginTransaction() .replace(R.id.container, TopicStoryFragment.getInstance(story, false)) .commit(); break; case LINK: getSupportFragmentManager().beginTransaction() .replace(R.id.container, LinkStoryFragment.getInstance(story, false)) .commit(); break; } }
private void initInterpolations() { ArrayList<Class> interpolatorList = new ArrayList<Class>() {{ add(FastOutSlowInInterpolator.class); add(BounceInterpolator.class); add(LinearInterpolator.class); add(DecelerateInterpolator.class); add(CycleInterpolator.class); add(AnticipateInterpolator.class); add(AccelerateDecelerateInterpolator.class); add(AccelerateInterpolator.class); add(AnticipateOvershootInterpolator.class); add(FastOutLinearInInterpolator.class); add(LinearOutSlowInInterpolator.class); add(OvershootInterpolator.class); }}; try { interpolatorSelector = (Interpolator) interpolatorList.get(animateSelector).newInstance(); } catch (Exception e) { e.printStackTrace(); } }
private void handleVote(Upvote vote) { shot.setVoted(fab.isChecked()); int count = vote.count; if (!fab.isChecked() && count > 0) { count -= 1; } if (count != shot.getVotes()) { shot.setVotes(count); updateVoteCount(); AnimatorSet s = new AnimatorSet(); s.setDuration(300).setInterpolator(new FastOutSlowInInterpolator()); s.playTogether( ObjectAnimator.ofFloat(voteCount, "alpha", 0, 1, 1, 1), ObjectAnimator.ofFloat(voteCount, "scaleX", 0.3f, 1.05f, 0.9f, 1), ObjectAnimator.ofFloat(voteCount, "scaleY", 0.3f, 1.05f, 0.9f, 1)); s.start(); } }
private void toggleFab(View view, int delay, float scale, final boolean last) { ViewCompat.animate(view) .setStartDelay(delay) .scaleX(scale) .scaleY(scale) .setInterpolator(new FastOutSlowInInterpolator()) .withEndAction(new Runnable() { @Override public void run() { if (last) { uiLinearLayout.setVisibility(View.GONE); } } }) .start(); }
private void toggleFab(View view, int delay, float scale, final boolean last) { ViewCompat.animate(view) .setStartDelay(delay) .scaleX(scale) .scaleY(scale) .setInterpolator(new FastOutSlowInInterpolator()) .withEndAction(new Runnable() { @Override public void run() { if (last) { mUiLayout.setVisibility(View.GONE); } } }) .start(); }
public void onStopNestedScroll(View child) { if (Math.abs(totalDrag) >= dragDismissDistance) { dispatchDismissCallback(); } else { // settle back to natural position ViewPropertyAnimator animator = mViewGroup.animate() .translationY(0f) .scaleY(1f) .setDuration(200L) .setInterpolator(new FastOutSlowInInterpolator()) .setListener(null); if (enableScaleX) { animator.scaleX(1f); } animator.start(); totalDrag = 0; draggingDown = draggingUp = false; dispatchDragCallback(0f, 0f, 0f, 0f); } }
private void animateShow() { ObjectAnimator yTranslation = ObjectAnimator.ofFloat(content, View.TRANSLATION_Y, 80, 0).setDuration(400); yTranslation.setInterpolator(new FastOutSlowInInterpolator()); yTranslation.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { content.setAlpha(1); } }); ObjectAnimator lightBoxAlpha = ObjectAnimator.ofFloat(lightBox, View.ALPHA, 0, 1).setDuration(70); AnimatorSet animatorSet = new AnimatorSet(); animatorSet.playTogether(lightBoxAlpha, yTranslation); animatorSet.start(); }
public void showSideNavigationPrompt(View view) { final MaterialTapTargetPrompt.Builder tapTargetPromptBuilder = new MaterialTapTargetPrompt.Builder(this) .setPrimaryText(R.string.menu_prompt_title) .setSecondaryText(R.string.menu_prompt_description) .setAnimationInterpolator(new FastOutSlowInInterpolator()) .setMaxTextWidth(R.dimen.tap_target_menu_max_width) .setIcon(R.drawable.ic_back); final Toolbar tb = this.findViewById(android.support.v7.appcompat.R.id.action_bar); tapTargetPromptBuilder.setTarget(tb.getChildAt(1)); tapTargetPromptBuilder.setPromptStateChangeListener(new MaterialTapTargetPrompt.PromptStateChangeListener() { @Override public void onPromptStateChanged(@NonNull MaterialTapTargetPrompt prompt, int state) { if (state == MaterialTapTargetPrompt.STATE_FOCAL_PRESSED) { //Do something such as storing a value so that this prompt is never shown again } } }); tapTargetPromptBuilder.show(); }
public void showOverflowPrompt(View view) { final MaterialTapTargetPrompt.Builder tapTargetPromptBuilder = new MaterialTapTargetPrompt.Builder(this) .setPrimaryText(R.string.overflow_prompt_title) .setSecondaryText(R.string.overflow_prompt_description) .setAnimationInterpolator(new FastOutSlowInInterpolator()) .setMaxTextWidth(R.dimen.tap_target_menu_max_width) .setIcon(R.drawable.ic_more_vert); final Toolbar tb = this.findViewById(android.support.v7.appcompat.R.id.action_bar); final View child = tb.getChildAt(2); if (child instanceof ActionMenuView) { final ActionMenuView actionMenuView = ((ActionMenuView) child); tapTargetPromptBuilder.setTarget(actionMenuView.getChildAt(actionMenuView.getChildCount() - 1)); } else { Toast.makeText(this, R.string.overflow_unavailable, Toast.LENGTH_SHORT); } tapTargetPromptBuilder.show(); }
public void showSideNavigationPrompt(View view) { final MaterialTapTargetPrompt.Builder tapTargetPromptBuilder = new MaterialTapTargetPrompt.Builder(this) .setPrimaryText(R.string.menu_prompt_title) .setSecondaryText(R.string.menu_prompt_description) .setFocalPadding(R.dimen.dp40) .setAnimationInterpolator(new FastOutSlowInInterpolator()) .setMaxTextWidth(R.dimen.tap_target_menu_max_width) .setIcon(R.drawable.ic_menu); final Toolbar tb = this.findViewById(R.id.toolbar); tapTargetPromptBuilder.setTarget(tb.getChildAt(1)); tapTargetPromptBuilder.setPromptStateChangeListener(new MaterialTapTargetPrompt.PromptStateChangeListener() { @Override public void onPromptStateChanged(@NonNull MaterialTapTargetPrompt prompt, int state) { if (state == MaterialTapTargetPrompt.STATE_FOCAL_PRESSED) { //Do something such as storing a value so that this prompt is never shown again } } }); tapTargetPromptBuilder.show(); }
public void showOverflowPrompt(View view) { final MaterialTapTargetPrompt.Builder tapTargetPromptBuilder = new MaterialTapTargetPrompt.Builder(this) .setPrimaryText(R.string.overflow_prompt_title) .setSecondaryText(R.string.overflow_prompt_description) .setAnimationInterpolator(new FastOutSlowInInterpolator()) .setMaxTextWidth(R.dimen.tap_target_menu_max_width) .setIcon(R.drawable.ic_more_vert); final Toolbar tb = this.findViewById(R.id.toolbar); final View child = tb.getChildAt(2); if (child instanceof ActionMenuView) { final ActionMenuView actionMenuView = ((ActionMenuView) child); tapTargetPromptBuilder.setTarget(actionMenuView.getChildAt(actionMenuView.getChildCount() - 1)); } else { Toast.makeText(this, R.string.overflow_unavailable, Toast.LENGTH_SHORT); } tapTargetPromptBuilder.show(); }
public void showSideNavigationPrompt(View view) { final MaterialTapTargetPrompt.Builder tapTargetPromptBuilder = new MaterialTapTargetPrompt.Builder(this) .setPrimaryText(R.string.menu_prompt_title) .setSecondaryText(R.string.menu_prompt_description) .setAnimationInterpolator(new FastOutSlowInInterpolator()) .setMaxTextWidth(R.dimen.tap_target_menu_max_width) .setIcon(R.drawable.ic_back) .setClipToView(findViewById(R.id.dialog_view)); final Toolbar tb = this.findViewById(R.id.toolbar); tapTargetPromptBuilder.setTarget(tb.getChildAt(1)); tapTargetPromptBuilder.setPromptStateChangeListener(new MaterialTapTargetPrompt.PromptStateChangeListener() { @Override public void onPromptStateChanged(@NonNull MaterialTapTargetPrompt prompt, int state) { if (state == MaterialTapTargetPrompt.STATE_FOCAL_PRESSED) { //Do something such as storing a value so that this prompt is never shown again } } }); tapTargetPromptBuilder.show(); }
public void showOverflowPrompt(View view) { final MaterialTapTargetPrompt.Builder tapTargetPromptBuilder = new MaterialTapTargetPrompt.Builder(this) .setPrimaryText(R.string.overflow_prompt_title) .setSecondaryText(R.string.overflow_prompt_description) .setAnimationInterpolator(new FastOutSlowInInterpolator()) .setMaxTextWidth(R.dimen.max_prompt_width) .setIcon(R.drawable.ic_more_vert) .setClipToView(findViewById(R.id.dialog_view)); final Toolbar tb = this.findViewById(R.id.toolbar); final View child = tb.getChildAt(2); if (child instanceof ActionMenuView) { final ActionMenuView actionMenuView = ((ActionMenuView) child); tapTargetPromptBuilder.setTarget(actionMenuView.getChildAt(actionMenuView.getChildCount() - 1)); } else { Toast.makeText(this, R.string.overflow_unavailable, Toast.LENGTH_SHORT); } tapTargetPromptBuilder.show(); }
@Test public void validateSetOfObjectAnimatorTranslationMotionTiming() { MotionSpec spec = MotionSpec.createFromResource( activityTestRule.getActivity(), R.animator.valid_set_of_object_animator_motion_spec); MotionTiming translation = spec.getTiming("translation"); assertEquals(11, translation.getDelay()); assertEquals(13, translation.getDuration()); if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) { assertThat(translation.getInterpolator(), instanceOf(PathInterpolator.class)); } else { assertThat(translation.getInterpolator(), instanceOf(FastOutSlowInInterpolator.class)); } assertEquals(17, translation.getRepeatCount()); assertEquals(ValueAnimator.REVERSE, translation.getRepeatMode()); }
public void executeTransition() { postponeEnterTransition(); final View decorView = getWindow().getDecorView(); getWindow().getDecorView().getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { @Override public boolean onPreDraw() { decorView.getViewTreeObserver().removeOnPreDrawListener(this); supportStartPostponedEnterTransition(); return true; } }); MyTransition transition = new MyTransition(); transition.setPositionDuration(300); transition.setSizeDuration(300); transition.setPositionInterpolator(new FastOutLinearInInterpolator()); transition.setSizeInterpolator(new FastOutSlowInInterpolator()); transition.addTarget("message"); getWindow().setSharedElementEnterTransition(transition); }
@TargetApi(14) public final Animator createScaleAnimator(final View paramView, float paramFloat1, float paramFloat2, long paramLong) { ValueAnimator localValueAnimator = ValueAnimator.ofFloat(new float[] { paramFloat1, paramFloat2 }); localValueAnimator.setDuration(paramLong); if (Build.VERSION.SDK_INT >= 21) { localValueAnimator.setInterpolator(PlayInterpolators.fastOutSlowIn(paramView.getContext())); } for (;;) { localValueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { public final void onAnimationUpdate(ValueAnimator paramAnonymousValueAnimator) { float f = ((Float)paramAnonymousValueAnimator.getAnimatedValue()).floatValue(); paramView.setScaleX(f); paramView.setScaleY(f); } }); return localValueAnimator; localValueAnimator.setInterpolator(new FastOutSlowInInterpolator()); } }
/** * * @param parent * @param bb * @param snackbar */ private void updateFabTranslationForSnackbar(CoordinatorLayout parent, BottomButton bb, View snackbar) { float translationY = this.getFabTranslationYForSnackbar(parent, bb); if (translationY != this.mTranslationY) { ViewCompat.animate(bb).cancel(); if (Math.abs(translationY - this.mTranslationY) == (float) snackbar.getHeight()) { ViewCompat.animate(bb).translationY(translationY).setInterpolator(new FastOutSlowInInterpolator()) .setListener((ViewPropertyAnimatorListener) null); } else { ViewCompat.setTranslationY(bb, translationY); } this.mTranslationY = translationY; } }
public void dismiss(boolean immediate) { if (immediate) { dismissNow(); } else { animatorFor(text, animatorContext) .withInterpolator(new FastOutSlowInInterpolator()) .fadeOut(INVISIBLE) .addOnAnimationCompleted(new OnAnimationCompleted() { @Override public void onAnimationCompleted(boolean finished) { dismissNow(); } }) .start(); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_home); this.animatorContext = new AnimatorContext(getClass().getSimpleName()); animatorContext.setTransactionTemplate(new AnimatorTemplate(new FastOutSlowInInterpolator())); this.viewPager = (ViewPager) findViewById(R.id.activity_home_view_pager); final ViewPagerAnimatorContextAdapter animatorContextAdapter = new ViewPagerAnimatorContextAdapter(animatorContext); viewPager.addOnPageChangeListener(animatorContextAdapter); viewPager.addOnPageChangeListener(this); this.adapter = new AmplitudeFragmentsAdapter(getSupportFragmentManager(), NUMBER_FRAGMENTS); viewPager.setAdapter(adapter); viewPager.setCurrentItem(NUMBER_FRAGMENTS - 1, false); if (savedInstanceState != null) { final boolean enableLongAnimations = savedInstanceState.getBoolean(SAVED_ENABLE_LONG_ANIMATIONS); setEnableLongAnimations(enableLongAnimations); } }
public void show() { if (hidden) { if (musicControllerAnimationSet == null) { TimeInterpolator interpolator = new FastOutSlowInInterpolator(); final int duration = 300; LinkedList<Animator> animators = new LinkedList<>(); addAnimation(animators, playPauseButton, interpolator, duration, 0); addAnimation(animators, nextButton, interpolator, duration, 100); addAnimation(animators, prevButton, interpolator, duration, 100); addAnimation(animators, shuffleButton, interpolator, duration, 200); addAnimation(animators, repeatButton, interpolator, duration, 200); musicControllerAnimationSet = new AnimatorSet(); musicControllerAnimationSet.playTogether(animators); } else { musicControllerAnimationSet.cancel(); } musicControllerAnimationSet.start(); } hidden = false; }
@TargetApi(Build.VERSION_CODES.LOLLIPOP) private Animator makeSearchPanelAnimator(boolean reverse) { int width = container.getWidth(); int centerX = container.getRight() + container.getPaddingRight() - resources.getDimensionPixelOffset(R.dimen.reveal_right) / 4 * 3; int centerY = container.getHeight() / 2; Animator animator = ViewAnimationUtils.createCircularReveal(container, centerX, centerY, reverse ? width : 0, reverse ? 0 : width); animator.setInterpolator(new FastOutSlowInInterpolator()); animator.setDuration(resources.getInteger(android.R.integer.config_mediumAnimTime)); return animator; }
public static void showChildrenObject(final View v) { v.setVisibility(View.VISIBLE); ValueAnimator animator = ValueAnimator.ofFloat(0, 1f); animator.setDuration(250); animator.setInterpolator(new FastOutSlowInInterpolator()); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { float value = ((Float) (animation.getAnimatedValue())).floatValue(); v.setAlpha(value); v.setScaleX(value); v.setScaleY(value); } }); animator.start(); }
/** * Called by worker task when decoder is ready and image size and EXIF orientation is known. */ private synchronized void onTilesInited(ImageRegionDecoder decoder, int sWidth, int sHeight, int sOrientation) { // If actual dimensions don't match the declared size, reset everything. if (this.sWidth > 0 && this.sHeight > 0 && (this.sWidth != sWidth || this.sHeight != sHeight)) { reset(false); if (bitmap != null) { if (!bitmapIsCached) { bitmap.recycle(); } bitmap = null; bitmapIsPreview = false; bitmapIsCached = false; } } this.decoder = decoder; this.sWidth = sWidth; this.sHeight = sHeight; this.sOrientation = sOrientation; checkReady(); checkImageLoaded(); invalidate(); requestLayout(); animate().setInterpolator(new FastOutSlowInInterpolator()).alpha(1); }
/** * Called by worker task when full size image bitmap is ready (tiling is disabled). */ private synchronized void onImageLoaded(Bitmap bitmap, int sOrientation, boolean bitmapIsCached) { // If actual dimensions don't match the declared size, reset everything. if (this.sWidth > 0 && this.sHeight > 0 && (this.sWidth != bitmap.getWidth() || this.sHeight != bitmap.getHeight())) { reset(false); } if (this.bitmap != null && !this.bitmapIsCached) { this.bitmap.recycle(); } this.bitmapIsPreview = false; this.bitmapIsCached = bitmapIsCached; this.bitmap = bitmap; this.sWidth = bitmap.getWidth(); this.sHeight = bitmap.getHeight(); this.sOrientation = sOrientation; boolean ready = checkReady(); boolean imageLoaded = checkImageLoaded(); if (ready || imageLoaded) { invalidate(); requestLayout(); } animate().setInterpolator(new FastOutSlowInInterpolator()).alpha(1); }