Search in sources :

Example 1 with Explode

use of androidx.transition.Explode in project Transitions-Everywhere by andkulikov.

the class ExplodeAndEpicenterExample method letsExplodeIt.

private void letsExplodeIt(View clickedView) {
    // save rect of view in screen coordinated
    final Rect viewRect = new Rect();
    clickedView.getGlobalVisibleRect(viewRect);
    final Explode explode = new Explode();
    explode.setEpicenterCallback(new Transition.EpicenterCallback() {

        @Override
        public Rect onGetEpicenter(Transition transition) {
            return viewRect;
        }
    });
    explode.excludeTarget(clickedView, true);
    TransitionSet set = new TransitionSet().addTransition(explode).addTransition(new Fade().addTarget(clickedView)).addListener(new TransitionListenerAdapter() {

        @Override
        public void onTransitionEnd(Transition transition) {
            transition.removeListener(this);
            getActivity().onBackPressed();
        }
    });
    TransitionManager.beginDelayedTransition(mRecyclerView, set);
    // remove all views from Recycler View
    mRecyclerView.setAdapter(null);
}
Also used : Explode(androidx.transition.Explode) Rect(android.graphics.Rect) TransitionSet(androidx.transition.TransitionSet) Transition(androidx.transition.Transition) TransitionListenerAdapter(androidx.transition.TransitionListenerAdapter) Fade(androidx.transition.Fade)

Aggregations

Rect (android.graphics.Rect)1 Explode (androidx.transition.Explode)1 Fade (androidx.transition.Fade)1 Transition (androidx.transition.Transition)1 TransitionListenerAdapter (androidx.transition.TransitionListenerAdapter)1 TransitionSet (androidx.transition.TransitionSet)1