I'm recently new to Android development and the idea of fragments in general. In ios
I was able to create a drawer menu
experience using SWRevealController, which leaves each page as it's own viewcontroller
- roughly equivalent to an activity
. These separate viewcontrollers
were very clear on where to load data and were pretty self managing in their lifecycle.
Now in android a drawer activity
has each page of the menu as a fragment
- all belonging to the same activity
. This leaves me with a few options:
- Have a mega-activity that knows how to load all the data for every possible page. This is potentially the easiest to do but the hardest to maintain.
- Have each fragment know how to load/display their own data. This seems ideal but has problems with reloading/duplicating data if done in onViewCreated. Additionally it makes the initial load of the drawer activity very slow, even when data loading is done in an async manner.
- What would be an easy to maintain approach for many drawer views that each need to make their own API call?