Example usage for android.transition Transition addListener

List of usage examples for android.transition Transition addListener

Introduction

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

Prototype

public Transition addListener(TransitionListener listener) 

Source Link

Document

Adds a listener to the set of listeners that are sent events through the life of an animation, such as start, repeat, and end.

Usage

From source file:com.clemot.julian.easylib.EasyActivity.java

public FragmentTransaction addTransitions(FragmentTransaction fragmentTransaction, Fragment currentFragment,
        final Fragment nextFragment, Pair<View, String>... sharedElements) {
    if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {

        // Set shared and scene transitions

        //setSharedElementReturnTransition(TransitionInflater.from(getActivity()).inflateTransition(R.transition.trans_move));
        //setExitTransition(TransitionInflater.from(getActivity()).inflateTransition(android.R.transition.explode));

        //Exit Transition for the current Fragment
        currentFragment/*from   ww  w.jav  a 2s.c o m*/
                .setExitTransition(TransitionInflater.from(this).inflateTransition(R.transition.trans_move));

        //ReEnter Transition for the current Fragment
        currentFragment
                .setReenterTransition(TransitionInflater.from(this).inflateTransition(R.transition.trans_move));

        nextFragment.setSharedElementReturnTransition(
                TransitionInflater.from(this).inflateTransition(R.transition.trans_move));
        // Set shared and scene transitions on 2nd fragment
        nextFragment.setSharedElementEnterTransition(
                TransitionInflater.from(this).inflateTransition(R.transition.trans_move));

        Transition transition = TransitionInflater.from(this).inflateTransition(android.R.transition.explode);
        transition.addListener(new Transition.TransitionListener() {
            @Override
            public void onTransitionStart(Transition transition) {
                ((EasyFragment) nextFragment).onTransitionStart(transition);
            }

            @Override
            public void onTransitionEnd(Transition transition) {
                ((EasyFragment) nextFragment).onTransitionEnd(transition);
            }

            @Override
            public void onTransitionCancel(Transition transition) {
                ((EasyFragment) nextFragment).onTransitionEnd(transition);
            }

            @Override
            public void onTransitionPause(Transition transition) {
                ((EasyFragment) nextFragment).onTransitionPause(transition);
            }

            @Override
            public void onTransitionResume(Transition transition) {
                ((EasyFragment) nextFragment).onTransitionResume(transition);
            }
        });
        nextFragment.setEnterTransition(transition);

        //Return Transition for the next Fragment
        nextFragment.setReturnTransition(
                TransitionInflater.from(this).inflateTransition(android.R.transition.explode));

        for (int i = 0; i < sharedElements.length; i++) {
            ViewCompat.setTransitionName(sharedElements[i].first, sharedElements[i].second);
            fragmentTransaction.addSharedElement(sharedElements[i].first, sharedElements[i].second);
        }
    }
    return fragmentTransaction;
}

From source file:us.phyxsi.gameshelf.ui.FeedAdapter.java

/**
 * The shared element transition to dribbble shots & dn stories can intersect with the FAB.
 * This can cause a strange layers-passing-through-each-other effect, especially on return.
 * In this situation, hide the FAB on exit and re-show it on return.
 *//* ww  w .ja  va  2 s . co m*/
private void setGridItemContentTransitions(View gridItem) {
    if (host.findViewById(R.id.fab) == null)
        return;
    if (!ViewUtils.viewsIntersect(gridItem, host.findViewById(R.id.fab)))
        return;

    final TransitionInflater ti = TransitionInflater.from(host);
    host.getWindow().setExitTransition(ti.inflateTransition(R.transition.home_content_item_exit));
    final Transition reenter = ti.inflateTransition(R.transition.home_content_item_reenter);
    // we only want this content transition in certain cases so clear it out after it's done.
    reenter.addListener(new AnimUtils.TransitionListenerAdapter() {
        @Override
        public void onTransitionEnd(Transition transition) {
            host.getWindow().setExitTransition(null);
            host.getWindow().setReenterTransition(null);
        }
    });
    host.getWindow().setReenterTransition(reenter);
}

From source file:spit.matrix2017.Activities.EventDetails.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void setupEnterAnimation() {
    Transition transition = TransitionInflater.from(this).inflateTransition(R.transition.transition);
    transition.setDuration(300);/*ww  w  .j a  va 2  s. com*/
    getWindow().setSharedElementEnterTransition(transition);
    transition.addListener(new Transition.TransitionListener() {
        @Override
        public void onTransitionStart(Transition transition) {
        }

        @Override
        public void onTransitionEnd(Transition transition) {
            fab.show();
        }

        @Override
        public void onTransitionCancel(Transition transition) {
        }

        @Override
        public void onTransitionPause(Transition transition) {
        }

        @Override
        public void onTransitionResume(Transition transition) {
        }
    });
}

From source file:io.plaidapp.core.ui.FeedAdapter.java

/**
 * The shared element transition to dribbble shots & dn stories can intersect with the FAB.
 * This can cause a strange layers-passing-through-each-other effect. On return hide the FAB
 * and animate it back in after the transition.
 *//*from w  w  w .ja  va  2  s .com*/
private void setGridItemContentTransitions(View gridItem) {
    final View fab = host.findViewById(R.id.fab);
    if (!ViewUtils.viewsIntersect(gridItem, fab))
        return;

    Transition reenter = TransitionInflater.from(host).inflateTransition(R.transition.grid_overlap_fab_reenter);
    reenter.addListener(new TransitionUtils.TransitionListenerAdapter() {

        @Override
        public void onTransitionEnd(Transition transition) {
            // we only want these content transitions in certain cases so clear out when done.
            host.getWindow().setReenterTransition(null);
        }
    });
    host.getWindow().setReenterTransition(reenter);
}

From source file:io.plaidapp.ui.FeedAdapter.java

/**
 * The shared element transition to dribbble shots & dn stories can intersect with the FAB.
 * This can cause a strange layers-passing-through-each-other effect, especially on return.
 * In this situation, hide the FAB on exit and re-show it on return.
 *///from   www.  java 2 s  . co m
private void setGridItemContentTransitions(View gridItem) {
    if (!ViewUtils.viewsIntersect(gridItem, host.findViewById(R.id.fab)))
        return;

    final TransitionInflater ti = TransitionInflater.from(host);
    host.getWindow().setExitTransition(ti.inflateTransition(R.transition.home_content_item_exit));
    final Transition reenter = ti.inflateTransition(R.transition.home_content_item_reenter);
    // we only want this content transition in certain cases so clear it out after it's done.
    reenter.addListener(new AnimUtils.TransitionListenerAdapter() {
        @Override
        public void onTransitionEnd(Transition transition) {
            host.getWindow().setExitTransition(null);
            host.getWindow().setReenterTransition(null);
        }
    });
    host.getWindow().setReenterTransition(reenter);
}

From source file:com.zertinteractive.wallpaper.MainActivity.java

@SuppressWarnings("NewApi")
private void setupEnterAnimations() {
    Transition transition = TransitionInflater.from(this)
            .inflateTransition(R.transition.changebounds_with_arcmotion);
    getWindow().setSharedElementEnterTransition(transition);
    transition.addListener(new Transition.TransitionListener() {
        @Override/*from w  ww . j av  a 2  s . c  o  m*/
        public void onTransitionStart(Transition transition) {
        }

        @Override
        public void onTransitionEnd(Transition transition) {
            // Removing listener here is very important because shared element transition is executed again backwards on exit. If we don't remove the listener this code will be triggered again.
            transition.removeListener(this);
            animateButtonsIn();
        }

        @Override
        public void onTransitionCancel(Transition transition) {
        }

        @Override
        public void onTransitionPause(Transition transition) {
        }

        @Override
        public void onTransitionResume(Transition transition) {
        }
    });
}