Generate MVVM-UseCase-Api-DI feature packages with 1 click

Overview

Android MVVM Generator

mvvm

Pre-requisites

  • Project assumes that you use Hilt, Retrofit, Kotlin, Flows, Jetpack ViewModel and MVVM with UseCase layer.

  • Import file_templates.zip as intelliJ settings file. It only imports file templates, so rest of your settings remain intact. (How to)

  • Copy some base files in your desired directory, which include:

    • NetworkProvider sets up retrofit instance, you can replace with your own
    • BaseUseCase interface enforces SRP by providing 1 method that works on 1 input and 1 output.
    • BaseService has api call boilerplate, including default error messages mapped to http codes
    • Resource sealed class to map network response to Data for success else Error
    • StringResourceProvider is wrapper around strings.xml resource that is declared in its module
    • dependencies.gradle file has all the dependencies needed, this is then imported in build.gradle (app)
    • Setup some dependencies project wide using build.gradle (project) and module wide build.gradle (app)

    You can always replace/edit these as per your requirements.

Usage

  • Create a package for feature in your desired package e.g. login
  • Right click on target feature package, goto New then click New Feature, enter name when prompt appears
  • Name in New Feature is case sensitive, e.g. Login, generated classes will be case sensitive with capital L- LoginApi, LoginUseCase etc.
  • You will get all the classes generated!

Few more steps:

  • Since base classes are completely subjective to their creation and placement, you will have to add some import statements.
  • Goto generated ViewModel, UseCase and ApiService classes and add imports for base/common classes. (takes <10 seconds).
  • Voila ! You have a feature skeleton ready to work on.

Generated Classes

<> replaces your generated feature name

  • <>Api - Retrofit API end point class
  • <>Service - Network call logic, uses <>Api
  • <>UseCase - Use case to contain pure logic for data transformation/manipulation
  • <>ViewModel - ViewModel with basic structure having reference to use case and some livedata declared
  • <>Fragment - Empty Fragment
  • <>Request - Model for UseCase input, there is room for better naming convention here.
  • <>State - Model for UseCase output, again, there is room for better naming convention here.
  • <>RequestDto - Model for request data in API call. This is json annotated to be used with Moshi.
  • <>Response - Model for response object, this is json annotated to be used with Moshi.
  • <>Bindings - DI bindings for Service and UseCase classes/interfaces
  • <>Module - DI module method to create <>Api instance using retrofit instance discussed in Pre-requisites.

Extensibility

While this is pretty specific, it very easy to edit or update templates

  • Goto Preferences in you IntelliJ (dependending on the OS, options may change), select File and Code Templates and scroll down in Files section. template
  • You will see there custom templates as mentioned in the image.
  • You can add, edit, remove or even create an entirely new set of templates from this.
  • This uses Apache Velocity langauage which is also mentioned in this prompt as VTL.
  • This is fairly simple, declarative, yet very powerful templating language. You can almost achieve everything that a code generator can using this templating engine.

Disclaimer

  • This does not in any way, ask you to implement or design apps/solutions with a preference. This might be 1 out of many ways to do things.
  • Do not expect this project to work 100% perfectly 100% of the time.
  • This is licensed with Apache 2.0
You might also like...
Reapp is everything you need to build amazing apps with React: a collection of packages that work together, our UI kit, and a CLI that scaffolds your app and includes a server and build system.
Reapp is everything you need to build amazing apps with React: a collection of packages that work together, our UI kit, and a CLI that scaffolds your app and includes a server and build system.

What is it? Reapp is everything you need to build amazing apps with React: a collection of packages that work together, our UI kit, and a CLI that sca

GraphQL Jetpack - A collection of packages for easily writing Java GraphQL server implementations

GraphQL Jetpack A collection of packages for easily writing Java GraphQL server

Turtle Graphics 🐢 implementation for Android Platform with Code Editor, Preview Screen and packages
Turtle Graphics 🐢 implementation for Android Platform with Code Editor, Preview Screen and packages

Turtle Graphics Download Turtle is an Android Application inspired from the original Turtle Graphics and Logo, Logo is an educational programming lang

View that imitates Ripple Effect on click which was introduced in Android L  (for Android 2.3+)
View that imitates Ripple Effect on click which was introduced in Android L (for Android 2.3+)

RippleView View that imitates Ripple Effect on click which was introduced in Android L. Usage For a working implementation, Have a look at the Sample

Android Library to provide swipe, click and other functionality to RecyclerView

RecyclerViewEnhanced Android Library to provide swipe, click and other functionality to RecyclerView Usage Add this to your build.gradle file dependen

This is a library designed for highlighting hashtags (
This is a library designed for highlighting hashtags ("#example") and catching click on them.

HashTagHelper This is a library designed for highlighting hashtags ("#example") and catching click on them. #Usage Add this snippet to your project bu

Android Library to provide swipe, click and other functionality to RecyclerView

RecyclerViewEnhanced Android Library to provide swipe, click and other functionality to RecyclerView Usage Add this to your build.gradle file dependen

learn to click in a good rhythm
learn to click in a good rhythm

pvp instruktarz Build plugin jar ./gradlew jar Running To run this plugin you must include Kotlin 1.4.32+ to the server classpath somehow. Example two

Explode compose elements on click! Just add explodeOnClick() modifier!
Explode compose elements on click! Just add explodeOnClick() modifier!

compose-explode Explode compose elements on click! Just add explodeOnClick() modifier! Inspired from ExplosionField Getting started Go to library/expl

NTabLayout is a simple tab bar custom view under android which has click-sliding and scaling up animation effect.
NTabLayout is a simple tab bar custom view under android which has click-sliding and scaling up animation effect.

NTabLayout Brief NTabLayout is a simple tab bar custom view under android which has click-sliding and scaling up animation effect. This tab bar's effe

ClickMachine Fabric - Click Machine for minecraft
ClickMachine Fabric - Click Machine for minecraft

Minecraft mod for Fabric Adds one block to the game: Auto Clicker. This autoclic

A random meme generator and can be shared , each click will show yo a different meme.
A random meme generator and can be shared , each click will show yo a different meme.

AlphaMemes(random meme sharing app) A android app which display new meme on each click. used API which is dynamic/ Glide library used / Recycler view

 PopupBarChart 📊 can shows a tooltip when user click on the bar 😍 🤩
PopupBarChart 📊 can shows a tooltip when user click on the bar 😍 🤩

PopupBarChart 📊 can shows a tooltip when user click on the bar 😍 🤩

Android playground project with modularization by feature (android libraries), unit tests, MVVM & MVI.
Android playground project with modularization by feature (android libraries), unit tests, MVVM & MVI.

Movies Movies is a simple project to study and play with some android components, architecture and tools for Android development. Tech Stack This proj

A lightweight, feature-rich wrapper for the Telegram Bot API, providing a handy Kotlin DSL to quickly build your bot.

Kotlin Telegram Bot Kotlin based wrapper over Telegram API. Current version of the Telegram Api: 6.0 Principles Annotations Magic. The basic interacti

Gender Checker app built using Kotlin, MVVM, Genderize.io API. Take this as a reference for MVVM and Genderize.io API 🚀
Gender Checker app built using Kotlin, MVVM, Genderize.io API. Take this as a reference for MVVM and Genderize.io API 🚀

Gender-Checker 👀 Gender Checker app built using Kotlin, MVVM, Genderize.io API Enter a name and the app will guess the gender 🤩 ✨ Highligts: API : G

An implementation of tap targets from the Material Design guidelines for feature discovery.
An implementation of tap targets from the Material Design guidelines for feature discovery.

TapTargetView An implementation of tap targets from Google's Material Design guidelines on feature discovery. Min SDK: 14 JavaDoc Installation TapTar

Twidere-Android Twidere is a powerful twitter client for Android 1.6+ 1 , which gives you a full Holo experience and nearly full Twitter's feature.
Twidere-Android Twidere is a powerful twitter client for Android 1.6+ 1 , which gives you a full Holo experience and nearly full Twitter's feature.

Twidere for Android Material Design ready and feature rich Twitter/Mastodon/Fanfou app for Android 4.1+. Enjoy Fediverse now! Twidere-Android is maint

An implementation of tap targets from the Material Design guidelines for feature discovery.
An implementation of tap targets from the Material Design guidelines for feature discovery.

TapTargetView An implementation of tap targets from Google's Material Design guidelines on feature discovery. Min SDK: 14 JavaDoc Installation TapTar

Owner
Talha Hasan Zia
Programming. Football. Proud Muslim.
Talha Hasan Zia
A tool to generate Android ContentProviders.

Android ContentProvider Generator (acpg) A tool to generate Android ContentProviders. It takes a set of entity (a.k.a "table") definitions as the inpu

Benoit Lubek 623 Dec 13, 2022
A small tool to help you generate android projects that have a base code.

Volt Project A small tool to help you generate android projects that have a base code. Usage Change project in base directory. python volt-gen.py <pac

Victor Varenik 3 Feb 2, 2022
generate TestCase

generate TestCase with Kotlin Usage 1. add maven Repository to build.gradle.kts repositories { maven { url = uri("https://maven.pkg.github

kamedon 1 Jan 5, 2022
A Java API for generating .java source files.

JavaPoet JavaPoet is a Java API for generating .java source files. Source file generation can be useful when doing things such as annotation processin

Square 10k Jan 2, 2023
Awesome Kid's Drawing App. It has a click and draws feature.

CanvaKids Overview It's a kid's drawing app which is build for android users. It is built in Kotlin with some very good practices involved.

null 9 Oct 30, 2021
Tons of extensively featured packages for Angular, VUE and React Projects

rxweb Clean Code. Built with Purpose Contributing to rxweb framework If you are thinking to make rxweb framework better, that's truly great. You can c

null 376 Jan 4, 2023
Adding support for Factory boy and django packages

This plugin provides some support for Factory Boy Features autocomplete for instances created by factories references to members of instance class Not

Nazareka 3 Dec 19, 2021
Kotlin jvm + android packages for bdk-ffi

bdk-kotlin This project builds .jar and .aar packages for the jvm and android platforms that provide Kotlin language bindings for the bdk library. The

Bitcoin Dev Kit 14 Nov 15, 2022