-
Notifications
You must be signed in to change notification settings - Fork 8
Design & Structure
kyleduo edited this page Mar 12, 2018
·
1 revision
When I think about the navigation process I found that we need 4 phase to complete it.
- Phase 1: Creating. Create a navigation action to represent a single process and initial it using a from object which is the origin.
- Phase 2: Parsing. Parse the url and find the target of navigation, witch represented as TargetInfo.
- Phase 3: Assembling. Assemble params and flags to create one real navigation target like Intent or Fragment instance.
- Phase 4: Navigating. This is where startActivity in invoked.
The structure of Rabbits was design like a pipeline, each phase works like a node on the pipeline.
There are some important concept and Classes.
- Action represents a navigation action and contains all the params and intermedia. Every phase process the Action object.
- Interceptor is a very important concept since every phase and every processing node is an Interceptor. Interceptors that you created during initialization is also a sub-class of Interceptor.
- Navigator is which really invoke the startActivity method. Every type (Activity, Fragment, FragmentV4) of target has one paired Navigator instance. To support Fragment navigation, you need create a navigator class and register it to Rabbits.