A more lightweight and simpler to use MVVM architecture for Android.

Last update: May 26, 2022

MMP_Architecture

More Modern Presenter.

A more lightweight and simpler to use MVVM architecture for Android, Data and views are two-way bound.

Only 300 lines of code.

Currently implemented using reflection, it can be optimized to automatically generate code using Gradle Plugin.

Example

Presenter

package cn.flutterfirst.mmp_architecture.main

import android.view.View
import cn.flutterfirst.mmp_architecture.State
import cn.flutterfirst.mmp_architecture.ViewClick
import cn.flutterfirst.mmp_architecture.mmp.BaseMMPActivity

abstract class MainPresenter : BaseMMPActivity() {

    @State
    protected var editValue: String? = null
        get() {
            if (field == null || field!!.isEmpty()) {
                return ""
            }
            return field
        }

    @State
    protected var count = 0
    private val countMax = 5
    private val countMin = 0

    @State
    protected var hintVisibility: Int? = null
        get() {
            if (count == countMax || count == countMin) {
                return View.VISIBLE
            }
            return View.GONE
        }

    @State
    protected var hintText: String? = null
        get() {
            return if (count == countMax) {
                "Can't add any more"
            } else {
                "Can't sub any more"
            }
        }

    @State
    protected var addEnable: Boolean? = null
        get() {
            return count != countMax
        }

    @State
    protected var subEnable: Boolean? = null
        get() {
            return count != countMin
        }

    @ViewClick
    protected fun add() {
        if (count == countMax) {
            return
        }
        setState {
            count++
        }
    }

    @ViewClick
    protected fun sub() {
        if (count == countMin) {
            return
        }
        setState {
            count--
        }
    }
}

View

package cn.flutterfirst.mmp_architecture.main

import cn.flutterfirst.mmp_architecture.ContentView
import cn.flutterfirst.mmp_architecture.R
import cn.flutterfirst.mmp_architecture.StateChanged

@ContentView(R.layout.activity_main)
class MainActivity : MainPresenter() {

    override fun initViewsBeforeFirstSetState() {
    }

    @StateChanged("count")
    fun countChanged() {
        println("count changed, new value = $count")
    }

    @StateChanged("editValue")
    fun editValueChanged() {
        println("editValue changed, new value = $editValue")
    }
}

Layout

example.gif

MIT License

Copyright (c) 2022 hackware1993

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

GitHub

https://github.com/hackware1993/MMP_Architecture
You might also like...

A small demo application based on modern Android application technology stacks and MVVM architecture

A small demo application based on modern Android application technology stacks and MVVM architecture

Pokedex Pokedex es una pequeña aplicación de demostración basada en modernas pil

Dec 17, 2021

Architecture Study with MVVM and MVI

Android-Architecture-Sample Android Architecture Study with MVVM and MVI Using DI(Hilt) + Retrofit + Coroutine + Moshi + AAC Stack 100% Kotlin + Corou

Jan 6, 2022

Movie app that receives popular movies and allows the user to search for the specific movie through the Rest API with help of retrofit library &MVVM architecture.

 Movie app that receives popular movies and allows the user to search for the specific movie through the Rest API with help of retrofit library &MVVM architecture.

MovieClue Millions of movies, TV shows and people to discover. Explore now Movie app that recieves popular movies and allow the user to search for spe

Mar 31, 2022

This repository contains a detailed sample app that implements MVVM architecture using Hilt, Coroutines, Retrofit and Compose

Saber News App sample project to explain how to build solid, clean architected App using MVVM and repository architecture Techniques Kotlin Clean arch

Dec 26, 2021

Retrieve Data from an API using MVVM Clean Architecture and Jetpack Compose

Retrieve Data from an API using MVVM Clean Architecture and Jetpack Compose

MVVM Clean Architecture Demo Retrieve Data from an API using MVVM Clean Architecture and Jetpack Compose. It simply shows a list of movies fetched fro

May 26, 2022

🧬 Android DataBinding kit for notifying data changes from Model layers to UI layers on MVVM architecture.

🧬 Android DataBinding kit for notifying data changes from Model layers to UI layers on MVVM architecture.

🧬 Android DataBinding kit for notifying data changes from Model layers to UI layers on MVVM architecture.

Jun 24, 2022

A simple Android Application with MVVM Architecture, Coroutine, Retrofit2

Retrofit with Coroutines and MVVM Architecture. A simple Android Application with MVVM Architecture Developed Using LiveData. MVVM Architecture. Retro

Oct 12, 2021

Currency converter Android application using MVVM architecture

Currency converter Android application using MVVM architecture

Currency Converter Currency conversion using live exchange rates. Demo Screenshots API service

Oct 31, 2021

Keep My Notes App Android MVVM architecture

Keep  My Notes App Android MVVM architecture

Keep My Notes My Notes. lien PlayStore Screenshots Architecture This app implements the MVVM architectural . Built with ViewModel - A class designed t

Nov 4, 2021
📊 A Minimal Expense Tracker App built to demonstrate the use of modern android architecture component with MVVM Architecture
📊 A Minimal Expense Tracker App built to demonstrate the use of modern android architecture component with MVVM Architecture

Expenso ?? A Simple Expense Tracker App ?? built to demonstrate the use of modern android architecture component with MVVM Architecture ?? . Made with

Jun 9, 2022
MVVM Redux is a lightweight lib to help you apply the redux concepts in your project based in MVVM.

MVVM Redux is a lightweight lib to help you apply the redux concepts in your project based in MVVM.

Apr 8, 2022
Android Clean Architecture💎 Base Project Android with Kotlin and MVVM applying clean architecture
 Android Clean Architecture💎 Base Project Android with Kotlin and MVVM applying clean architecture

Android Clean Architecture?? Base Project Android with Kotlin and MVVM applying clean architecture

Jun 23, 2022
MVVM RECIPE ANDROID APP Is an app where I show how to use MVVM, retrofit, dagger hilt, coroutine, liveData, Kotlin, navigation component, and so on...
MVVM RECIPE ANDROID APP Is an app where I show how to use MVVM, retrofit, dagger hilt, coroutine, liveData, Kotlin, navigation component, and so on...

MVVM RECIPE ANDROID APP Is an app where I show how to use MVVM, retrofit, dagger hilt, coroutine, liveData, kotlin, navigation component, and so on...

Jun 22, 2022
Chat App MVVM + Clean ArchitectureChat App MVVM + Clean Architecture
Chat App MVVM + Clean ArchitectureChat App MVVM + Clean Architecture

Chat App MVVM + Clean Architecture This Android application built using MVVM + Clean Architecture architecture approach and is written 100% in Kotlin.

Jun 10, 2022
Clean Architecture - Kotlin, MVVM, Use cases
Clean Architecture - Kotlin, MVVM, Use cases

CleanArchitecture Is Clean Architecture only MVVM ? NO, MVVM is a part of clean architecture. MVVM includes Model, View and ViewModel and in addition

Jun 20, 2022
📝 A demo todo/notes app which demonstrates the use of MVVM architecture, Navigation Component Library, Room Database, LiveData, Coroutines
📝 A demo todo/notes app which demonstrates the use of MVVM architecture, Navigation Component Library, Room Database, LiveData, Coroutines

?? MyNotes A demo notes/todo app which demonstrates the use of MVVM architecture, Navigation Component Library, Room Database, LiveData, Coroutines et

Jun 23, 2022
An Android Template with MVVM and Clean Architecture
An Android Template with MVVM and Clean Architecture

MVVMTemplate ??‍ A simple Android template that lets you create an Android project quickly. How to use ?? Just click on button to create a new repo st

Jun 17, 2022
GraphQLTrial is a demo application based on modern Android application tech-stacks and MVVM architecture.

GraphQLTrial is a demo application based on modern Android application tech-stacks and MVVM architecture. App fetching data from the netw

Sep 26, 2021
JeTaxi is built on Clean Architecture-MVVM with Kotlin and follows modern android development trends.
 JeTaxi is built on Clean Architecture-MVVM with Kotlin and follows modern android development trends.

JeTaxi is built on Clean Architecture-MVVM with Kotlin and follows modern android development trends. Also, It uses some of Jetpack and popular libraries. These are Kotlin Coroutine-Flow, kotlinx.serialization, Hilt, Compose, Accompanist, Retrofit2, OkHttp3, Chucker, MockWebServer, Truth.

May 19, 2022