We've introduced you into Moxy - mvp framework for spliting application into logic layers and lifecycle managing. Now it's time to to reduce boilerplate via Android Studio Templates
Firstly we should immobilize project structure Project structure
Presenter, view, activity and fragment packages consist of logic modules. These models are often the application's sections (f.e. intro, offers, feed) Check example with two Activity (CarActivity and HomeActivity) and one fragment (CarDetailsFragment) belowarDetailsFragment)
Our goal is generate this class set using Android Studio Templates
Adding Moxy templates to Android Studio:
- Download templates for Java from Github or directly using link
- Or download templates for Kotlin from Github
- Copy files to ANDROID_STUDIO_DIR/plugins/android/lib/templates/activities
- Restart Android Studio
Managing hot keys for templates quick access:
- Open settings-> Keymap
- Enter "Moxy" to search box
- Add key combination (A prefer Alt + A for Moxy Activity and Alt + F for Moxy Fragment)
- Click your ROOT package and then press Alt + A.
- In Activity Name box enter "MyFirstMoxyActivity"
Other fields will fill automaticly
Finaly print in the Package Name field yoor subpackage name (f.e. first) and press Finish.
Attention while your Android Studio upgrading all the custom templates can be delayed. In this case it is necessary to import them again