Search in sources :

Example 1 with TransitionAdapter

use of com.hackvg.android.views.custom_listeners.TransitionAdapter in project Material-Movies by saulmm.

the class MovieDetailActivity method configureEnterTransition.

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void configureEnterTransition() {
    getWindow().setSharedElementEnterTransition(TransitionUtils.makeSharedElementEnterTransition(this));
    postponeEnterTransition();
    int moviePosition = getIntent().getIntExtra(MoviesActivity.EXTRA_MOVIE_POSITION, 0);
    mCoverImageView.setTransitionName(MoviesActivity.SHARED_ELEMENT_COVER + moviePosition);
    mObservableScrollView.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {

        @Override
        public boolean onPreDraw() {
            mObservableScrollView.getViewTreeObserver().removeOnPreDrawListener(this);
            startPostponedEnterTransition();
            return true;
        }
    });
    getWindow().getSharedElementEnterTransition().addListener(new TransitionAdapter() {

        @Override
        public void onTransitionEnd(Transition transition) {
            super.onTransitionEnd(transition);
            animateElementsByScale();
        }
    });
}
Also used : TransitionAdapter(com.hackvg.android.views.custom_listeners.TransitionAdapter) Transition(android.transition.Transition) ViewTreeObserver(android.view.ViewTreeObserver) TargetApi(android.annotation.TargetApi)

Aggregations

TargetApi (android.annotation.TargetApi)1 Transition (android.transition.Transition)1 ViewTreeObserver (android.view.ViewTreeObserver)1 TransitionAdapter (com.hackvg.android.views.custom_listeners.TransitionAdapter)1