/ File Manager

A powerful library that manage Fragment for Android

A powerful library that manage Fragment for Android

FragmentationX

Fragmentation is a powerful library managing Fragment for Android.

It is designed for "Single Activity + Multi-Fragments" and "Multi-FragmentActivities + Multi-Fragments" architecture to simplify development process.

The first demo shows the basic usage of the library. The second one shows the way to implement an app which is similar to Instagram. Complicated nested fragments' usage demo are also showed.

demo1--1-

demo2--1-

demo3

Feature

1. Develop complicated nested fragment app rapidly

2. Use fragment's stack view dialog to debug easily

3. Add launch mode, startForResult etc. to provide similar behavior of Activity

4. Add onBackPressedSupport() method to support back button press monitoring in Fragment

5. Add onSupportVisible(), onLazyInitView() to simplify dev

6. Easily manage Fragment transition animations

7. To simplify the communication between Fragment(EventBusActivityScope module)

8. Support SwipeBack to pop(Fragmentation_SwipeBack module README)

stack

log

SwipeBack

How do I use Fragmentation?

Note: This is the use of androidx, if you are using the android.support, click here branch:master

1、build.gradle

// This is the use of androidx, if you are using the android.support: fragmentationx -> fragmentation
implementation 'me.xuexuan:fragmentationx:1.0.5'

// If you don't want to extends SupportActivity/Fragment and would like to customize your own support, just rely on fragmentation-core
// implementation 'me.xuexuan:fragmentationx-core:1.0.5'

// To get SwipeBack feature, rely on both fragmentation & fragmentation-swipeback
implementation 'me.xuexuan:fragmentationx:1.0.5'
// Swipeback is based on fragmentation. Refer to SwipeBackActivity/Fragment for your Customized SupportActivity/Fragment
implementation 'me.xuexuan:fragmentationx-swipeback:1.0.5'

// To simplify the communication between Fragments.
implementation 'me.yokeyword:eventbus-activity-scope:1.1.0'
// Your EventBus's version
implementation 'org.greenrobot:eventbus:{version}'

2. Activity extends SupportActivity or implements ISupportActivity:(refer to MySupportActivity)

// since v1.0.0, forced extends of SupportActivity is not required, you can use interface + delegate to implement your own SupportActivity 
public class MainActivity extends SupportActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(...);
      	// Fragmentation is recommended to initialize in the Application
        Fragmentation.builder()
          	 // show stack view. Mode: BUBBLE, SHAKE, NONE
             .stackViewMode(Fragmentation.BUBBLE)
             .debug(BuildConfig.DEBUG)
             ...
             .install();

        if (findFragment(HomeFragment.class) == null) {
            loadRootFragment(R.id.fl_container, HomeFragment.newInstance());  //load root Fragment
        }
    }

3. Fragment extends SupportFragment or implements ISupportFragment:(refer to MySupportFragment):

// since v1.0.0, forced extends of SupportActivity is not required, you can use interface + delegate to implement your own SupportActivity
public class HomeFragment extends SupportFragment {

    private void xxx() {
      	// launch a new Fragment, other methods: start(fragment,SINGTASK)、startForResult、startWithPop etc.
        start(DetailFragment.newInstance(HomeBean));
      	// check wiki for other pop, find and animation setting related API
    }
}

GitHub

Comments