An Activity containing a NavigationDrawer must juggle it with fragments. My problem is that the box should be accessible on all possible screens of the application, which makes my only MainActivity activity very cluttered with fragment-callback code and various types of navigation / business logic.
As the application grows, it becomes more difficult to navigate this activity, and I began to think about possible alternative approaches. The new approach should maintain the same visual behavior of the original and eliminate clutter.
In addition to the navigation box events, there are several fragments that also contain navigation / business logic, which must also be processed by MainActivity. For example, a fragment may contain 3 or more buttons that will launch other fragments or execute some business logic with cross-concern.
So, the resulting number of listener interfaces implemented by MainActivity is growing and currently stands at 20. Perhaps you think this does not look and does not seem good.
I think I could divide things into several NavigationDrawer actions to facilitate maintenance. This implies an increase in resource consumption and a slight deviation of visual effects, since new actions will only be launched after the box is closed, contrary to the initial approach, which instantly changes fragments.
Do you think this is a bad idea? How can this be improved? Or is there a better solution?
Thanks.
UPD clarified the description.
android android-activity android-fragments navigation-drawer android-navigation
midnight
source share