Example usage for android.animation Animator setInterpolator

List of usage examples for android.animation Animator setInterpolator

Introduction

In this page you can find the example usage for android.animation Animator setInterpolator.

Prototype

public abstract void setInterpolator(TimeInterpolator value);

Source Link

Document

The time interpolator used in calculating the elapsed fraction of the animation.

Usage

From source file:org.cyanogenmod.designertools.ui.CreditsActivity.java

private void circularRevealActivity(View v) {

    int cx = v.getWidth() / 2;
    int cy = v.getHeight() / 2;

    float finalRadius = Math.max(v.getWidth(), v.getHeight());

    // create the animator for this view (the start radius is zero)
    Animator circularReveal = ViewAnimationUtils.createCircularReveal(v, cx, cy, 0, finalRadius);
    circularReveal.setDuration(getResources().getInteger(R.integer.credits_circular_reveal_duration));

    // make the view visible and start the animation
    v.setVisibility(View.VISIBLE);
    circularReveal.setInterpolator(new AccelerateDecelerateInterpolator());
    circularReveal.addListener(new Animator.AnimatorListener() {
        @Override//w  w w .  j av  a  2 s.  co m
        public void onAnimationStart(Animator animator) {
        }

        @Override
        public void onAnimationEnd(Animator animator) {
            animateContent();
        }

        @Override
        public void onAnimationCancel(Animator animator) {
        }

        @Override
        public void onAnimationRepeat(Animator animator) {
        }
    });
    circularReveal.start();
}

From source file:com.google.samples.apps.iosched.ui.SearchActivity.java

/**
 * On Lollipop+ perform a circular animation (a contracting circular mask) when hiding the
 * search panel./*from  w  w  w.j  av  a  2  s . com*/
 */
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void doExitAnim() {
    final View searchPanel = findViewById(R.id.search_panel);
    // Center the animation on the top right of the panel i.e. near to the search button which
    // launched this screen. The starting radius therefore is the diagonal distance from the top
    // right to the bottom left
    int revealRadius = (int) Math
            .sqrt(Math.pow(searchPanel.getWidth(), 2) + Math.pow(searchPanel.getHeight(), 2));
    // Animating the radius to 0 produces the contracting effect
    Animator shrink = ViewAnimationUtils.createCircularReveal(searchPanel, searchPanel.getRight(),
            searchPanel.getTop(), revealRadius, 0f);
    shrink.setDuration(200L);
    shrink.setInterpolator(
            AnimationUtils.loadInterpolator(SearchActivity.this, android.R.interpolator.fast_out_slow_in));
    shrink.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            searchPanel.setVisibility(View.INVISIBLE);
            ActivityCompat.finishAfterTransition(SearchActivity.this);
        }
    });
    shrink.start();

    // We also animate out the translucent background at the same time.
    findViewById(R.id.scrim).animate().alpha(0f).setDuration(200L).setInterpolator(
            AnimationUtils.loadInterpolator(SearchActivity.this, android.R.interpolator.fast_out_slow_in))
            .start();
}

From source file:com.unipiazza.material2stepslogin.fragments.SecondStepFragment.java

private void createReveal(final View myView) {

    // get the center for the clipping circle
    int cx = (myView.getWidth()) / 2;
    int cy = (myView.getHeight()) / 2;

    // get the final radius for the clipping circle
    int finalRadius = Math.max(myView.getWidth(), myView.getHeight());

    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
        Animator animator = android.view.ViewAnimationUtils.createCircularReveal(myView, cx, cy, 0,
                finalRadius);/*w w w  .  j  a  v  a  2 s.co m*/
        animator.setDuration(800);
        animator.start();
    } else {
        SupportAnimator animator = ViewAnimationUtils.createCircularReveal(myView, cx, cy, 0, finalRadius);
        animator.setInterpolator(new AccelerateDecelerateInterpolator());
        animator.setDuration(800);
        animator.start();
    }
}

From source file:com.google.samples.apps.iosched.ui.SearchActivity.java

/**
 * On Lollipop+ perform a circular reveal animation (an expanding circular mask) when showing
 * the search panel.//from  w  ww.j a v a 2 s .  c o  m
 */
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void doEnterAnim() {
    // Fade in a background scrim as this is a floating window. We could have used a
    // translucent window background but this approach allows us to turn off window animation &
    // overlap the fade with the reveal animation  making it feel snappier.
    View scrim = findViewById(R.id.scrim);
    scrim.animate().alpha(1f).setDuration(500L)
            .setInterpolator(AnimationUtils.loadInterpolator(this, android.R.interpolator.fast_out_slow_in))
            .start();

    // Next perform the circular reveal on the search panel
    final View searchPanel = findViewById(R.id.search_panel);
    if (searchPanel != null) {
        // We use a view tree observer to set this up once the view is measured & laid out
        searchPanel.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
            @Override
            public boolean onPreDraw() {
                searchPanel.getViewTreeObserver().removeOnPreDrawListener(this);
                // As the height will change once the initial suggestions are delivered by the
                // loader, we can't use the search panels height to calculate the final radius
                // so we fall back to it's parent to be safe
                int revealRadius = ((ViewGroup) searchPanel.getParent()).getHeight();
                // Center the animation on the top right of the panel i.e. near to the
                // search button which launched this screen.
                Animator show = ViewAnimationUtils.createCircularReveal(searchPanel, searchPanel.getRight(),
                        searchPanel.getTop(), 0f, revealRadius);
                show.setDuration(250L);
                show.setInterpolator(AnimationUtils.loadInterpolator(SearchActivity.this,
                        android.R.interpolator.fast_out_slow_in));
                show.start();
                return false;
            }
        });
    }
}

From source file:systems.soapbox.ombuds.client.ui.omb.SearchActivity.java

/**
 * On Lollipop+ perform a circular reveal animation (an expanding circular mask) when showing
 * the search panel./*from www . j  av a  2s  .co m*/
 *
 * Support CircularReveal :
 * https://github.com/ozodrukh/CircularReveal
 */
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void doEnterAnim() {
    // Fade in a background scrim as this is a floating window. We could have used a
    // translucent window background but this approach allows us to turn off window animation &
    // overlap the fade with the reveal animation  making it feel snappier.
    View scrim = findViewById(R.id.scrim);
    scrim.animate().alpha(1f).setDuration(500L)
            .setInterpolator(AnimationUtils.loadInterpolator(this, android.R.interpolator.fast_out_slow_in))
            .start();

    // Next perform the circular reveal on the search panel
    final View searchPanel = findViewById(R.id.search_panel);
    if (searchPanel != null) {
        // We use a view tree observer to set this up once the view is measured & laid out
        searchPanel.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
            @Override
            public boolean onPreDraw() {
                searchPanel.getViewTreeObserver().removeOnPreDrawListener(this);
                // As the height will change once the initial suggestions are delivered by the
                // loader, we can't use the search panels height to calculate the final radius
                // so we fall back to it's parent to be safe
                int revealRadius = ((ViewGroup) searchPanel.getParent()).getHeight();
                // Center the animation on the top right of the panel i.e. near to the
                // search button which launched this screen.
                Animator show = ViewAnimationUtils.createCircularReveal(searchPanel, searchPanel.getRight(),
                        searchPanel.getTop(), 0f, revealRadius);
                show.setDuration(350L);
                show.setInterpolator(AnimationUtils.loadInterpolator(SearchActivity.this,
                        android.R.interpolator.fast_out_slow_in));
                show.start();
                return false;
            }
        });
    }
}

From source file:com.google.android.apps.gutenberg.ScannerActivity.java

private void showCheckinAnimation(Checkin checkin) {
    if (mLastAnimator != null) {
        mLastAnimator.cancel();// www  .ja v  a 2s  . co  m
    }
    final FrameLayout cover = (FrameLayout) findViewById(R.id.item_cover);
    cover.setVisibility(View.VISIBLE);
    final FrameLayout layer = (FrameLayout) findViewById(R.id.animation_layer);
    final CheckinHolder holder = new CheckinHolder(getLayoutInflater(), layer);
    FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
            FrameLayout.LayoutParams.WRAP_CONTENT);
    lp.gravity = Gravity.CENTER_VERTICAL;
    holder.setWillAnimate(true);
    holder.bind(checkin, mImageLoader);
    holder.itemView.setBackgroundColor(Color.rgb(0xf0, 0xf0, 0xf0));
    float elevation = getResources().getDimension(R.dimen.popup_elevation);
    ViewCompat.setTranslationZ(holder.itemView, elevation);
    holder.setLines(false, false);
    layer.addView(holder.itemView, lp);
    // Interpolator for animators
    FastOutSlowInInterpolator interpolator = new FastOutSlowInInterpolator();
    // Pop-up
    Animator popUpAnim = AnimatorInflater.loadAnimator(this, R.animator.pop_up);
    popUpAnim.setTarget(holder.itemView);
    popUpAnim.setInterpolator(interpolator);
    popUpAnim.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            holder.animateCheckin();
        }
    });
    // Wait
    ObjectAnimator waitAnim = new ObjectAnimator();
    waitAnim.setTarget(holder.itemView);
    waitAnim.setPropertyName("translationY");
    waitAnim.setFloatValues(0.f, 0.f);
    waitAnim.setDuration(2000);
    // Slide-down
    ObjectAnimator slideDownAnim = new ObjectAnimator();
    slideDownAnim.setTarget(holder.itemView);
    slideDownAnim.setPropertyName("translationY");
    slideDownAnim.setFloatValues(0.f, calcSlideDistance());
    slideDownAnim.setInterpolator(interpolator);
    // Landing anim
    ObjectAnimator landingAnim = new ObjectAnimator();
    landingAnim.setTarget(holder.itemView);
    landingAnim.setPropertyName("translationZ");
    landingAnim.setFloatValues(elevation, 0.f);
    landingAnim.setInterpolator(interpolator);
    landingAnim.setDuration(500);
    // Play the animators
    AnimatorSet set = new AnimatorSet();
    set.setInterpolator(interpolator);
    set.playSequentially(popUpAnim, waitAnim, slideDownAnim, landingAnim);
    set.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            clean();
        }

        @Override
        public void onAnimationCancel(Animator animation) {
            clean();
        }

        private void clean() {
            mLastAnimator = null;
            layer.removeAllViews();
            cover.setVisibility(View.INVISIBLE);
        }
    });
    mLastAnimator = set;
    set.start();
}

From source file:com.fastbootmobile.encore.app.ArtistActivity.java

@Override
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_artist);

    mHandler = new Handler();

    FragmentManager fm = getSupportFragmentManager();
    mActiveFragment = (ArtistFragment) fm.findFragmentByTag(TAG_FRAGMENT);

    if (savedInstanceState == null) {
        mHero = Utils.dequeueBitmap(BITMAP_ARTIST_HERO);
        mInitialIntent = getIntent().getExtras();
    } else {//from   w  w w .j a  v a 2s .  com
        mHero = Utils.dequeueBitmap(BITMAP_ARTIST_HERO);
        mInitialIntent = savedInstanceState.getBundle(EXTRA_RESTORE_INTENT);
    }

    if (mActiveFragment == null) {
        mActiveFragment = new ArtistFragment();
        fm.beginTransaction().add(R.id.container, mActiveFragment, TAG_FRAGMENT).commit();
    }

    mActiveFragment.setArguments(mHero, mInitialIntent);

    // Remove the activity title as we don't want it here
    mToolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(mToolbar);
    final ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setHomeButtonEnabled(true);
        actionBar.setTitle("");
    }

    mIsEntering = true;

    if (Utils.hasLollipop()) {
        setEnterSharedElementCallback(new SharedElementCallback() {
            @Override
            public void onMapSharedElements(List<String> names, Map<String, View> sharedElements) {
                View fab = mActiveFragment.findViewById(R.id.fabPlay);
                fab.setVisibility(View.VISIBLE);

                // get the center for the clipping circle
                int cx = fab.getMeasuredWidth() / 2;
                int cy = fab.getMeasuredHeight() / 2;

                // get the final radius for the clipping circle
                final int finalRadius = fab.getWidth();

                // create and start the animator for this view
                // (the start radius is zero)
                Animator anim;
                if (mIsEntering) {
                    anim = ViewAnimationUtils.createCircularReveal(fab, cx, cy, 0, finalRadius);
                } else {
                    anim = ViewAnimationUtils.createCircularReveal(fab, cx, cy, finalRadius, 0);
                }
                anim.setInterpolator(new DecelerateInterpolator());
                anim.start();

                fab.setTranslationX(-fab.getMeasuredWidth() / 4.0f);
                fab.setTranslationY(-fab.getMeasuredHeight() / 4.0f);
                fab.animate().translationX(0.0f).translationY(0.0f)
                        .setDuration(getResources().getInteger(android.R.integer.config_shortAnimTime))
                        .setInterpolator(new DecelerateInterpolator()).start();

                final View artistName = mActiveFragment.findViewById(R.id.tvArtist);
                if (artistName != null) {
                    cx = artistName.getMeasuredWidth() / 4;
                    cy = artistName.getMeasuredHeight() / 2;
                    final int duration = getResources().getInteger(android.R.integer.config_mediumAnimTime);
                    final int radius = Utils.getEnclosingCircleRadius(artistName, cx, cy);

                    if (mIsEntering) {
                        artistName.setVisibility(View.INVISIBLE);
                        Utils.animateCircleReveal(artistName, cx, cy, 0, radius, duration, 300);
                    } else {
                        artistName.setVisibility(View.VISIBLE);
                        Utils.animateCircleReveal(artistName, cx, cy, radius, 0, duration, 0);
                    }
                }
            }
        });
    }

    getWindow().getDecorView()
            .setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
}

From source file:com.fairphone.fplauncher3.Folder.java

private static Animator setupAlphaAnimator(final View v, final float startAlpha, final float endAlpha,
        final long duration, final long startDelay) {
    v.setAlpha(startAlpha);/*  w ww  . j  av  a 2s  .c  o m*/
    Animator animator = LauncherAnimUtils.ofFloat(v, "alpha", startAlpha, endAlpha);
    animator.setDuration(duration);
    animator.setStartDelay(startDelay);
    animator.setInterpolator(new LogDecelerateInterpolator(60, 0));
    animator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            // in low power mode the animation doesn't play, so set the end value here
            v.setAlpha(endAlpha);
        }
    });

    return animator;
}

From source file:com.oceansky.yellow.app.ArtistActivity.java

@Override
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_artist);

    mHandler = new Handler();

    FragmentManager fm = getSupportFragmentManager();
    mActiveFragment = (ArtistFragment) fm.findFragmentByTag(TAG_FRAGMENT);

    if (savedInstanceState == null) {
        mHero = Utils.dequeueBitmap(BITMAP_ARTIST_HERO);
        mInitialIntent = getIntent().getExtras();
    } else {//from   ww  w .  j  a  v  a2  s .com
        mHero = Utils.dequeueBitmap(BITMAP_ARTIST_HERO);
        mInitialIntent = savedInstanceState.getBundle(EXTRA_RESTORE_INTENT);
    }

    if (mActiveFragment == null) {
        mActiveFragment = new ArtistFragment();
        fm.beginTransaction().add(R.id.container, mActiveFragment, TAG_FRAGMENT).commit();
    }

    try {
        mActiveFragment.setArguments(mHero, mInitialIntent);
    } catch (IllegalStateException e) {
        Log.e(TAG, "Invalid artist!", e);
    }

    // Remove the activity title as we don't want it here
    mToolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(mToolbar);
    final ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setHomeButtonEnabled(true);
        actionBar.setTitle("");
    }

    mIsEntering = true;

    if (Utils.hasLollipop()) {
        setEnterSharedElementCallback(new SharedElementCallback() {
            @Override
            public void onMapSharedElements(List<String> names, Map<String, View> sharedElements) {
                View fab = mActiveFragment.findViewById(R.id.fabPlay);
                fab.setVisibility(View.VISIBLE);

                // get the center for the clipping circle
                int cx = fab.getMeasuredWidth() / 2;
                int cy = fab.getMeasuredHeight() / 2;

                // get the final radius for the clipping circle
                final int finalRadius = fab.getWidth();

                // create and start the animator for this view
                // (the start radius is zero)
                Animator anim;
                if (mIsEntering) {
                    anim = ViewAnimationUtils.createCircularReveal(fab, cx, cy, 0, finalRadius);
                } else {
                    anim = ViewAnimationUtils.createCircularReveal(fab, cx, cy, finalRadius, 0);
                }
                anim.setInterpolator(new DecelerateInterpolator());
                anim.start();

                fab.setTranslationX(-fab.getMeasuredWidth() / 4.0f);
                fab.setTranslationY(-fab.getMeasuredHeight() / 4.0f);
                fab.animate().translationX(0.0f).translationY(0.0f)
                        .setDuration(getResources().getInteger(android.R.integer.config_shortAnimTime))
                        .setInterpolator(new DecelerateInterpolator()).start();

                final View artistName = mActiveFragment.findViewById(R.id.tvArtist);
                if (artistName != null) {
                    cx = artistName.getMeasuredWidth() / 4;
                    cy = artistName.getMeasuredHeight() / 2;
                    final int duration = getResources().getInteger(android.R.integer.config_mediumAnimTime);
                    final int radius = Utils.getEnclosingCircleRadius(artistName, cx, cy);

                    if (mIsEntering) {
                        artistName.setVisibility(View.INVISIBLE);
                        Utils.animateCircleReveal(artistName, cx, cy, 0, radius, duration, 300);
                    } else {
                        artistName.setVisibility(View.VISIBLE);
                        Utils.animateCircleReveal(artistName, cx, cy, radius, 0, duration, 0);
                    }
                }
            }
        });
    }

    getWindow().getDecorView()
            .setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
}

From source file:ca.zadrox.dota2esportticker.ui.TeamDetailActivity.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void createCircularReveal() {

    mHeaderTeamLogo.setVisibility(View.VISIBLE);
    mHeaderTeamLogo.setImageBitmap(mTeam.logo);

    if (mHeaderBox.isAttachedToWindow()) {
        mHeaderTeamLogo.setTranslationY(-UIUtils.calculateActionBarSize(this) - mHeaderTeamLogo.getHeight());

        mHeaderTeamLogo.animate().translationY(0).setDuration(100)
                .setInterpolator(new AccelerateDecelerateInterpolator())
                .setListener(new Animator.AnimatorListener() {
                    @Override//from  ww w  .  ja va2s  .c  o  m
                    public void onAnimationStart(Animator animation) {

                    }

                    @Override
                    public void onAnimationEnd(Animator animation) {
                        int cx = (mHeaderBox.getLeft() + mHeaderBox.getRight()) / 2;
                        int cy = (mHeaderBox.getTop() + mHeaderBox.getBottom()) / 2;

                        int finalRadius = Math.max(mHeaderBox.getWidth(), mHeaderBox.getHeight());

                        final Animator anim = ViewAnimationUtils.createCircularReveal(mHeaderBox, cx, cy, 0,
                                finalRadius);

                        anim.setDuration(250);
                        anim.setInterpolator(new AccelerateDecelerateInterpolator());
                        anim.addListener(new Animator.AnimatorListener() {
                            @Override
                            public void onAnimationStart(Animator animation) {
                                mHeaderTeamName.setAlpha(1);
                                mHeaderTeamLogo.setImageBitmap(mTeam.logo);
                                mHeaderBox.setBackgroundColor(mTeam.palette
                                        .getDarkVibrantColor(getResources().getColor(R.color.theme_primary)));
                            }

                            @Override
                            public void onAnimationEnd(Animator animation) {

                            }

                            @Override
                            public void onAnimationCancel(Animator animation) {

                            }

                            @Override
                            public void onAnimationRepeat(Animator animation) {

                            }
                        });
                        anim.start();
                    }

                    @Override
                    public void onAnimationCancel(Animator animation) {

                    }

                    @Override
                    public void onAnimationRepeat(Animator animation) {

                    }
                }).start();

    } else {
        mHeaderTeamName.setAlpha(1);
        mHeaderTeamLogo.setImageBitmap(mTeam.logo);
        mHeaderBox.setBackgroundColor(
                mTeam.palette.getDarkVibrantColor(getResources().getColor(R.color.theme_primary)));
    }
}