Example usage for android.view.animation AccelerateDecelerateInterpolator AccelerateDecelerateInterpolator

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

Introduction

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

Prototype

public AccelerateDecelerateInterpolator() 

Source Link

Usage

From source file:com.example.jonas.materialmockups.activities.ExhibitDetailsActivity.java

/**
 * Shows the audio toolbar./*w  ww  .  j av a2  s .  c  o m*/
 * @return true if the toolbar has been revealed, false otherwise.
 */
private boolean showAudioToolbar() {
    // check only if mRevealView != null. If isAudioToolbarHidden == true is also checked,
    // the toolbar cannot be displayed on savedInstanceState
    if (mRevealView != null) {
        int cx = (mRevealView.getLeft() + mRevealView.getRight());
        int cy = mRevealView.getTop();
        int radius = Math.max(mRevealView.getWidth(), mRevealView.getHeight());

        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {

            SupportAnimator animator = ViewAnimationUtils.createCircularReveal(mRevealView, cx, cy, 0, radius);
            animator.setInterpolator(new AccelerateDecelerateInterpolator());
            animator.setDuration(800);

            mRevealView.setVisibility(View.VISIBLE);
            animator.start();

        } else {
            Animator anim = android.view.ViewAnimationUtils.createCircularReveal(mRevealView, cx, cy, 0,
                    radius);
            mRevealView.setVisibility(View.VISIBLE);
            anim.start();
        }

        isAudioToolbarHidden = false;
        return true;
    }

    return false;
}

From source file:org.tomahawk.tomahawk_android.fragments.PlaybackFragment.java

private void setupAlbumArtAnimation() {
    if (mAlbumArtViewPager != null) {
        ViewUtils.afterViewGlobalLayout(new ViewUtils.ViewRunnable(mAlbumArtViewPager) {
            @Override//from  ww  w . j  a v  a2s. c om
            public void run() {
                if (mOriginalViewPagerHeight <= 0) {
                    mOriginalViewPagerHeight = mAlbumArtViewPager.getHeight();
                }

                // now calculate the animation goal and instantiate the animation
                int playbackPanelHeight = TomahawkApp.getContext().getResources()
                        .getDimensionPixelSize(R.dimen.playback_panel_height);
                ValueAnimator animator = ObjectAnimator.ofFloat(getLayedOutView(), "y", playbackPanelHeight,
                        getLayedOutView().getHeight() / -4).setDuration(10000);
                animator.setInterpolator(new AccelerateDecelerateInterpolator());
                addAnimator(ANIM_ALBUMART_ID, animator);

                refreshAnimations();
            }
        });
    }
}

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 w  w  w .  ja  v a2 s  .  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:com.example.jonas.materialmockups.activities.ExhibitDetailsActivity.java

/**
 * Hides the audio toolbar./*from   w  ww  .  j  av a 2  s. co  m*/
 * @return true if the audio toolbar was hidden, false otherwise
 */
private boolean hideAudioToolbar() {
    if (mRevealView != null) {
        int cx = (mRevealView.getLeft() + mRevealView.getRight());
        int cy = mRevealView.getTop();
        int radius = Math.max(mRevealView.getWidth(), mRevealView.getHeight());

        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {

            SupportAnimator animator = ViewAnimationUtils.createCircularReveal(mRevealView, cx, cy, 0, radius);
            animator.setInterpolator(new AccelerateDecelerateInterpolator());
            animator.setDuration(800);

            SupportAnimator animator_reverse = animator.reverse();
            animator_reverse.addListener(new SupportAnimator.AnimatorListener() {
                @Override
                public void onAnimationStart() {

                }

                @Override
                public void onAnimationEnd() {
                    mRevealView.setVisibility(View.INVISIBLE);
                    isAudioToolbarHidden = true;

                }

                @Override
                public void onAnimationCancel() {

                }

                @Override
                public void onAnimationRepeat() {

                }
            });
            animator_reverse.start();

        } else {
            Animator anim = android.view.ViewAnimationUtils.createCircularReveal(mRevealView, cx, cy, radius,
                    0);
            anim.addListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                    super.onAnimationEnd(animation);
                    mRevealView.setVisibility(View.INVISIBLE);
                    isAudioToolbarHidden = true;
                }
            });
            anim.start();

        }

        return true;
    }

    return false;
}

From source file:com.pitchedapps.primenumbercalculator.Calculator.java

License:asdf

@Override
public void onTextSizeChanged(final TextView textView, float oldSize) {
    if (mCurrentState != CalculatorState.INPUT) {
        // Only animate text changes that occur from user input.
        return;/* w  ww  . j  av  a  2 s .  c o  m*/
    }

    // Calculate the values needed to perform the scale and translation animations,
    // maintaining the same apparent baseline for the displayed text.
    final float textScale = oldSize / textView.getTextSize();
    final float translationX = (1.0f - textScale) * (textView.getWidth() / 2.0f - textView.getPaddingEnd());
    final float translationY = (1.0f - textScale) * (textView.getHeight() / 2.0f - textView.getPaddingBottom());

    final AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.playTogether(ObjectAnimator.ofFloat(textView, View.SCALE_X, textScale, 1.0f),
            ObjectAnimator.ofFloat(textView, View.SCALE_Y, textScale, 1.0f),
            ObjectAnimator.ofFloat(textView, View.TRANSLATION_X, translationX, 0.0f),
            ObjectAnimator.ofFloat(textView, View.TRANSLATION_Y, translationY, 0.0f));
    animatorSet.setDuration(getResources().getInteger(android.R.integer.config_mediumAnimTime));
    animatorSet.setInterpolator(new AccelerateDecelerateInterpolator());
    animatorSet.start();
}

From source file:devlight.io.library.ArcProgressStackView.java

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public void setInterpolator(final Interpolator interpolator) {
    mInterpolator = interpolator == null ? new AccelerateDecelerateInterpolator() : interpolator;
    mProgressAnimator.setInterpolator(mInterpolator);
}

From source file:com.sociablue.nanodegree_p1.MovieListFragment.java

public void setupTransitions(final MovieDetailPagerFragment newFragment, ImageView posterImageView) {
    //TODO: Shared Element Return Transition

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        // Inflate transitions to apply
        TransitionSet changeTransitionSet = new TransitionSet();
        Transition changeTransform = new ChangeTransform();
        changeTransitionSet.addTransition(changeTransform);
        changeTransitionSet.addTransition(new ChangeBounds());
        changeTransitionSet.setDuration(200);
        changeTransitionSet.setInterpolator(new AccelerateDecelerateInterpolator());
        this.setAllowEnterTransitionOverlap(true);
        this.setAllowReturnTransitionOverlap(true);

        // Setup enter transition on second fragment
        newFragment.setSharedElementEnterTransition(changeTransitionSet);
        newFragment.setAllowEnterTransitionOverlap(true);

        // Find the shared element (in Fragment A)
        moviePoster = posterImageView;/*from  w  ww .  j  a va  2  s  .co m*/
        moviePoster.setTransitionName("movie_poster");

        // Add and hide details view pager fragment. Adding fragment, creates view and downloads images.
        getFragmentManager().beginTransaction().add(R.id.movie_list_fragment, newFragment, "detail")
                .addToBackStack("transaction2").hide(newFragment).commit();

    } else {
        // Code to run on older devices
        //TODO: Handle older devices
    }
}

From source file:org.runbuddy.tomahawk.ui.fragments.PlaybackFragment.java

private void setupAlbumArtAnimation() {
    if (mAlbumArtViewPagerFrame != null) {
        ViewUtils.afterViewGlobalLayout(new ViewUtils.ViewRunnable(mAlbumArtViewPagerFrame) {
            @Override//from w  ww .j a  v  a  2  s.c  o  m
            public void run() {
                if (mOriginalViewPagerHeight <= 0) {
                    mOriginalViewPagerHeight = mAlbumArtViewPager.getHeight();
                }

                // now calculate the animation goal and instantiate the animation
                int playbackPanelHeight = TomahawkApp.getContext().getResources()
                        .getDimensionPixelSize(R.dimen.playback_panel_height);
                ValueAnimator animator = ObjectAnimator.ofFloat(getLayedOutView(), "y", playbackPanelHeight,
                        getLayedOutView().getHeight() / -4).setDuration(10000);
                animator.setInterpolator(new AccelerateDecelerateInterpolator());
                addAnimator(ANIM_ALBUMART_ID, animator);

                refreshAnimations();
            }
        });
    }
}

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

@TargetApi(21)
private void showLollipopImpl() {
    int rootWidth = mRoot.getWidth();

    float endFabX;
    float controlX;

    if (mFabOriginalX > rootWidth / 2f) {
        endFabX = rootWidth / 2f + (mFabOriginalX - rootWidth / 2f) / 4f;
        controlX = mFabOriginalX * 0.98f;
    } else {//from www.ja va 2 s. c o m
        endFabX = rootWidth / 2f - (mFabOriginalX - rootWidth / 2f) / 4f;
        controlX = mFabOriginalX * 1.02f;
    }

    /**
     * Animate FAB movement
     */
    final Path path = new Path();
    path.moveTo(mFab.getX(), mFab.getY());
    final float x2 = controlX;
    final float y2 = getY();
    path.quadTo(x2, y2, endFabX, getY());
    ObjectAnimator anim = ObjectAnimator.ofFloat(mFab, View.X, View.Y, path);
    anim.setInterpolator(new AccelerateDecelerateInterpolator());
    anim.setDuration(FAB_MORPH_DURATION);
    anim.start();

    /**
     * Fade FAB drawable
     */
    Drawable drawable = mFab.getDrawable();
    if (drawable != null) {
        anim = ObjectAnimator.ofPropertyValuesHolder(drawable, PropertyValuesHolder.ofInt("alpha", 0));
        anim.setInterpolator(new AccelerateDecelerateInterpolator());
        anim.setDuration((long) (FAB_MORPH_DURATION / 3f));
        anim.start();
    }

    /**
     * Animate FAB elevation to 8dp
     */
    anim = ObjectAnimator.ofFloat(mFab, View.TRANSLATION_Z, dpToPixels(2));
    anim.setInterpolator(new AccelerateDecelerateInterpolator());
    anim.setDuration(FAB_MORPH_DURATION);
    anim.start();

    /**
     * Create circular reveal
     */
    Animator toolbarReveal = ViewAnimationUtils.createCircularReveal(this, getWidth() / 2, getHeight() / 2,
            (float) mFab.getWidth() / 2f, (float) (Math.hypot(getWidth() / 2, getHeight() / 2)));

    toolbarReveal.setDuration(CIRCULAR_REVEAL_DURATION);
    toolbarReveal.setTarget(this);
    toolbarReveal.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationStart(Animator animation) {
            super.onAnimationStart(animation);
            mFab.setVisibility(View.INVISIBLE);
            setVisibility(View.VISIBLE);
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            mMorphing = false;
        }
    });

    toolbarReveal.setInterpolator(new AccelerateInterpolator());
    toolbarReveal.setStartDelay(CIRCULAR_REVEAL_DELAY);
    toolbarReveal.start();

    /**
     * Animate FloatingToolbar elevation to 8dp
     */
    anim = ObjectAnimator.ofFloat(this, View.TRANSLATION_Z, dpToPixels(2));
    anim.setDuration(CIRCULAR_REVEAL_DURATION);
    anim.setStartDelay(CIRCULAR_REVEAL_DELAY);
    anim.start();
}

From source file:com.hamzahrmalik.calculator2.Calculator.java

private void onResult(final String result) {
    // Calculate the values needed to perform the scale and translation
    // animations,
    // accounting for how the scale will affect the final position of the
    // text./*from  ww  w .  j a v  a 2 s  .c  o m*/
    final float resultScale = mFormulaEditText.getVariableTextSize(result) / mResultEditText.getTextSize();
    final float resultTranslationX = (1.0f - resultScale)
            * (mResultEditText.getWidth() / 2.0f - mResultEditText.getPaddingEnd());
    final float resultTranslationY = (1.0f - resultScale)
            * (mResultEditText.getHeight() / 2.0f - mResultEditText.getPaddingBottom())
            + (mFormulaEditText.getBottom() - mResultEditText.getBottom())
            + (mResultEditText.getPaddingBottom() - mFormulaEditText.getPaddingBottom());
    final float formulaTranslationY = -mFormulaEditText.getBottom();

    // Use a value animator to fade to the final text color over the course
    // of the animation.
    final int resultTextColor = mResultEditText.getCurrentTextColor();
    final int formulaTextColor = mFormulaEditText.getCurrentTextColor();
    final ValueAnimator textColorAnimator = ValueAnimator.ofObject(new ArgbEvaluator(), resultTextColor,
            formulaTextColor);
    textColorAnimator.addUpdateListener(new AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            /*
             * mResultEditText.setTextColor((int) valueAnimator
             * .getAnimatedValue());
             */
        }
    });

    final AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.playTogether(textColorAnimator,
            ObjectAnimator.ofFloat(mResultEditText, View.SCALE_X, resultScale),
            ObjectAnimator.ofFloat(mResultEditText, View.SCALE_Y, resultScale),
            ObjectAnimator.ofFloat(mResultEditText, View.TRANSLATION_X, resultTranslationX),
            ObjectAnimator.ofFloat(mResultEditText, View.TRANSLATION_Y, resultTranslationY),
            ObjectAnimator.ofFloat(mFormulaEditText, View.TRANSLATION_Y, formulaTranslationY));
    animatorSet.setDuration(getResources().getInteger(android.R.integer.config_longAnimTime));
    animatorSet.setInterpolator(new AccelerateDecelerateInterpolator());
    animatorSet.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationStart(Animator animation) {
            mResultEditText.setText(result);
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            // Reset all of the values modified during the animation.
            mResultEditText.setTextColor(resultTextColor);
            mResultEditText.setScaleX(1.0f);
            mResultEditText.setScaleY(1.0f);
            mResultEditText.setTranslationX(0.0f);
            mResultEditText.setTranslationY(0.0f);
            mFormulaEditText.setTranslationY(0.0f);

            // Finally update the formula to use the current result.
            mFormulaEditText.setText(result);
            setState(CalculatorState.RESULT);

            mCurrentAnimator = null;
        }
    });

    mCurrentAnimator = animatorSet;
    animatorSet.start();
}