Skip to content
Branch: master
Find file History
Type Name Latest commit message Commit time
Failed to load latest commit information.
Java Fixed templates for Android Studio 3.1 May 5, 2018
Kotlin Updated kotlin fragment template for support lib >= 27 Oct 22, 2018
images templates images Jul 23, 2016 Added Moxy templates for Kotlin Jan 12, 2017

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

Project structure

Firstly we should immobilize project structure
  • model
  • presentation
    • presenter
    • view
  • ui
    • activity
    • fragment

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)

Activity template

Our goal is generate this class set using Android Studio Templates

Template settings

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)

Activity template

Temlates using

  • Click your ROOT package and then press Alt + A.
  • In Activity Name box enter "MyFirstMoxyActivity"

Other fields will fill automaticly

Activity template

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

You can’t perform that action at this time.