Search in sources :

Example 1 with TransitionListenerAdapter

use of com.google.samples.apps.topeka.widget.TransitionListenerAdapter in project android-topeka by googlesamples.

the class SignInFragment method performSignInWithTransition.

private void performSignInWithTransition(View v) {
    final Activity activity = getActivity();
    if (v == null || ApiLevelHelper.isLowerThan(Build.VERSION_CODES.LOLLIPOP)) {
        // Don't run a transition if the passed view is null
        CategorySelectionActivity.start(activity, mPlayer);
        activity.finish();
        return;
    }
    if (ApiLevelHelper.isAtLeast(Build.VERSION_CODES.LOLLIPOP)) {
        activity.getWindow().getSharedElementExitTransition().addListener(new TransitionListenerAdapter() {

            @Override
            public void onTransitionEnd(Transition transition) {
                activity.finish();
            }
        });
        final Pair[] pairs = TransitionHelper.createSafeTransitionParticipants(activity, true, new Pair<>(v, activity.getString(R.string.transition_avatar)));
        @SuppressWarnings("unchecked") ActivityOptionsCompat activityOptions = ActivityOptionsCompat.makeSceneTransitionAnimation(activity, pairs);
        CategorySelectionActivity.start(activity, mPlayer, activityOptions);
    }
}
Also used : Transition(android.transition.Transition) CategorySelectionActivity(com.google.samples.apps.topeka.activity.CategorySelectionActivity) Activity(android.app.Activity) TransitionListenerAdapter(com.google.samples.apps.topeka.widget.TransitionListenerAdapter) ActivityOptionsCompat(android.support.v4.app.ActivityOptionsCompat) Pair(android.support.v4.util.Pair)

Aggregations

Activity (android.app.Activity)1 ActivityOptionsCompat (android.support.v4.app.ActivityOptionsCompat)1 Pair (android.support.v4.util.Pair)1 Transition (android.transition.Transition)1 CategorySelectionActivity (com.google.samples.apps.topeka.activity.CategorySelectionActivity)1 TransitionListenerAdapter (com.google.samples.apps.topeka.widget.TransitionListenerAdapter)1