List of usage examples for android.support.v4.view.animation FastOutSlowInInterpolator FastOutSlowInInterpolator
public FastOutSlowInInterpolator()
From source file:com.example.waitou.rxjava.LoadingView.java
/** * set the animator's interpolator//from ww w . j av a 2 s . c o m * * @param style */ public void setProgressStyle(int style) { switch (style) { case PROGRESS_STYLE_MATERIAL: interpolator = new FastOutSlowInInterpolator(); break; case PROGRESS_STYLE_LINEAR: interpolator = new LinearInterpolator(); break; } }
From source file:com.google.samples.apps.topeka.activity.QuizActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { mCountingIdlingResource = new CountingIdlingResource("Quiz"); String categoryId = getIntent().getStringExtra(Category.TAG); mInterpolator = new FastOutSlowInInterpolator(); if (null != savedInstanceState) { mSavedStateIsPlaying = savedInstanceState.getBoolean(STATE_IS_PLAYING); }/*from www . j a v a 2 s .c o m*/ super.onCreate(savedInstanceState); populate(categoryId); int categoryNameTextSize = getResources().getDimensionPixelSize(R.dimen.category_item_text_size); int paddingStart = getResources().getDimensionPixelSize(R.dimen.spacing_double); final int startDelay = getResources().getInteger(R.integer.toolbar_transition_duration); ActivityCompat.setEnterSharedElementCallback(this, new TextSharedElementCallback(categoryNameTextSize, paddingStart) { @Override public void onSharedElementStart(List<String> sharedElementNames, List<View> sharedElements, List<View> sharedElementSnapshots) { super.onSharedElementStart(sharedElementNames, sharedElements, sharedElementSnapshots); mToolbarBack.setScaleX(0f); mToolbarBack.setScaleY(0f); } @Override public void onSharedElementEnd(List<String> sharedElementNames, List<View> sharedElements, List<View> sharedElementSnapshots) { super.onSharedElementEnd(sharedElementNames, sharedElements, sharedElementSnapshots); // Make sure to perform this animation after the transition has ended. ViewCompat.animate(mToolbarBack).setStartDelay(startDelay).scaleX(1f).scaleY(1f).alpha(1f); } }); }
From source file:uk.co.samuelwall.materialtaptargetprompt.sample.EmptyActivity.java
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 = (Toolbar) 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 {//ww w. j ava 2 s. c om Toast.makeText(this, R.string.overflow_unavailable, Toast.LENGTH_SHORT); } tapTargetPromptBuilder.show(); }
From source file:de.dreier.mytargets.features.training.overview.TrainingsFragment.java
@NonNull @Override/*www .java2s . c o m*/ protected LoaderUICallback onLoad(Bundle args) { final List<Training> trainings = Training.getAll(); return new LoaderUICallback() { @Override public void applyData() { TrainingsFragment.this.setList(trainings, false); if (trainings.isEmpty() && !SettingsManager.isFirstTrainingShown()) { new MaterialTapTargetPrompt.Builder(TrainingsFragment.this.getActivity()) .setDrawView(binding.fab).setTarget(binding.fab.getChildAt(2)) .setBackgroundColourFromRes(R.color.colorPrimary) .setPrimaryText(R.string.your_first_training) .setSecondaryText(R.string.first_training_description) .setAnimationInterpolator(new FastOutSlowInInterpolator()) .setOnHidePromptListener(new MaterialTapTargetPrompt.OnHidePromptListener() { @Override public void onHidePrompt(MotionEvent event, boolean tappedTarget) { //Do something such as storing a value so that this prompt is never shown again SettingsManager.setFirstTrainingShown(true); } @Override public void onHidePromptComplete() { } }).show(); } } }; }
From source file:com.google.samples.apps.topeka.view.quiz.QuizActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { mInterpolator = new FastOutSlowInInterpolator(); super.onCreate(savedInstanceState); int categoryNameTextSize = getResources().getDimensionPixelSize(R.dimen.category_item_text_size); int paddingStart = getResources().getDimensionPixelSize(R.dimen.spacing_double); final int startDelay = getResources().getInteger(R.integer.toolbar_transition_duration); ActivityCompat.setEnterSharedElementCallback(this, new TextSharedElementCallback(categoryNameTextSize, paddingStart) { @Override/* w ww .j a va 2 s .co m*/ public void onSharedElementStart(List<String> sharedElementNames, List<View> sharedElements, List<View> sharedElementSnapshots) { super.onSharedElementStart(sharedElementNames, sharedElements, sharedElementSnapshots); mToolbarBack.setScaleX(0f); mToolbarBack.setScaleY(0f); } @Override public void onSharedElementEnd(List<String> sharedElementNames, List<View> sharedElements, List<View> sharedElementSnapshots) { super.onSharedElementEnd(sharedElementNames, sharedElements, sharedElementSnapshots); // Make sure to perform this animation after the transition has ended. ViewCompat.animate(mToolbarBack).setStartDelay(startDelay).scaleX(1f).scaleY(1f).alpha(1f); } }); if (null != savedInstanceState) { mSavedStateIsPlaying = savedInstanceState.getBoolean(STATE_IS_PLAYING); } this.presenter = initPresenter(); }
From source file:com.lambdasoup.appbarsyncedfab.AppBarBoundFabBehavior.java
private void updateFabTranslationForSnackbar(CoordinatorLayout parent, final FloatingActionButton fab, View snackbar) {/*from w w w .jav a 2 s .c om*/ // We want to introduce additional y-translation (with respect to what's already there), // by the current visible height of any snackbar final float targetTransYByThis = getVisibleHeightOfOverlappingSnackbar(parent, fab); if (snackbarFabTranslationYByThis == targetTransYByThis) { // We're already at (or currently animating to) the target value, return... return; } final float currentTransY = ViewCompat.getTranslationY(fab); // Calculate difference between what we want now and what we wanted earlier final float stepTransYDelta = targetTransYByThis - snackbarFabTranslationYByThis; // ... and we're going to change the current state just by the difference final float targetTransY = currentTransY + stepTransYDelta; // Make sure that any current animation is cancelled if (snackbarFabTranslationYAnimator != null && snackbarFabTranslationYAnimator.isRunning()) { snackbarFabTranslationYAnimator.cancel(); } if (fab.isShown() && Math.abs(currentTransY - targetTransY) > (fab.getHeight() * 0.667f)) { // If the FAB will be travelling by more than 2/3 of it's height, let's animate // it instead if (snackbarFabTranslationYAnimator == null) { snackbarFabTranslationYAnimator = ValueAnimator.ofFloat(currentTransY, targetTransY); snackbarFabTranslationYAnimator.setInterpolator(new FastOutSlowInInterpolator()); snackbarFabTranslationYAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animator) { ViewCompat.setTranslationY(fab, (Float) animator.getAnimatedValue()); } }); } snackbarFabTranslationYAnimator.start(); } else { // Now update the translation Y ViewCompat.setTranslationY(fab, targetTransY); } snackbarFabTranslationYByThis = targetTransYByThis; }
From source file:de.dreier.mytargets.utils.transitions.FabTransform.java
@Override public Animator createAnimator(@NonNull final ViewGroup sceneRoot, final TransitionValues startValues, final TransitionValues endValues) { if (startValues == null || endValues == null) { return null; }/*from ww w . j av a 2 s . c o m*/ final Rect startBounds = (Rect) startValues.values.get(PROP_BOUNDS); final Rect endBounds = (Rect) endValues.values.get(PROP_BOUNDS); final boolean fromFab = endBounds.width() > startBounds.width(); final View view = endValues.view; final Rect dialogBounds = fromFab ? endBounds : startBounds; final Rect fabBounds = fromFab ? startBounds : endBounds; final Interpolator fastOutSlowInInterpolator = new FastOutSlowInInterpolator(); final long duration = getDuration(); final long halfDuration = duration / 2; final long twoThirdsDuration = duration * 2 / 3; if (!fromFab) { // Force measure / layout the dialog back to it's original bounds view.measure(makeMeasureSpec(startBounds.width(), View.MeasureSpec.EXACTLY), makeMeasureSpec(startBounds.height(), View.MeasureSpec.EXACTLY)); view.layout(startBounds.left, startBounds.top, startBounds.right, startBounds.bottom); } final int translationX = startBounds.centerX() - endBounds.centerX(); final int translationY = startBounds.centerY() - endBounds.centerY(); if (fromFab) { view.setTranslationX(translationX); view.setTranslationY(translationY); } // Add a color overlay to fake appearance of the FAB final ColorDrawable fabColor = new ColorDrawable(color); fabColor.setBounds(0, 0, dialogBounds.width(), dialogBounds.height()); if (!fromFab) { fabColor.setAlpha(0); } view.getOverlay().add(fabColor); // Add an icon overlay again to fake the appearance of the FAB final Drawable fabIcon = ContextCompat.getDrawable(sceneRoot.getContext(), icon).mutate(); final int iconLeft = (dialogBounds.width() - fabIcon.getIntrinsicWidth()) / 2; final int iconTop = (dialogBounds.height() - fabIcon.getIntrinsicHeight()) / 2; fabIcon.setBounds(iconLeft, iconTop, iconLeft + fabIcon.getIntrinsicWidth(), iconTop + fabIcon.getIntrinsicHeight()); if (!fromFab) { fabIcon.setAlpha(0); } view.getOverlay().add(fabIcon); // Circular clip from/to the FAB size final Animator circularReveal; if (fromFab) { circularReveal = ViewAnimationUtils.createCircularReveal(view, view.getWidth() / 2, view.getHeight() / 2, startBounds.width() / 2, (float) Math.hypot(endBounds.width() / 2, endBounds.height() / 2)); circularReveal.setInterpolator(new FastOutLinearInInterpolator()); } else { circularReveal = ViewAnimationUtils.createCircularReveal(view, view.getWidth() / 2, view.getHeight() / 2, (float) Math.hypot(startBounds.width() / 2, startBounds.height() / 2), endBounds.width() / 2); circularReveal.setInterpolator(new LinearOutSlowInInterpolator()); // Persist the end clip i.e. stay at FAB size after the reveal has run circularReveal.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { view.setOutlineProvider(new ViewOutlineProvider() { @Override public void getOutline(View view, Outline outline) { final int left = (view.getWidth() - fabBounds.width()) / 2; final int top = (view.getHeight() - fabBounds.height()) / 2; outline.setOval(left, top, left + fabBounds.width(), top + fabBounds.height()); view.setClipToOutline(true); } }); } }); } circularReveal.setDuration(duration); // Translate to end position along an arc final Animator translate = ObjectAnimator.ofFloat(view, View.TRANSLATION_X, View.TRANSLATION_Y, fromFab ? getPathMotion().getPath(translationX, translationY, 0, 0) : getPathMotion().getPath(0, 0, -translationX, -translationY)); translate.setDuration(duration); translate.setInterpolator(fastOutSlowInInterpolator); // Fade contents of non-FAB view in/out List<Animator> fadeContents = null; if (view instanceof ViewGroup) { final ViewGroup vg = ((ViewGroup) view); fadeContents = new ArrayList<>(vg.getChildCount()); for (int i = vg.getChildCount() - 1; i >= 0; i--) { final View child = vg.getChildAt(i); final Animator fade = ObjectAnimator.ofFloat(child, View.ALPHA, fromFab ? 1f : 0f); if (fromFab) { child.setAlpha(0f); } fade.setDuration(twoThirdsDuration); fade.setInterpolator(fastOutSlowInInterpolator); fadeContents.add(fade); } } // Fade in/out the fab color & icon overlays final Animator colorFade = ObjectAnimator.ofInt(fabColor, "alpha", fromFab ? 0 : 255); final Animator iconFade = ObjectAnimator.ofInt(fabIcon, "alpha", fromFab ? 0 : 255); if (!fromFab) { colorFade.setStartDelay(halfDuration); iconFade.setStartDelay(halfDuration); } colorFade.setDuration(halfDuration); iconFade.setDuration(halfDuration); colorFade.setInterpolator(fastOutSlowInInterpolator); iconFade.setInterpolator(fastOutSlowInInterpolator); // Work around issue with elevation shadows. At the end of the return transition the shared // element's shadow is drawn twice (by each activity) which is jarring. This workaround // still causes the shadow to snap, but it's better than seeing it double drawn. Animator elevation = null; if (!fromFab) { elevation = ObjectAnimator.ofFloat(view, View.TRANSLATION_Z, -view.getElevation()); elevation.setDuration(duration); elevation.setInterpolator(fastOutSlowInInterpolator); } // Run all animations together final AnimatorSet transition = new AnimatorSet(); transition.playTogether(circularReveal, translate, colorFade, iconFade); transition.playTogether(fadeContents); if (elevation != null) { transition.play(elevation); } if (fromFab) { transition.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { // Clean up view.getOverlay().clear(); } }); } return new NoPauseAnimator(transition); }
From source file:net.semantic_error.turritype.sample.TypeActivity.java
@OnCheckedChanged({ R.id.interpolator_one, R.id.interpolator_multiple }) void interpolatorChange(CompoundButton checkBox) { if (!checkBox.isChecked()) return;//from w ww. j a v a 2 s .c om switch (checkBox.getId()) { case R.id.interpolator_one: interpolatorList = null; interpolator = new FastOutSlowInInterpolator(); break; case R.id.interpolator_multiple: interpolator = null; interpolatorList = getDefaultInterpolatorList(); break; default: speed = TurriType.NORMAL_SPEED; throw new IllegalStateException("Unsupported interpolator"); } updateAnimator(); }
From source file:com.sysdata.widget.accordion.ItemAnimator.java
@Override public boolean animateMove(final ViewHolder holder, int fromX, int fromY, int toX, int toY) { endAnimation(holder);//w w w.ja v a 2 s.com final int deltaX = toX - fromX; final int deltaY = toY - fromY; final long moveDuration = getMoveDuration(); if (deltaX == 0 && deltaY == 0) { dispatchMoveFinished(holder); return false; } final View view = holder.itemView; final float prevTranslationX = view.getTranslationX(); final float prevTranslationY = view.getTranslationY(); view.setTranslationX(-deltaX); view.setTranslationY(-deltaY); final ObjectAnimator moveAnimator; if (deltaX != 0 && deltaY != 0) { final PropertyValuesHolder moveX = PropertyValuesHolder.ofFloat(TRANSLATION_X, 0f); final PropertyValuesHolder moveY = PropertyValuesHolder.ofFloat(TRANSLATION_Y, 0f); moveAnimator = ObjectAnimator.ofPropertyValuesHolder(holder.itemView, moveX, moveY); } else if (deltaX != 0) { final PropertyValuesHolder moveX = PropertyValuesHolder.ofFloat(TRANSLATION_X, 0f); moveAnimator = ObjectAnimator.ofPropertyValuesHolder(holder.itemView, moveX); } else { final PropertyValuesHolder moveY = PropertyValuesHolder.ofFloat(TRANSLATION_Y, 0f); moveAnimator = ObjectAnimator.ofPropertyValuesHolder(holder.itemView, moveY); } moveAnimator.setDuration(moveDuration); moveAnimator.setInterpolator(new FastOutSlowInInterpolator()); moveAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animator) { dispatchMoveStarting(holder); } @Override public void onAnimationEnd(Animator animator) { animator.removeAllListeners(); mAnimators.remove(holder); view.setTranslationX(prevTranslationX); view.setTranslationY(prevTranslationY); dispatchMoveFinished(holder); } }); mMoveAnimatorsList.add(moveAnimator); mAnimators.put(holder, moveAnimator); return true; }
From source file:uk.co.samuelwall.materialtaptargetprompt.sample.MainActivity.java
public void showNoAutoDismiss(View view) { if (mFabPrompt != null) { return;/*from ww w .j av a2 s. c o m*/ } mFabPrompt = new MaterialTapTargetPrompt.Builder(MainActivity.this).setTarget(findViewById(R.id.fab)) .setPrimaryText("No Auto Dismiss") .setSecondaryText("This prompt will only be removed after tapping the envelop") .setAnimationInterpolator(new FastOutSlowInInterpolator()).setAutoDismiss(false) .setAutoFinish(false).setCaptureTouchEventOutsidePrompt(true) .setOnHidePromptListener(new MaterialTapTargetPrompt.OnHidePromptListener() { @Override public void onHidePrompt(MotionEvent event, boolean tappedTarget) { if (tappedTarget) { mFabPrompt.finish(); mFabPrompt = null; } } @Override public void onHidePromptComplete() { } }).show(); }