This repository contains a detailed sample app that implements MVP architecture using Dagger2, GreenDao, RxJava2, FastAndroidNetworking and PlaceholderView

Overview

Android MVP Architecture: Sample App

Mindorks Mindorks Community

This repository contains a detailed sample app that implements MVP architecture using Dagger2, GreenDao, RxJava, FastAndroidNetworking, PlaceHolderView and AndroidDebugDatabase




Architecture Blueprint

Blueprint

Project Structure

Structure

Read the below listed articles. They describe the MVP concepts and the Project structure.

  1. MVP: Part 1
  2. MVP: Part 2
  3. MVP: Part 3
  4. Extension with Interactors and Repositories

The app has following packages:

  1. data: It contains all the data accessing and manipulating components.
  2. di: Dependency providing classes using Dagger2.
  3. ui: View classes along with their corresponding Presenters.
  4. service: Services for the application.
  5. utils: Utility classes.

Classes have been designed in such a way that it could be inherited and maximize the code reuse.

Library reference resources:

  1. RxJava2: https://github.com/amitshekhariitbhu/RxJava2-Android-Samples
  2. Dagger2: https://github.com/MindorksOpenSource/android-dagger2-example
  3. FastAndroidNetworking: https://github.com/amitshekhariitbhu/Fast-Android-Networking
  4. PlaceHolderView: https://github.com/janishar/PlaceHolderView
  5. AndroidDebugDatabase: https://github.com/amitshekhariitbhu/Android-Debug-Database
  6. Calligraphy: https://github.com/chrisjenx/Calligraphy
  7. GreenDao: http://greenrobot.org/greendao/
  8. ButterKnife: http://jakewharton.github.io/butterknife/

Concept reference resources:

  1. Introduction to Dagger 2: Part 1
  2. Introduction to Dagger 2: Part 2
  3. Android Dagger2: Critical things to know before you implement
  4. The Best Android Networking Library for Fast and Easy Networking
  5. RxJava + Fast Android Networking
  6. Migrating from RxJava 1.0 to RxJava 2.0 and Learn RxJava by Examples
  7. Android Tinder Swipe View Example
  8. Debugging Android Databases And Shared Preferences In The Easiest Way
  9. RxJava Anatomy: What is RxJava, how RxJava is designed, and how RxJava works.
  10. Powerful Android ORM: greenDAO 3 Tutorial

Learn to build a ride-sharing Android app like Uber, Lyft - Check here

Looking for MVVM Architecture for Beginners - Check here

Looking for MVVM Architecture - Check here

Looking for Kotlin MVP Architecture - Check here

Mindorks open source projects

Check out Mindorks awesome open source projects here

How do I use this project?

This is a boilerplate project aimed to help bootstrap new Android MVP Applications. Feel free to fork this application or use AndroidStarters to create new app using this boilerplate.

MVP template

When we follow any architecture pattern like MVP, MVVM, MVP clean, we always come across a small but repetitive task to create basic files like Android Activity, Presenter, View, Api models and then writing boiler plate code. This usually takes 1-2 hours for each single screen. To ease out work and save time We have created an automated template which will do above work in less than 20 seconds.

How to Install

Find the template/MVPActivity folder under root directory of android-mvp-architecture app. Paste the MVPActivity folder at below location.

  1. Windows - C:\Program Files\Android\Android Studio\plugins\android\lib\templates\activities
  2. Mac - /Applications/Android/Studio.app/Contents/plugins/android/lib/templates/activities

Restart the Android Studio.

Blueprint

How to use

Select the folder under which you want to create a new MVP folder. This MVP folder will contain Activity, Presenter, MVpPresenter and View class. For example, to create a new MVP folder under “view” folder, do as shown below.

Blueprint

License

   Copyright (C) 2017 MINDORKS NEXTGEN PRIVATE LIMITED

   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.

Contributing to Android MVP Architecture

All pull requests are welcome, make sure to follow the contribution guidelines when you submit pull request.

Comments
  • Don't cast the ApplicationContext to your MvpApp

    Don't cast the ApplicationContext to your MvpApp

    In your MvpApp class you cast the ApplicationContext to your MvpApp.

    return (MvpApp) context.getApplicationContext();

    This is wrong: see this SO Answer for details:

    So if you want the Application class you registered in the Manifest, you should never call getApplicationContext() and cast it to your application, because it may not be the application instance (which you obviously experienced with the test framework).

    opened by tmtron 7
  • Can't use Generic Class on getObjectSingle

    Can't use Generic Class on getObjectSingle

    https://github.com/MindorksOpenSource/android-mvp-architecture/blob/ef9de86274b76e3a7ca7523ca7c258203cb8197d/app/src/main/java/com/mindorks/framework/mvp/data/network/AppApiHelper.java#L66

    https://i.stack.imgur.com/S8p75.png https://i.stack.imgur.com/Gyico.png

    opened by indraAsLesmana 4
  • Why Presenter and its related classes care created as Generic. But not view contract?

    Why Presenter and its related classes care created as Generic. But not view contract?

    Hi, I have simple doubt with the presenter classes that are created in this project. I noted all the presenter classes (both classes & interfaces) are created as generic type classes. But view contract classes are not generic. Even though I created all the view contract classes generic it works fine. But fortunately I noted that view contract classes are not generic, Is there any specific reason for that?

    opened by anbarasu-seven 4
  • Use getSchedulerProvider and  getCompositeDisposable in services.

    Use getSchedulerProvider and getCompositeDisposable in services.

    What is the way to use getCompositeDisposable and getSchedulerProvider in a service (For example SyncService)?

    I have several services, one of them from Firebase (to update the user's push token) but I have to make an HTTP call from the service and I could not do it. I tried using dependency injection but I could not.

    opened by Themesaul 3
  • CompositeDisposable dispose when detaching fragment

    CompositeDisposable dispose when detaching fragment

    I'm attaching and detaching fragments, when i first add the fragment and call the presenter methods eveything works ok but after deataching and attaching again the compositeDisposable is disposed and doesn't execute anything. Any clue?

     switch (screenKey) {
                    case Screens.STATUS_SCREEN:
                        fm.beginTransaction()
                                .detach(historyFragment)
                                .detach(profileFragment)
                                .attach(statusFragment)
                                .commitNow();
                        break;
                    case Screens.HISTORY_SCREEN:
                        fm.beginTransaction()
                                .detach(profileFragment)
                                .detach(statusFragment)
                                .attach(historyFragment)
                                .commitNow();
                        break;
                    case Screens.PROFILE_SCREEN:
                        fm.beginTransaction()
                                .detach(historyFragment)
                                .detach(statusFragment)
                                .attach(profileFragment)
                                .commitNow();
                        break;
                }
    

    EDIT: I have a MainActivity which has an fragment_container that i change over bottonNavigationBar selection.

    opened by madnotdead 3
  • How to mock for UI testing?

    How to mock for UI testing?

    I'm really confused on how it should work. I'm studying this architecture and converting it to kotling, it seems even tho I can build successfully I cannot get a Mocked instance of API or Preferences helper, what I mean is that I'm trying to mock objects using mockito at ApplicationTestModule but its not replacing the real object from ApplicationModule, I wonder if there is something missing in the flow,... if RuleChain is properly setup in fact. I see the calls from TestComponentRule but

    mTestComponent = DaggerTestComponent.builder() .applicationTestModule(ApplicationTestModule(app)) .build()

    this is not working

    opened by andretortolano 3
  • mOpenSourceAdapter is null

    mOpenSourceAdapter is null

    https://github.com/MindorksOpenSource/android-mvp-architecture/blob/4191a3c325a2464811fdf4c3733731f54b4902a5/app/src/main/java/com/mindorks/framework/mvp/ui/feed/opensource/OpenSourceFragment.java#L100

    Sometimes mOpenSourceAdapter is null and it hangs.

    Reproduce the problem in an easy way:

    1- Start an intent to youtube

    Intent intent = new Intent(Intent.ACTION_VIEW,Uri.parse(String.format("http://www.youtube.com/watch?v=%s", KEY))); intent.putExtra("force_fullscreen", true); itemView.getContext().startActivity(intent);

    2- Press 4 times or more the button back before the video is opened

    2.1 - The "onDestroyView" method is triggered when it does not have to.

    3 - mOpenSourceAdapter is null and the application closes

    I have tried to check if it is null and in the case that it is to start a new instance of OpenSourceAdapter but the application does not respond.

    Is this normal?

    opened by Themesaul 2
  • GreenDao and HTTP same time

    GreenDao and HTTP same time

    In the case of wanting to implement custom offline cache with GreenDao, Where should I do in DataManager or in the request in the presenter?

    You could say how you would do it, please (no need code, just a short description, for example for getBlogApiCall() )

    Another question I have is about the possibility of making multiple requests (single, ex: getBlogApiCall) at a time (when necessary) with zip. Is it a good practice?

    Thanks for this repository and for the blog.

    opened by Themesaul 2
  • Update UI in Service?

    Update UI in Service?

    Hi guys, I'm a new guys trying to implement MVP with dependencies injection to new app. I have a question about working with Service in MVP structure. Is there a best way to update UI in a service in this architecture? (Ex : SyncService in this example). Or I have to update through presenter? If i have to update through presenter, what should I do?

    And how about Broadcast Receiver from system. Is there a best practice to do that also ?

    Thank you so much!

    opened by giaotuancse 2
  • UnitTestingError

    UnitTestingError

    when I add the code blow to the LoginPresenterTest.java

    @Test
    public void testInvalidEmailLoginShouldShowError() {
            //invalid email address
            String email = "dummygmail.com";
            String password = "password";
            mLoginPresenter.onServerLoginClick(email, password);
            verify(mMockLoginMvpView).onError(R.string.invalid_email);
    }
    

    and run the test class LoginPresenterTest, then error occurred:

    java.lang.ExceptionInInitializerError
    	at io.reactivex.android.schedulers.AndroidSchedulers$1.call(AndroidSchedulers.java:35)
    	at io.reactivex.android.schedulers.AndroidSchedulers$1.call(AndroidSchedulers.java:33)
    	at io.reactivex.android.plugins.RxAndroidPlugins.callRequireNonNull(RxAndroidPlugins.java:70)
    	at io.reactivex.android.plugins.RxAndroidPlugins.initMainThreadScheduler(RxAndroidPlugins.java:40)
    	at io.reactivex.android.schedulers.AndroidSchedulers.<clinit>(AndroidSchedulers.java:32)
    	at com.mindorks.framework.mvp.ui.login.LoginPresenter.onServerLoginClick(LoginPresenter.java:67)
    	at com.mindorks.framework.mvp.ui.login.LoginPresenterTest.testServerLoginSuccess(LoginPresenterTest.java:82)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.lang.reflect.Method.invoke(Method.java:498)
    	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
    	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
    	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
    	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
    	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
    	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
    	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
    	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
    	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    	at org.mockito.internal.runners.DefaultInternalRunner$1.run(DefaultInternalRunner.java:68)
    	at org.mockito.internal.runners.DefaultInternalRunner.run(DefaultInternalRunner.java:74)
    	at org.mockito.internal.runners.StrictRunner.run(StrictRunner.java:39)
    	at org.mockito.junit.MockitoJUnitRunner.run(MockitoJUnitRunner.java:161)
    	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
    	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
    	at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:51)
    	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
    	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.lang.reflect.Method.invoke(Method.java:498)
    	at com.intellij.rt.execution.application.AppMainV2.main(AppMainV2.java:131)
    Caused by: java.lang.RuntimeException: Method getMainLooper in android.os.Looper not mocked. See http://g.co/androidstudio/not-mocked for details.
    	at android.os.Looper.getMainLooper(Looper.java)
    	at io.reactivex.android.schedulers.AndroidSchedulers$MainHolder.<clinit>(AndroidSchedulers.java:29)
    	... 41 more
    
    opened by iplanetcn 2
  • Manifest merger failed

    Manifest merger failed

    Upon installing the relevant libraries and trying to build for the first time it displays this message:

    Error:Execution failed for task ':app:processDebugManifest'. Manifest merger failed : Attribute meta-data#android.support.VERSION@value value=(25.3.0) from [com.android.support:cardview-v7:25.3.0] AndroidManifest.xml:24:9-31 is also present at [com.android.support:recyclerview-v7:25.3.1] AndroidManifest.xml:24:9-31 value=(25.3.1). Suggestion: add 'tools:replace="android:value"' to <meta-data> element at AndroidManifest.xml:22:5-24:34 to override.

    Upon adding to AndroidManifest.xml:

    <meta-data tools:replace="android:value"/>
    

    it displays:

    Error:Execution failed for task ':app:processDebugManifest'. Manifest merger failed with multiple errors, see logs

    opened by jbmlaird 2
  • Can't login ,What's  the default  username and  password?

    Can't login ,What's the default username and password?

    图片 I try to use this username and password,it dose not work。 And why when i write the real and collect google account and password ,it still can't login?It's a fake function? I don't understand the login logic。

    opened by 1322739583 2
  • MVP template not working with Android Studio 3.6 on MACOS

    MVP template not working with Android Studio 3.6 on MACOS

    Please help, I can not using MVP template with my Android Studio. When I copy and paste the MVPActivity folder at this location : /Applications/Android/Studio.app/Contents/plugins/android/lib/templates/activities

    -> I can not see menu MVP on my Android Studio

    opened by hoang89yenthe 0
  • Android Boiler code template is not working...

    Android Boiler code template is not working...

    The boiler plate template is not showing in my menu... May be Android studio made some changes in latest update... don't know how to debug... or fix this thing... I tried myself but everything is fine as per guidelines...

    opened by satputekuldip 0
  • Better understanding of documentation

    Better understanding of documentation

    Hi all friends Friends, to better understand this framework, let's do everything by example Examples help us to master this framework more effectively Examples can be as follows, such as forms, lists, and even small projects. This can help a great deal. Form Submit Forms

    Lists Lists

    opened by awebmaker 0
Owner
MindOrks
Learn Android App Development
MindOrks
An Open-Source repository that contains all the Android Dev and Kotlin concepts and several projects on android ranging in difficulty making this repo completely beginner-friendly.

An Open-Source repository that contains all the Android Dev and Kotlin concepts and several projects on android ranging in difficulty making this repo completely beginner-friendly. The main aim of this repository is to help students who are learning Android Development or preparing for an Android Developer role-based job.

Mimo Patra 15 Dec 29, 2022
Repository contains structures and methods to execute linear algebra operations (matrix multiplication etc)

LinearAlgebra Repository contains structures and methods to execute linear algebra operations (matrix multiplication etc) Matrix class Matrix implemen

null 0 Apr 27, 2022
A repository that contains various examples of how to use the telegram-bot library.

Telegram-bot templates This repository contains simple different examples of how to use the telegram-bot library. How to use All the examples are conv

Jey 3 Nov 15, 2022
❤️ A sample Marvel heroes application based on MVVM (ViewModel, Coroutines, LiveData, Room, Repository, Koin) architecture.

MarvelHeroes MarvelHeroes is a demo application based on modern Android application tech-stacks and MVVM architecture. Fetching data from the network

Jaewoong Eum 1.2k Dec 19, 2022
:movie_camera: Movie discovery app showcasing Android best practices with Google's recommended architecture: MVVM + Repository + Offline support + Android Architecture Components + Paging library & Retrofit2.

Popular Movies Stage 1 + Stage 2 Discover the most popular and top rated movies playing. Movies data fetched using themoviedb.org API. ✨ Screenshots M

Yassin AJDI 189 Nov 26, 2022
This repo contains sample mobile apps that implement contributor design pattern

This repo contains sample mobile apps that implement contributor design pattern. This design pattern was evolved to establish clean contracts for the developers and partners in Teams Mobile code base

Microsoft 3 Jan 6, 2023
Android app built with MVP architectural approach and uses Marvel Comics API that allows developers everywhere to access information about Marvel's vast library of comics. :zap:

Villains & Heroes Android app built with MVP architectural approach and uses Marvel Comics API that allows developers everywhere to access information

André Mion 53 Jul 13, 2022
🦁 A Disney app using transformation motions based on MVVM (ViewModel, Coroutines, Flow, LiveData, Room, Repository, Koin) architecture.

DisneyMotions A demo Disney app using transformation motions based on MVVM architecture. The motion system is included in the 1.2.0-alpha05 released m

Jaewoong Eum 1.4k Dec 16, 2022
This is a work-in-progress (🔧️) ultraviolet index viewer app for demonstrating Instant Apps + Kotlin + Dagger + MVP

UV Index A simple ultraviolet index viewer app for demonstrating: Instant Apps + Kotlin + Dagger + MVP Built With Weatherbit as weather API Android In

Mustafa Berkay Mutlu 65 Oct 31, 2022
An MVP Dribbble client for Android Mobile, Tablet, Wear and TV.

Bourbon ![Sidebar] (https://img.shields.io/badge/Sidebar-06%2F05%2F2016-orange.svg) Bourbon is a simple Dribbble client built for Android Mobile, Wear

Joe Birch 1.1k Dec 12, 2022
Android application that implements location and network related Android APIs

Location and network data collection Location and network data collection with Android's telephonyManager class. Introduction Technologies Android's A

jquk 0 Oct 31, 2021
A PyCharm plugin that implements inlay parameter and type annotation hints for Python.

Python Inlay Params Quick Installation Using IDE built-in plugin system: Settings/Preferences > Plugins > Marketplace > Search for "Python Inlay Param

Daniil Kovalenko 19 Dec 5, 2022
Simple Mvp Implementation

Froggy Simple Mvp Implementation Download Gragle: compile 'ru.bullyboo.mvp:froggy:1.0.2' Maven: <dependency> <groupId>ru.bullyboo.mvp</groupId>

Rostislav Sharafutdinov 15 Mar 17, 2019
This projects implements Github User search with Android Pagination 3 Library

GithubUser Search An Android App that lists the github users sorted by most followers Resources GitHub API Building Clone the git repository Build ./g

Siyanatullah Khan 3 Oct 12, 2022
This app contains feature barcode and QR scanner, and video recording in-app.

BarcodeQRScannerAndVideoRecord This app contains feature barcode and QR scanner, and video recording in-app. Scanner using ML Kit and CameraX. Video R

Abdullah Fahmi 1 Dec 23, 2021
Advanced Android Weather App using MVVM Architecture Sample (ViewModel + LiveData + Kotlin + volley) = Weather App

Advanced Android Weather App using MVVM Architecture Sample (ViewModel + LiveData + Kotlin + volley) = Weather App Video Weather.-.HD.720p.mov Introdu

wykee2 4 Jul 12, 2022
A sample app illustrating Android development using Kotlin with MVVM architecture, Android Jetpack, and other commonly used libraries.

Anime Facts A sample app illustrating Android development using Kotlin with MVVM architecture, Android Jetpack, and other commonly used libraries. Ani

Eugene Javiñas 0 Dec 5, 2021
Android app which fetches a sample movies list to display. Built using Kotlin and latest Android tech stack, with an approach to clean architecture.

movies-sample-app This is an Android app which fetches a sample movies list to display. Built using Kotlin and latest Android tech stack, with an appr

Nadeem Ahmed 1 Oct 21, 2021
🚀 Sample Android Clean Architecture on Rorty App focused on the scalability, testability and maintainability written in Kotlin, following best practices using Jetpack.

Android Clean Architecture Android Clean Architecture in Rorty is a sample project that presents modern, approach to Android application development u

Mr.Sanchez 0 Dec 28, 2021