FragmentRigger
💥A powerful library to manage Fragments. 一个强大的Fragment管理框架。(中文版入口)
This might is the library that at the least cost of use to manage fragments.
No need to extend any class!!! No need to extend any class!!! No need to extend any class!!! the most important thing must be said for three times!!!
You can use this FragmentRigger
with one line annotation.
Principle: define the pointcuts for Fragment/Activity lifecycle methods and bind to the proxy class to execute.
Demo
This library support usual fragment using scenes,if you found the scene that this library does not supported,you can post Issues or Email me
Stack manager | Show | Lazy loading | Replace |
---|---|---|---|
Goal
- Make Fragment use easier.
- At the least cost of use to manage fragments.
Wiki
Getting Started
- Installation
- Using start
- Fragments usage
- Custom fragment tag
- Lazy loading
- Transition animations
- Intercept onBackPressed
- startFragmentForResult
- Swipe edge to exit Activity/Fragment
- How to use in library module
Information
Feature
- Powerful api
- Enough English notes
- Strictest exceptions
- Resolve usual exceptions and bugs in fragments
- Never lost any fragment transaction commit
- Extend the android native fragment methods,add some usual methods such as
onBackPressed()
- Print tree for the fragment stack
- Fragment lazy load
- Fragment transition animations
- Option to configure fragment tag
- Add
onBackPressed
method support for the fragment that is not added into stack - Swipe edge to exit Fragment/Activity
- Option to configure fragment launch mode
- Fragment shared elements transition animations
- Support DialogFragment
Problem solved
Fragment view overlappingFragment Multi-level showingFragment stack managerFragment transaction commit failedCommit the transaction when the host activity is not resumedMultiple commits are interconnected but the fragment transaction commit does not happen immediatelyA series of exceptions when memory restartingData saved and restored when the screen is flippedCan not perform this action after onSaveInstanceStateLazy loading in ViewPager and other scenariosThe animation does not perform in different scenarios
Usage example
This library provides powerful api.
1、Add support for your classes
Add
@Puppet
annotation for yourActivity/Fragment
that need to use this library.
//MainActivity.java
@Puppet(containerViewId = R.id.atyContent)//containerViewId is the fragment to be placed in.
public class MainActivity extends AppCompatActivity
//TestFragment.java
@Puppet
public class TestFragment extends Fragment
2、Fragment usage
After add
@Puppet
annotation, use the proxy classRigger
to manage fragments.
@Puppet(containerViewId = R.id.atyContent)
public class MainActivity extends AppCompatActivity{
...
//add and show a fragment and add it to the stack,this fragment is placed in the container view.
Rigger.getRigger(this).startFragment(TestFragment.newInstance());
}
3、Activity/Fragment swipe back to exit
Add
Swiper
annotation for yourActivity/Fragment
.
@Swiper
@Puppet
public class MainActivity extends AppCompatActivity{
// swiper can only used with puppet.
}
@Swiper
@Puppet
public class TestFragment extends Fragment{
// swiper can only used with puppet.
}
License
This library is available under the MIT license. See the LICENSE file for more info.