Example usage for android.transition TransitionSet setInterpolator

List of usage examples for android.transition TransitionSet setInterpolator

Introduction

In this page you can find the example usage for android.transition TransitionSet setInterpolator.

Prototype

@Override
    public TransitionSet setInterpolator(TimeInterpolator interpolator) 

Source Link

Usage

From source file:com.kogitune.activitytransition.ActivityTransition.java

public ExitActivityTransition start(Bundle savedInstanceState) {
    if (interpolator == null) {
        interpolator = new DecelerateInterpolator();
    }/* ww w  .  jav a 2 s  . co  m*/

    final Bundle bundle = fromIntent.getExtras();
    if (Build.VERSION.SDK_INT >= 21) {
        final TransitionData transitionData = new TransitionData(toView.getContext(), bundle);
        if (transitionData.imageFilePath != null) {
            TransitionAnimation.setImageToView(toView, transitionData.imageFilePath);
        }

        ViewCompat.setTransitionName(toView, toViewName);
        final Window window = ((Activity) context).getWindow();
        TransitionSet set = new TransitionSet();
        set.addTransition(new ChangeBounds());
        set.addTransition(new ChangeImageTransform());
        set.setInterpolator(interpolator);

        window.setSharedElementEnterTransition(set);
        window.setSharedElementReturnTransition(set);

        return new ExitActivityTransition(null);
    }
    final Context context = toView.getContext();
    final MoveData moveData = TransitionAnimation.startAnimation(context, toView, bundle, savedInstanceState,
            duration, interpolator);

    return new ExitActivityTransition(moveData);
}

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   ww w.ja v  a  2s  . c om*/
        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
    }
}