fragment/src/main/java/androidx/fragment/app/FragmentTransition.java
private static Object configureSharedElementsOrdered(final FragmentTransitionImpl impl,
            final ViewGroup sceneRoot,
            final View nonExistentView, final ArrayMap<String, String> nameOverrides,
            final FragmentContainerTransition fragments,
            final ArrayList<View> sharedElementsOut,
            final ArrayList<View> sharedElementsIn,
            final Object enterTransition, final Object exitTransition) {
        final Fragment inFragment = fragments.lastIn;
        final Fragment outFragment = fragments.firstOut;

        if (inFragment == null || outFragment == null) {
            return null; // no transition
        }

        final boolean inIsPop = fragments.lastInIsPop;
        Object sharedElementTransition = nameOverrides.isEmpty() ? null
                : getSharedElementTransition(impl, inFragment, outFragment, inIsPop);

        ArrayMap<String, View> outSharedElements = captureOutSharedElements(impl, nameOverrides,
                sharedElementTransition, fragments);

        if (nameOverrides.isEmpty()) {
            sharedElementTransition = null;
        } else {
            sharedElementsOut.addAll(outSharedElements.values());
        }

        if (enterTransition == null && exitTransition == null && sharedElementTransition == null) {
            // don't call onSharedElementStart/End since there is no transition
            return null;
        }

        callSharedElementStartEnd(inFragment, outFragment, inIsPop, outSharedElements, true);

        final Rect inEpicenter;
        if (sharedElementTransition != null) {
            inEpicenter = new Rect();
            impl.setSharedElementTargets(sharedElementTransition,
                    nonExistentView, sharedElementsOut);
            final boolean outIsPop = fragments.firstOutIsPop;
            final BackStackRecord outTransaction = fragments.firstOutTransaction;
            setOutEpicenter(impl, sharedElementTransition, exitTransition, outSharedElements,
                    outIsPop, outTransaction);
            if (enterTransition != null) {
                impl.setEpicenter(enterTransition, inEpicenter);
            }
        } else {
            inEpicenter = null;
        }


        final Object finalSharedElementTransition = sharedElementTransition;
        OneShotPreDrawListener.add(sceneRoot, new Runnable() {
            @Override
            public void run() {
                ArrayMap<String, View> inSharedElements = captureInSharedElements(impl,
                        nameOverrides, finalSharedElementTransition, fragments);

                if (inSharedElements != null) {
                    sharedElementsIn.addAll(inSharedElements.values());
                    sharedElementsIn.add(nonExistentView);
                }

                callSharedElementStartEnd(inFragment, outFragment, inIsPop,
                        inSharedElements, false);
                if (finalSharedElementTransition != null) {
                    impl.swapSharedElementTargets(
                            finalSharedElementTransition, sharedElementsOut,
                            sharedElementsIn);

                    final View inEpicenterView = getInEpicenterView(inSharedElements,
                            fragments, enterTransition, inIsPop);
                    if (inEpicenterView != null) {
                        impl.getBoundsOnScreen(inEpicenterView,
                                inEpicenter);
                    }
                }
            }
        });

        return sharedElementTransition;
    }
/**
     * Configures the shared elements of an ordered fragment transaction's transition.
     * This retrieves the shared elements of the incoming fragments, and schedules capturing
     * the incoming fragment's shared elements. It also maps the views, and sets up the epicenter
     * on the transitions.
     * <p>
     * The epicenter of exit and shared element transitions is the first shared element
     * in the outgoing fragment. The epicenter of the entering transition is the first shared
     * element in the incoming fragment.
     *
     * @param sceneRoot The fragment container View
     * @param nonExistentView A View that does not exist in the hierarchy. This is used to
     *                        prevent transitions from acting on other Views when there is no
     *                        other target.
     * @param nameOverrides A map of the shared element names from the starting fragment to
     *                      the final fragment's Views as given in
     *                      {@link FragmentTransaction#addSharedElement(View, String)}.
     * @param fragments A structure holding the transitioning fragments in this container.
     * @param sharedElementsOut A list modified to contain the shared elements in the outgoing
     *                          fragment
     * @param sharedElementsIn A list modified to contain the shared elements in the incoming
     *                         fragment
     * @param enterTransition The transition used for entering Views, modified by applying the
     *                        epicenter
     * @param exitTransition The transition used for exiting Views, modified by applying the
     *                       epicenter
     * @return The shared element transition or null if no shared elements exist
     */
Configures the shared elements of an ordered fragment transaction's transition.
This retrieves the shared elements of the incoming fragments, and schedules capturing
the incoming fragment's shared elements. It also maps the views, and sets up the epicenter
on the transitions.

The epicenter of exit and shared element transitions is the first shared element
in the outgoing fragment. The epicenter of the entering transition is the first shared
element in the incoming fragment.

@param sceneRoot The fragment container View
@param nonExistentView A View that does not exist in the hierarchy. This is used to
prevent transitions from acting on other Views when there is no
other target.
@param nameOverrides A map of the shared element names from the starting fragment to
the final fragment's Views as given in
FragmentTransaction#addSharedElement(View, String).
@param fragments A structure holding the transitioning fragments in this container.
Configures the shared elements of an ordered fragment transaction ' s transition . This retrieves the shared elements of the incoming fragments and schedules capturing the incoming fragment ' s shared elements . It also maps the views and sets up the epicenter on the transitions . The epicenter of exit and shared element transitions is the first shared element in the outgoing fragment . The epicenter of the entering transition is the first shared element in the incoming fragment . @param sceneRoot The fragment container View @param nonExistentView A View that does not exist in the hierarchy . This is used to prevent transitions from acting on other Views when there is no other target . @param nameOverrides A map of the shared element names from the starting fragment to the final fragment ' s Views as given in FragmentTransaction#addSharedElement ( View String ) . @param fragments A structure holding the transitioning fragments in this container .
private static Object configureSharedElementsOrdered(final FragmentTransitionImpl impl,
            final ViewGroup sceneRoot,
            final View nonExistentView, final ArrayMap<String, String> nameOverrides,
            final FragmentContainerTransition fragments,
            final ArrayList<View> sharedElementsOut,
            final ArrayList<View> sharedElementsIn,
            final Object enterTransition, final Object exitTransition) {
        final Fragment inFragment = fragments.lastIn;
        final Fragment outFragment = fragments.firstOut;
        if (inFragment == null || outFragment == null) {
            return null; 
        }
        final boolean inIsPop = fragments.lastInIsPop;
        Object sharedElementTransition = nameOverrides.isEmpty() ? null
                : getSharedElementTransition(impl, inFragment, outFragment, inIsPop);
        ArrayMap<String, View> outSharedElements = captureOutSharedElements(impl, nameOverrides,
                sharedElementTransition, fragments);
        if (nameOverrides.isEmpty()) {
            sharedElementTransition = null;
        } else {
            sharedElementsOut.addAll(outSharedElements.values());
        }
        if (enterTransition == null && exitTransition == null && sharedElementTransition == null) {
            return null;
        }
        callSharedElementStartEnd(inFragment, outFragment, inIsPop, outSharedElements, true);
        final Rect inEpicenter;
        if (sharedElementTransition != null) {
            inEpicenter = new Rect();
            impl.setSharedElementTargets(sharedElementTransition,
                    nonExistentView, sharedElementsOut);
            final boolean outIsPop = fragments.firstOutIsPop;
            final BackStackRecord outTransaction = fragments.firstOutTransaction;
            setOutEpicenter(impl, sharedElementTransition, exitTransition, outSharedElements,
                    outIsPop, outTransaction);
            if (enterTransition != null) {
                impl.setEpicenter(enterTransition, inEpicenter);
            }
        } else {
            inEpicenter = null;
        }
        final Object finalSharedElementTransition = sharedElementTransition;
        OneShotPreDrawListener.add(sceneRoot, new Runnable() {
            @Override
            public void run() {
                ArrayMap<String, View> inSharedElements = captureInSharedElements(impl,
                        nameOverrides, finalSharedElementTransition, fragments);
                if (inSharedElements != null) {
                    sharedElementsIn.addAll(inSharedElements.values());
                    sharedElementsIn.add(nonExistentView);
                }
                callSharedElementStartEnd(inFragment, outFragment, inIsPop,
                        inSharedElements, false);
                if (finalSharedElementTransition != null) {
                    impl.swapSharedElementTargets(
                            finalSharedElementTransition, sharedElementsOut,
                            sharedElementsIn);
                    final View inEpicenterView = getInEpicenterView(inSharedElements,
                            fragments, enterTransition, inIsPop);
                    if (inEpicenterView != null) {
                        impl.getBoundsOnScreen(inEpicenterView,
                                inEpicenter);
                    }
                }
            }
        });
        return sharedElementTransition;
    }
private static Object configureSharedElementsOrdered ( final FragmentTransitionImpl impl , final ViewGroup sceneRoot , final View nonExistentView , final ArrayMap < String , String > nameOverrides , final FragmentContainerTransition fragments , final ArrayList < View > sharedElementsOut , final ArrayList < View > sharedElementsIn , final Object enterTransition , final Object exitTransition ) { final Fragment inFragment = fragments . lastIn ; final Fragment outFragment = fragments . firstOut ; if ( inFragment == null || outFragment == null ) { return null ; } final boolean inIsPop = fragments . lastInIsPop ; Object sharedElementTransition = nameOverrides . isEmpty ( ) ? null : getSharedElementTransition ( impl , inFragment , outFragment , inIsPop ) ; ArrayMap < String , View > outSharedElements = captureOutSharedElements ( impl , nameOverrides , sharedElementTransition , fragments ) ; if ( nameOverrides . isEmpty ( ) ) { sharedElementTransition = null ; } else { sharedElementsOut . addAll ( outSharedElements . values ( ) ) ; } if ( enterTransition == null && exitTransition == null && sharedElementTransition == null ) { return null ; } callSharedElementStartEnd ( inFragment , outFragment , inIsPop , outSharedElements , true ) ; final Rect inEpicenter ; if ( sharedElementTransition != null ) { inEpicenter = new Rect ( ) ; impl . setSharedElementTargets ( sharedElementTransition , nonExistentView , sharedElementsOut ) ; final boolean outIsPop = fragments . firstOutIsPop ; final BackStackRecord outTransaction = fragments . firstOutTransaction ; setOutEpicenter ( impl , sharedElementTransition , exitTransition , outSharedElements , outIsPop , outTransaction ) ; if ( enterTransition != null ) { impl . setEpicenter ( enterTransition , inEpicenter ) ; } } else { inEpicenter = null ; } final Object finalSharedElementTransition = sharedElementTransition ; OneShotPreDrawListener . add ( sceneRoot , new Runnable ( ) { @ Override public void run ( ) { ArrayMap < String , View > inSharedElements = captureInSharedElements ( impl , nameOverrides , finalSharedElementTransition , fragments ) ; if ( inSharedElements != null ) { sharedElementsIn . addAll ( inSharedElements . values ( ) ) ; sharedElementsIn . add ( nonExistentView ) ; } callSharedElementStartEnd ( inFragment , outFragment , inIsPop , inSharedElements , false ) ; if ( finalSharedElementTransition != null ) { impl . swapSharedElementTargets ( finalSharedElementTransition , sharedElementsOut , sharedElementsIn ) ; final View inEpicenterView = getInEpicenterView ( inSharedElements , fragments , enterTransition , inIsPop ) ; if ( inEpicenterView != null ) { impl . getBoundsOnScreen ( inEpicenterView , inEpicenter ) ; } } } } ) ; return sharedElementTransition ; }
Configures the shared elements of an ordered fragment transaction's transition.
Configures the shared elements of an ordered fragment transaction ' s transition .
// no transition // don't call onSharedElementStart/End since there is no transition