app/src/main/java/com/stoneium/onepagesample/MainActivity.java
/***
     * Transition to a given view.
     *
     * @param tag            The tag that represents the fragment.
     * @param view           The view to transition to.
     * @param transitionType The type of transition to use.
     * @param state          A state object that can be passed to the view.
     */
Transition to a given view.
@param tag            The tag that represents the fragment.
@param view           The view to transition to.
@param transitionType The type of transition to use.
@param state          A state object that can be passed to the view.
Transition to a given view . @param tag The tag that represents the fragment . @param view The view to transition to . @param transitionType The type of transition to use . @param state A state object that can be passed to the view .
@Override
    public void transitionToView(String tag, Object view, TransitionType transitionType,
                                 Object state) {
        _logger.debug("MainActivity: transitionToView - %s", tag);
        if (_currentFragment == view) {
            return;
        }
        FragmentManager fragmentManager = getFragmentManager();
        FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
        if (transitionType != null) {
            setTransitionType(fragmentTransaction, transitionType);
        }
        if (_currentFragment != null) {
            fragmentTransaction.remove(_currentFragment);
        } else {
            Fragment fragment = fragmentManager.findFragmentByTag(tag);
            if (fragment != null) {
                fragmentTransaction.remove(fragment);
            }
        }
        fragmentTransaction.add(R.id.fragmentContainer, (Fragment) view, tag);
        fragmentTransaction.commit();
        _currentFragment = (Fragment) view;
        if (_currentFragment instanceof IStateView) {
            ((IStateView) _currentFragment).setState(state);
        }
    }
@ Override public void transitionToView ( String tag , Object view , TransitionType transitionType , Object state ) { _logger . debug ( "MainActivity: transitionToView - %s" , tag ) ; if ( _currentFragment == view ) { return ; } FragmentManager fragmentManager = getFragmentManager ( ) ; FragmentTransaction fragmentTransaction = fragmentManager . beginTransaction ( ) ; if ( transitionType != null ) { setTransitionType ( fragmentTransaction , transitionType ) ; } if ( _currentFragment != null ) { fragmentTransaction . remove ( _currentFragment ) ; } else { Fragment fragment = fragmentManager . findFragmentByTag ( tag ) ; if ( fragment != null ) { fragmentTransaction . remove ( fragment ) ; } } fragmentTransaction . add ( R . id . fragmentContainer , ( Fragment ) view , tag ) ; fragmentTransaction . commit ( ) ; _currentFragment = ( Fragment ) view ; if ( _currentFragment instanceof IStateView ) { ( ( IStateView ) _currentFragment ) . setState ( state ) ; } }
Transition to a given view.
Transition to a given view .
// We wont transition if the view is not active. // If the view is already set then lets do nothing. // Get the fragment manager and transaction object. // Remove the current fragment if needed. // Add the new fragment.