All Projects → benoitletondor → Android Studio Mvp Template

benoitletondor / Android Studio Mvp Template

Licence: apache-2.0
Android MVP template for Android Studio

Projects that are alternatives of or similar to Android Studio Mvp Template

MVPDemo
MVP+动态代理的模式框架例子
Stars: ✭ 12 (-98.11%)
Mutual labels:  mvp, mvp-android
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 (-3.3%)
Mutual labels:  mvp, mvp-android
android-template
Template for android development at Tiki
Stars: ✭ 17 (-97.33%)
Mutual labels:  mvp, mvp-android
wikilight
A lightweight Wikipedia Client
Stars: ✭ 50 (-92.14%)
Mutual labels:  mvp, mvp-android
Componentizationarch
Stars: ✭ 265 (-58.33%)
Mutual labels:  mvp, mvp-android
mvp-sample
一个简单的MVP示例,和传统不一样的是,我们把Activity/Fragment作为Presenter,把View单独提出来,扩展了Presenter的能力。
Stars: ✭ 41 (-93.55%)
Mutual labels:  mvp, mvp-android
uv-index
This is a work-in-progress (🔧️) ultraviolet index viewer app for demonstrating Instant Apps + Kotlin + Dagger + MVP
Stars: ✭ 64 (-89.94%)
Mutual labels:  mvp, mvp-android
XMVP
This is a mvp framework to help you easily achieve mvp structure.
Stars: ✭ 61 (-90.41%)
Mutual labels:  mvp, mvp-android
visum
Android reactive MVP stack
Stars: ✭ 19 (-97.01%)
Mutual labels:  mvp, mvp-android
KotlinMvpTemplateGenerator
Android Studio template for Kotlin with MVP + Dagger2 + Retrofit2
Stars: ✭ 65 (-89.78%)
Mutual labels:  mvp, mvp-android
AlquranQ
Terjemahan Alquran Bahasa Indonesia & Bahasa Inggris
Stars: ✭ 26 (-95.91%)
Mutual labels:  mvp, mvp-android
Firebucket
Glimpse into Firebase, with a simple TODO list app built around Dagger, RxJava 2, Clean architecture and of course, Firebase.
Stars: ✭ 376 (-40.88%)
Mutual labels:  mvp, mvp-android
Trickl
trickl torrent client
Stars: ✭ 50 (-92.14%)
Mutual labels:  mvp, mvp-android
Klean-ArchiteKture
Kotlin Android clean-architecture demo project for a meetup talk. Slides: https://docs.google.com/presentation/d/1CxnntHf3CorNDicx_cDN5s1t5pEbUwjwWHZ5PNmfe6Y/edit?usp=sharing
Stars: ✭ 10 (-98.43%)
Mutual labels:  mvp, mvp-android
MVPDemo
Android MVP架构Demo--Android MVP架构从入门到精通-真枪实弹
Stars: ✭ 66 (-89.62%)
Mutual labels:  mvp, mvp-android
EdgeMvp
一个MVP架构利器。自动生成接口文件,且不需要实现接口。
Stars: ✭ 56 (-91.19%)
Mutual labels:  mvp, mvp-android
Preservely
Lightweight Android lib preserving objects instances during orientation changes
Stars: ✭ 22 (-96.54%)
Mutual labels:  mvp, mvp-android
Android-Starter-Kit
This is up-to-date android studio project for native android application, that is using modern tools and libraries.
Stars: ✭ 16 (-97.48%)
Mutual labels:  mvp, mvp-android
mvp-android-template
MVP Android Template to give you a Quick Head Start for your next Android Project. It implements MVP Architecture using Dagger2, Room, RxJava2 , Retrofit2
Stars: ✭ 20 (-96.86%)
Mutual labels:  mvp, mvp-android
The Pit Of The Android Studio
👍 👍 👏 🌟 ⭐️ ⭐️ Everything about the Android Studio and Intellij IDEAfor example:Install,common problems and solutions,each libraries for android and androidx library,code and peoject templates,etc.全面总结Android Studio以及Intellij IDEA的填坑指南,详解AS版本号、Gradle版本、BuildTools三者的对照关系,AS模板配置,gradle插件,Android自带注解库详解,support详解等干货。
Stars: ✭ 296 (-53.46%)
Mutual labels:  freemarker, android-studio

Android Studio MVP Template

This is an Android Studio template for MVP.

It is inspired by u2020-mvp-android-studio-template and follows Antonio Leiva's MVP implementation guide for Android. It also implements presenter surviving orientation changes following Antonio Gutierrez's article.

If you are looking for the first version, without presenter survival, please download the first release. Note that version 2 (current one) is not compatible with version 1.

Here's the hierarchy it follows:

com.company.app
    +-- injection
    |   - ActivityScope
    |   - AppComponent
    |   - AppModule
    |   - FragmentScope
    |   - MainViewComponent
    |   - MainViewModule
    +-- interactor
    |   +-- impl
    |       - MainViewInteractorImpl
    |   - BaseInteractor
    |   - MainViewInteractor
    +-- presenter
    |   +-- impl
    |       - BasePresenterImpl
    |       - MainViewPresenterImpl
    |   - BasePresenter
    |   - MainViewPresenter
    +-- view
    |   +-- impl
    |       - BaseActivity
    |       - BaseFragment
    |       - MainActivity
    |   - MainView
    | - YourApp

Prerequisites

You must use Dagger 2 for dependency injection and AppCompat for annotations and base classes.

Installation

For Mac:

  • If you have a standard Android Studio installation:

Just run the install script at the root of this repository:

./install.sh
  • Manual installation:

Just copy all 3 directories MVPFragment, MVPActivity and MVPBoilerplate to $ANDROID_STUDIO_FOLDER$/Contents/plugins/android/lib/templates/activities/

For Windows:

Just copy all 3 directories MVPFragment, MVPActivity and MVPBoilerplate to $ANDROID_STUDIO_FOLDER$\plugins\android\lib\templates\activities\

How to use

1. Generate base boilerplate

First of all, create the base hierarchy and classes using MVP Boilerplate from the root package folder. This needs to be done only once per project:

Create MVP Boilerplate

It will generate an App class that you should use as your Application, an ActivityScope, FragmentScope, AppModule and AppComponent for injection, a BaseActivity, BaseFragment, BasePresenter, BasePresenterImpl and BaseInteractor. It also generates the common classes for presenter persistancy (PresenterFactory and PresenterLoader).

Be sure to use the generated App as your Application into your manifest!

2. Create your first activity

Then you can create a new MVP Activity. It will create:

  • An Activity
  • A layout for your Activity
  • A Component and a Module for Dagger 2 injection
  • A View interface for your Activity
  • A Presenter interface and default implementation class
  • An Interactor interface and default implementation class for your model

It's important that you create it from the root package, otherwise it will re-create the whole MVP hierarchy under your subpackage which is not what you want.

Presenter lifecycle (Important!)

Your presenter will be kept across activity re-creation on orientation changes using a Loader. For more details about how its done, read Antonio Gutierrez's article.

It means that:

  • You want to be sure to update your view state on each onStart call of your presenter since your view may have been destroyed and re-created since last stop.
  • You should use the viewCreated parameter of the onStart method to know if the view has been created or re-created (e.g. following a screen rotation). This boolean will be true only if the view has just been created so if it's true you should update your view according to the presenter's state.
  • You should not stop your background operations on the onStop method (things like HTTP calls or database connection) since your view may still be available (on the next onStart call).
  • You must stop all background operation on the onPresenterDestroyed method. When this method is reached, it means that your view is completely destroyed and will not be re-created later.

You should also be very careful about:

  • Since the presenter is loaded asynchronously by a Loader, it means that it's not available before the view actually started. So the mPresenter variable can (and will probably) be null when your activity or fragment starts (you should not call your presenter directly into onCreate, onStart or onResume methods).
  • To avoid leaks, your presenter will not keep a reference on your view when this view is stopped. It means that your view is guaranteed to be available from the onStart method to the onStop. It also means it will be null outside of this scope.

To ensure those last 2 points, mView and mPresenter are annotated with @Nullable, to enforce the check by the linter. It's a good idea to surround all calls with !=null.

Contributors

License

Copyright 2019 Benoit LETONDOR

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
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].