All Projects → moxy-community → Moxy

moxy-community / Moxy

Licence: mit
Moxy is MVP library for Android with incremental annotation processor and ktx features

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Moxy

Mvpart
🎨 A new Android MVP architecture (此框架旨在解决传统 MVP 类和接口太多, 并且 Presenter 和 View 通过接口通信过于繁琐, 重用 Presenter 代价太大等问题).
Stars: ✭ 776 (+231.62%)
Mutual labels:  mvp, android-architecture, mvp-architecture, mvp-android
Flair
This is powerful android framework
Stars: ✭ 31 (-86.75%)
Mutual labels:  mvp, android-architecture, mvp-architecture, mvp-android
Android Mvp Architecture
🏛 A basic sample android application to understand MVP in a very simple way. Just clone, build, run and understand MVP.
Stars: ✭ 203 (-13.25%)
Mutual labels:  mvp, android-architecture, mvp-architecture, mvp-android
Armscomponent
📦 A complete android componentization solution, powered by MVPArms (MVPArms 官方快速组件化方案).
Stars: ✭ 1,664 (+611.11%)
Mutual labels:  mvp, android-architecture, mvp-architecture, mvp-android
Mvparms
⚔️ A common architecture for Android applications developing based on MVP, integrates many open source projects, to make your developing quicker and easier (一个整合了大量主流开源项目高度可配置化的 Android MVP 快速集成框架).
Stars: ✭ 10,146 (+4235.9%)
Mutual labels:  mvp, android-architecture, mvp-architecture, mvp-android
Karchi
Repository that showcases 3 different Android app architectures, all with Java and Kotlin versions: "Standard Android", MVP and MVVM. The exact same app is built 6 times following the different patterns.
Stars: ✭ 20 (-91.45%)
Mutual labels:  mvp, android-architecture, mvp-android
Mvvm Kotlin Android Architecture
MVVM + Kotlin + Retrofit2 + Hilt + Coroutines + Kotlin Flow + mockK + Espresso + Junit5
Stars: ✭ 1,014 (+333.33%)
Mutual labels:  mvp, android-architecture, mvp-architecture
Android Clean Architecture Boilerplate
Apply clean architecture on Android
Stars: ✭ 141 (-39.74%)
Mutual labels:  mvp, mvp-architecture, mvp-android
Kotlinmvparchitecture
Clean MVP Architecture with Dagger2 + Retrofit2 + Mockito + Fresco + EasiestGenericRecyclerAdapter using Kotlin. Added Unit Tests(Kotlin Tests)!
Stars: ✭ 143 (-38.89%)
Mutual labels:  mvp, mvp-architecture, mvp-android
Supermvp
MVP“美”图+新闻+天气预报+Material+RxJava3+Retrofit2+Glide4+AndroidX+Leakcanary+Butterknife
Stars: ✭ 763 (+226.07%)
Mutual labels:  mvp, mvp-architecture, mvp-android
Android tmdb clean architecture
Showcase of clean architecture concepts along with Continuous Integration and Development for modular Android applications. Includes test suits (functional and unit tests) along with code coverage.
Stars: ✭ 63 (-73.08%)
Mutual labels:  mvp, android-architecture, mvp-android
Memorize
🚀 Japanese-English-Mongolian dictionary. It lets you find words, kanji and more quickly and easily
Stars: ✭ 72 (-69.23%)
Mutual labels:  mvp, mvp-architecture, mvp-android
Kotlinrxmvparchitecture
Clean MVP Architecture with RxJava + Dagger2 + Retrofit2 + Mockito + Fresco + EasiestGenericRecyclerAdapter using Kotlin. Includes Unit Tests(Kotlin Tests)!
Stars: ✭ 94 (-59.83%)
Mutual labels:  mvp, mvp-architecture, mvp-android
Android Mvp Basic Sample
Android MVP Basic Sample
Stars: ✭ 140 (-40.17%)
Mutual labels:  mvp, mvp-architecture, mvp-android
Mvpandroid
Sample app to demonstrate MVP (Model - View - Presenter) architecture in android
Stars: ✭ 91 (-61.11%)
Mutual labels:  mvp, mvp-architecture, mvp-android
Androidbasemvp
🚀一个快速搭建MVP+RxJava2+Retrofit 基础框架,主要是封装有Http网络请求、日志、缓存、加载等待、toast、页面状态布局管理、权限、RxBus、Glide图片加载等组件,方便快速开发新项目、减少开发成本。
Stars: ✭ 184 (-21.37%)
Mutual labels:  mvp, mvp-architecture, mvp-android
Simple Mvp Retrofit Example
A simple example of a project using MVP architecture and Retrofit 2.0 library for Android for beginners.
Stars: ✭ 70 (-70.09%)
Mutual labels:  mvp, mvp-architecture, mvp-android
Android Mvp Architecture
This repository contains a detailed sample app that implements MVP architecture using Dagger2, GreenDao, RxJava2, FastAndroidNetworking and PlaceholderView
Stars: ✭ 4,360 (+1763.25%)
Mutual labels:  mvp, android-architecture, mvp-architecture
Android Kotlin Mvp Architecture
This repository contains a detailed sample app that implements MVP architecture in Kotlin using Dagger2, Room, RxJava2, FastAndroidNetworking and PlaceholderView
Stars: ✭ 615 (+162.82%)
Mutual labels:  mvp, mvp-architecture, mvp-android
Android Mvp Architecture
MVP + Kotlin + Retrofit2 + Dagger2 + Coroutines + Anko + Kotlin-Android-Extensions + RX-java + Mockk + Espresso + Junit5
Stars: ✭ 82 (-64.96%)
Mutual labels:  mvp, android-architecture, mvp-architecture

Moxy

Bintray Maven Central

Moxy 2 is out! Check out the migration guide and give it a try!

Moxy is a library that allows for hassle-free implementation of the MVP pattern in an Android Application. Without troubles of lifecycle and boilerplate code!

Illustration of how Moxy is working: schematic_using

Capabilities

Moxy has a few killer features:

  • Presenter stays alive when Activity is being recreated (it simplifies multithread handling)
  • Automatical restoration of all content in the recreated Activity (including additional dynamic content)

Example

View interface

interface MainView : MvpView {

    @AddToEndSingle
    fun displayUser(user: User)
}

class MainActivity : MvpAppCompatActivity(R.layout.activity_main), MainView {

    private val presenter by moxyPresenter { MainPresenter() }

    override fun displayUser(user: User) {
        userLayout.showUser(user)
    }
}

Presenter

class MainPresenter : MvpPresenter<MainView>() {
    override fun onFirstViewAttach() {
        viewState.showUser(getCurrentUser())
    }
}

Inject with Dagger2

Kotlin

@Inject
lateinit var presenterProvider: Provider<MainPresenter>

private val presenter by moxyPresenter { presenterProvider.get() }

Java

@InjectPresenter
MainPresenter presenter;

@Inject
Provider<MainPresenter> presenterProvider;

@ProvidePresenter
MainPresenter providePresenter() {
    return presenterProvider.get();
}

Android studio and Intellij templates

We will change this template in future In order to avoid tedious task of writing boilerplate code for binding activities, fragments and its presentation parts, we recommend use of Android Studio templates for Moxy.

Links

Telegram channels from original moxy community

Telegram channel (en)
Telegram channel (ru)

Integration

Please replace moxyVersion with the latest version number: Bintray

Base modules

Java

dependencies {
    // ...
    implementation "com.github.moxy-community:moxy:$moxyVersion"
    annotationProcessor "com.github.moxy-community:moxy-compiler:$moxyVersion"
}

Kotlin

apply plugin: 'kotlin-kapt'
// ...
dependencies {
    // ...
    implementation "com.github.moxy-community:moxy:$moxyVersion"
    kapt "com.github.moxy-community:moxy-compiler:$moxyVersion"
}

Java 8

Moxy uses Java 8 features, so you also need to specify source and target compatibility for each Module that uses Moxy:

android {
    ...
    // For Java projects
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    // For Kotlin projects
    kotlinOptions {
        jvmTarget = "1.8"
    }
}

Default Android module

For additional base view classes MvpActivity and MvpFragment add this:

implementation "com.github.moxy-community:moxy-android:$moxyVersion"

AppCompat module

If you are using AppCompat, you'll need MvpAppCompatActivity and MvpAppCompatFragment classes. Add this:

implementation "com.github.moxy-community:moxy-app-compat:$moxyVersion"

AndroidX module

If you're using AndroidX, you'll need a different implementation for MvpAppCompatActivity and MvpAppCompatFragment classes. Use this one:

implementation "com.github.moxy-community:moxy-androidx:$moxyVersion"

AndroidX (Google material) module

If you're using Google material, use MvpBottomSheetDialogFragment and add this:

implementation "com.github.moxy-community:moxy-material:$moxyVersion"

Kotlin extensions

Declare presenters in your views using property delegate:

class MyFragment: MvpFragment() {
    ...
    private val presenter by moxyPresenter { presenterProvider.get() }
    ...
}

Launch coroutines in presenter scope:

class MyPresenter : MvpPresenter<MvpView>() {
    override fun onFirstViewAttach() {
        presenterScope.launch {
            // Coroutine that will be canceled when presenter is destroyed
        }
    }
}

To use MvpDelegateHolder.moxyPresenter and MvpPresenter.presenterScope, add this:

implementation "com.github.moxy-community:moxy-ktx:$moxyVersion"

New Features and Compiler option for Migration from old version

By default, each MvpView method must have an annotation @StateStrategyType. In the version 1 of Moxy it was allowed to omit stategies for methods. In this case a default strategy was applied.

You can fallback to the old behavior. To do this, set the disableEmptyStrategyCheck parameter to true.

disableEmptyStrategyCheck : 'true'

In this case the default strategy will be AddToEndSingleStrategy. In the old version the default strategy was AddToEndStrategy.

To change default strategy provide for the defaultMoxyStrategy parameter a full class name of the new default strategy.

defaultMoxyStrategy : 'moxy.viewstate.strategy.OneExecutionStateStrategy'

If the compiler finds MvpView method without the @StateStrategyType annotation, it'd show an error via standard method for notifying about compilation problems. For ease of migration from older versions we have provided an additional mechanism: EmptyStrategyHelper. It collects all the errors associated with an empty strategy in one place. Using it, you can easily navigate from the EmptyStrategyHelper directly to the method with a missing strategy.

To switch the error output method enable this option

enableEmptyStrategyHelper : 'true'

To enable Isolating incremental annotation processor mode for Moxy processor use this option

moxyEnableIsolatingProcessing : 'true'

Use this option for faster incremental builds. You can read about differences between Isolating and Aggreagating modes and Gradle incremental annotation processing support in Gradle documentation. Warning! This option is experimental for now. It should work fine, but we prefer to make this transition as safe as possible. If you'll encounter compilation problems after enabling this option, please feel free to report an ussue. Hopefully we will enable isolating annotation processor mode by default after several releases.

How to correctly use compilation flags check out the sample-app build.gradle file

Plugin

This plugin automates work with strategies You can download it here https://plugins.jetbrains.com/plugin/13679-moxy-strategy/versions developing here https://github.com/Maksim-Novikov/moxy-strategy-plugin

ProGuard\R8

If you are using R8 then no additional configuration required. If you use ProGuard then you have to manually add rules from this file.

Road Map

  • [✓] Provide a migration tool from com.arello-mobile.moxy and its default strategy
  • [✓] Kotlin incremental compilation support
  • [✓] Remove reflectors and common presenter store
  • [✓] Add delivery module support
  • [х] Add separate Annotation Processor for migration
  • [✓] Research possibility of removing @InjectViewState annotation
  • [ ] Provide Runtime Implementation

Moxy Community

Brave people who created the library:

@senneco
@jordan1997
@xanderblinov
@VovaStelmashchuk
@aasitnikov
@alaershov
@bejibx
@katkoff
@ekursakov
@SavinMike
@sychyow
@AlexeyKorshun
@dmdevgo
@rsajob
@terrakok
@mohaxspb
@CherryPerry
@fl1pflops
@phoenixxt
@Dosssik
@AcoustickSan
@seven332
@v-grishechko
@sbogolepov
@A-Zaiats
@lion4ik
@NotPerfectBlue
@IlyaGulya
@Svechnikov
@hram
@ValdZX
@Maksim-Novikov

You may also find them in contributors page of the old project

Contributing

Install code style to your IntelliJ or Android Studio. MoxyAndroid.xml For import file use or Mac OS: Preferences -> Editor -> Code style -> Scheme -> Import Scheme -> IntelliJ IDEA code style XML -> choose the MoxyAndroid.xml file in finder

License

The MIT License (MIT)

Copyright (c) 2019 Moxy Community

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.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].