Example usage for android.transition ChangeTransform ChangeTransform

List of usage examples for android.transition ChangeTransform ChangeTransform

Introduction

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

Prototype

public ChangeTransform() 

Source Link

Usage

From source file:net.huannguyen.conductorexample.transition.DetailPushTransChangeHandler.java

@NonNull
@Override/*from w w  w .  jav a  2 s .  c o  m*/
protected Transition getTransition(@NonNull ViewGroup container, @Nullable View from, @Nullable View to,
        boolean isPush) {

    if (to == null || !(to instanceof CountryDetailView)) {
        throw new IllegalArgumentException("The to view must be a CountryDetailView");
    }

    final CountryDetailView detailView = (CountryDetailView) to;

    detailView.flagView.setTransitionName(flagViewTransitionName);

    ChangeTransform changeTransform = new ChangeTransform();

    // Shared elements (the flag view in this case) are drawn in the window's view overlay during the transition by default.
    // That causes the favourite fab being drawn behind the flag when it is scaled up.
    // Setting the change transform not using overlay addresses this issue.
    changeTransform.setReparentWithOverlay(false);

    return new TransitionSet()
            .addTransition(new TransitionSet().addTransition(new ChangeBounds())
                    .addTransition(new ChangeClipBounds()).addTransition(changeTransform)
                    .addTransition(new ChangeImageTransform()).setDuration(300))
            .addTransition(new Slide().addTarget(detailView.detailGroup).setStartDelay(150))
            .addTransition(new Scale().addTarget(detailView.favouriteFab).setStartDelay(300))
            .setInterpolator(new FastOutSlowInInterpolator());
}

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 w  w  .  j av a2 s.  c o  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
    }
}