Transition getTransition(@TransitionRes int transitionId) { Transition transition = transitions.get(transitionId); if (transition == null) { transition = TransitionInflater.from(this).inflateTransition(transitionId); transitions.put(transitionId, transition); } return transition; }
@SuppressWarnings("unchecked") public static void transitionTo(AppCompatActivity from, Intent intent, @TransitionRes int transition, View... sharedElements) { final Pair<View, String>[] pairs = createSafeTransitionParticipants(from, true, getPairs(sharedElements)); ActivityOptionsCompat transitionActivityOptions = ActivityOptionsCompat.makeSceneTransitionAnimation(from, pairs); intent.putExtra(TRANSITION_ID, transition); from.startActivity(intent, transitionActivityOptions.toBundle()); }
@SuppressWarnings("unchecked") public static void transitionTo(Fragment from, Intent intent, @TransitionRes int transition, View... sharedElements) { final Pair<View, String>[] pairs = createSafeTransitionParticipants(from.getActivity(), true, getPairs(sharedElements)); ActivityOptionsCompat transitionActivityOptions = ActivityOptionsCompat.makeSceneTransitionAnimation(from.getActivity(), pairs); intent.putExtra(TRANSITION_ID, transition); from.startActivity(intent, transitionActivityOptions.toBundle()); }
@SuppressWarnings("unchecked") public static void transitionToForResult(AppCompatActivity from, Intent intent, int requestCode, @TransitionRes int transition, View... sharedElements) { final Pair<View, String>[] pairs = createSafeTransitionParticipants(from, true, getPairs(sharedElements)); ActivityOptionsCompat transitionActivityOptions = ActivityOptionsCompat.makeSceneTransitionAnimation(from, pairs); intent.putExtra(TRANSITION_ID, transition); from.startActivityForResult(intent, requestCode, transitionActivityOptions.toBundle()); }
@SuppressWarnings("unchecked") public static void transitionToForResult(Fragment from, Intent intent, int requestCode, @TransitionRes int transition, View... sharedElements) { final Pair<View, String>[] pairs = createSafeTransitionParticipants(from.getActivity(), true, getPairs(sharedElements)); ActivityOptionsCompat transitionActivityOptions = ActivityOptionsCompat.makeSceneTransitionAnimation(from.getActivity(), pairs); intent.putExtra(TRANSITION_ID, transition); from.startActivityForResult(intent, requestCode, transitionActivityOptions.toBundle()); }
private Transition getTransition(@TransitionRes int transitionId) { TransitionInflater inflater=TransitionInflater.from(this); return inflater.inflateTransition(transitionId); }
/** * Inflates a desired Transition from the specified <var>resource</var>. * * @param resource Resource id of the desired transition to inflate. * @return Inflated transition or {@code null} if the current API level does not support transitions * or this fragment is not attached to its parent context. * @see TransitionInflater#inflateTransition(int) */ @Nullable protected Transition inflateTransition(@TransitionRes int resource) { final Activity activity = getActivity(); return activity != null && FragmentPolicies.TRANSITIONS_SUPPORTED ? TransitionInflater.from(activity).inflateTransition(resource) : null; }
/** * Inflates a desired Transition from the specified <var>resource</var>. * * @param context Context used for inflation process. * @param resource Resource id of the desired transition to inflate. * @return Inflated transition or {@code null} if the current API level does not support transitions. * @see TransitionInflater#inflateTransition(int) * @see #inflateTransitionManager(Context, int, ViewGroup) */ @Nullable @SuppressLint("NewApi") public static Transition inflateTransition(@NonNull final Context context, @TransitionRes final int resource) { return FragmentPolicies.TRANSITIONS_SUPPORTED ? TransitionInflater.from(context).inflateTransition(resource) : null; }
/** * Inflates a desired TransitionManager from the specified <var>resource</var>. * * @param context Context used for inflation process. * @param resource Resource id of the desired transition manager to inflate. * @param sceneRoot Root of the scene for which to inflate transition manager. * @return Inflated transition manager or {@code null} if the current API level does not support * transitions. * @see TransitionInflater#inflateTransitionManager(int, ViewGroup) * @see #inflateTransition(Context, int) */ @Nullable @SuppressLint("NewApi") public static TransitionManager inflateTransitionManager(@NonNull final Context context, @TransitionRes final int resource, @NonNull final ViewGroup sceneRoot) { return FragmentPolicies.TRANSITIONS_SUPPORTED ? TransitionInflater.from(context).inflateTransitionManager(resource, sceneRoot) : null; }