fragment/src/main/java/androidx/fragment/app/FragmentManager.java
void moveToState(int newState, boolean always) {
        if (mHost == null && newState != Fragment.INITIALIZING) {
            throw new IllegalStateException("No activity");
        }

        if (!always && newState == mCurState) {
            return;
        }

        mCurState = newState;

        if (mActive != null) {

            // Must add them in the proper order. mActive fragments may be out of order
            final int numAdded = mAdded.size();
            for (int i = 0; i < numAdded; i++) {
                Fragment f = mAdded.get(i);
                moveFragmentToExpectedState(f);
            }

            // Now iterate through all active fragments. These will include those that are removed
            // and detached.
            final int numActive = mActive.size();
            for (int i = 0; i < numActive; i++) {
                Fragment f = mActive.valueAt(i);
                if (f != null && (f.mRemoving || f.mDetached) && !f.mIsNewlyAdded) {
                    moveFragmentToExpectedState(f);
                }
            }

            startPendingDeferredFragments();

            if (mNeedMenuInvalidate && mHost != null && mCurState == Fragment.RESUMED) {
                mHost.onSupportInvalidateOptionsMenu();
                mNeedMenuInvalidate = false;
            }
        }
    }
/**
     * Changes the state of the fragment manager to {@code newState}. If the fragment manager
     * changes state or {@code always} is {@code true}, any fragments within it have their
     * states updated as well.
     *
     * @param newState The new state for the fragment manager
     * @param always If {@code true}, all fragments update their state, even
     *               if {@code newState} matches the current fragment manager's state.
     */
Changes the state of the fragment manager to  newState. If the fragment manager
changes state or  always is  true, any fragments within it have their
states updated as well.

@param newState The new state for the fragment manager
@param always If  true, all fragments update their state, even
if  newState matches the current fragment manager's state.
Changes the state of the fragment manager to newState . If the fragment manager changes state or always is true any fragments within it have their states updated as well . @param newState The new state for the fragment manager @param always If true all fragments update their state even if newState matches the current fragment manager ' s state .
void moveToState(int newState, boolean always) {
        if (mHost == null && newState != Fragment.INITIALIZING) {
            throw new IllegalStateException("No activity");
        }
        if (!always && newState == mCurState) {
            return;
        }
        mCurState = newState;
        if (mActive != null) {
            final int numAdded = mAdded.size();
            for (int i = 0; i < numAdded; i++) {
                Fragment f = mAdded.get(i);
                moveFragmentToExpectedState(f);
            }
            final int numActive = mActive.size();
            for (int i = 0; i < numActive; i++) {
                Fragment f = mActive.valueAt(i);
                if (f != null && (f.mRemoving || f.mDetached) && !f.mIsNewlyAdded) {
                    moveFragmentToExpectedState(f);
                }
            }
            startPendingDeferredFragments();
            if (mNeedMenuInvalidate && mHost != null && mCurState == Fragment.RESUMED) {
                mHost.onSupportInvalidateOptionsMenu();
                mNeedMenuInvalidate = false;
            }
        }
    }
void moveToState ( int newState , boolean always ) { if ( mHost == null && newState != Fragment . INITIALIZING ) { throw new IllegalStateException ( "No activity" ) ; } if ( ! always && newState == mCurState ) { return ; } mCurState = newState ; if ( mActive != null ) { final int numAdded = mAdded . size ( ) ; for ( int i = 0 ; i < numAdded ; i ++ ) { Fragment f = mAdded . get ( i ) ; moveFragmentToExpectedState ( f ) ; } final int numActive = mActive . size ( ) ; for ( int i = 0 ; i < numActive ; i ++ ) { Fragment f = mActive . valueAt ( i ) ; if ( f != null && ( f . mRemoving || f . mDetached ) && ! f . mIsNewlyAdded ) { moveFragmentToExpectedState ( f ) ; } } startPendingDeferredFragments ( ) ; if ( mNeedMenuInvalidate && mHost != null && mCurState == Fragment . RESUMED ) { mHost . onSupportInvalidateOptionsMenu ( ) ; mNeedMenuInvalidate = false ; } } }
Changes the state of the fragment manager to {@code newState}.
Changes the state of the fragment manager to { @code newState } .
// Must add them in the proper order. mActive fragments may be out of order // Now iterate through all active fragments. These will include those that are removed // and detached.