All Projects → catalinghita8 → Android Mvvm Rxjava2 Dagger2

catalinghita8 / Android Mvvm Rxjava2 Dagger2

This repository contains a detailed sample application that uses MVVM as its presentation layer pattern. Essential dependencies are Dagger2 with Dagger-android, RxJava2 with RxAndroid, Room, Retrofit and Espresso.

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Android Mvvm Rxjava2 Dagger2

Android App Architecture Mvvm Databinding
A simple but complete project (in both Java & Kotlin) to demonstrate the Android application architecture with MVVM pattern, a client app for The Movie DB Web API. Dagger2 is used for dependency injection and RxJava is used for RFP (Reactive Functional Programming).
Stars: ✭ 69 (+38%)
Mutual labels:  rxjava2, dagger2, dependency-injection, android-development, room-persistence-library
Android Audiorecorder App
Android application to record audio. RxJava2, Dagger2, MVP, RoomDb.
Stars: ✭ 180 (+260%)
Mutual labels:  rxjava2, dagger2, room-persistence-library
Fountain
Android Kotlin paged endpoints made easy
Stars: ✭ 175 (+250%)
Mutual labels:  rxjava2, dagger2, room-persistence-library
Instant Weather
An Android weather application implemented using the MVVM pattern, Retrofit2, Dagger2, LiveData, ViewModel, Coroutines, Room, Navigation Components, Data Binding and some other libraries from the Android Jetpack.
Stars: ✭ 473 (+846%)
Mutual labels:  dagger2, dependency-injection, room-persistence-library
Kotlin Android Scaffolding
An android project structure using kotlin and most common libraries.
Stars: ✭ 53 (+6%)
Mutual labels:  rxjava2, dagger2, android-development
Dagger2
Kotlin Dagger2 example project
Stars: ✭ 145 (+190%)
Mutual labels:  rxjava2, dagger2, dependency-injection
Base Mvvm
App built to showcase basic Android View components like ViewPager, RecyclerView(homogeneous and heterogeneous items), NavigationDrawer, Animated Vector Drawables, Collapsing Toolbar Layout etc. housed in a MVVM architecture
Stars: ✭ 18 (-64%)
Mutual labels:  rxjava2, dagger2, room-persistence-library
Kuroba Experimental
Free and open source image board browser
Stars: ✭ 76 (+52%)
Mutual labels:  rxjava2, dagger2, room-persistence-library
android-template
Template for android development at Tiki
Stars: ✭ 17 (-66%)
Mutual labels:  dependency-injection, dagger2, rxjava2
Cucumber
A recipe finding app written in Kotlin with MVP architecture
Stars: ✭ 64 (+28%)
Mutual labels:  dagger2, rxjava2, room-persistence-library
Weather-Guru-MVP
Sample Material-design Android weather application build with MVP architectural approach using Dagger2, RxJava2, Retrofit2, Event-Bus, GreenDao, Butterknife, Lottie etc.
Stars: ✭ 15 (-70%)
Mutual labels:  android-development, dagger2, rxjava2
Kata-Dagger2-Android
Kata to practice Dependency injection using Dagger 2.
Stars: ✭ 21 (-58%)
Mutual labels:  dependency-injection, android-development, dagger2
idreminder
Simple reminder app build with Kotlin + Clean Architecture + RxJava + Dagger2 + MVP + Room
Stars: ✭ 29 (-42%)
Mutual labels:  dagger2, rxjava2, room-persistence-library
InstantAppStarter
Starter Project Structure for Android Instant app. https://blog.mindorks.com/android-mvp-architecture-with-instant-app-support-11ba48241a82
Stars: ✭ 44 (-12%)
Mutual labels:  android-development, dagger2, rxjava2
BESTV
Android TV App powered by TMDb. It is a easy way to find the best TV content, the top movies, series... all of that in your TV.
Stars: ✭ 49 (-2%)
Mutual labels:  dependency-injection, dagger2, rxjava2
android-online-course
Android Online Course
Stars: ✭ 22 (-56%)
Mutual labels:  android-development, dagger2, rxjava2
Changedetection
Automatically track websites changes on Android in background.
Stars: ✭ 563 (+1026%)
Mutual labels:  dagger2, room-persistence-library
Bailan
基于retorfit2,Rxjva2,Okhttp3,Glide,Dagger2,GreenDAO等框架采用MVP架构的仿应用商店App
Stars: ✭ 542 (+984%)
Mutual labels:  rxjava2, dagger2
Theatre
Pet project using Clean Architecture + MVVM + Reactive Extensions + Android Architecture Components. The data are fetched from LondonTheatreDirect API. 🎭
Stars: ✭ 577 (+1054%)
Mutual labels:  rxjava2, dagger2
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 (+1130%)
Mutual labels:  rxjava2, dagger2

Android-MVVM-RxJava2-Dagger2

This repository contains a detailed sample application that uses MVVM as its presentation layer pattern. The app aims to be extremely flexible to creating variants for automated and manual testing. Also, the project implements and follows the guidelines presented in Google Sample MVVM+RXJAVA-android.

Essential dependencies are Dagger2 with Dagger-android, RxJava2 with RxAndroid, Room, Retrofit and Espresso. Other noteworthy dependencies would be Mockito, Chrome CustomTabs and Guava.

App Demo

This app displays latest earthquakes from all around the world. A number of quakes is fetched realtime upon request. If offline, the app displays the most recent loaded quakes.

content content content

Presentation Layer

MVVM pattern is integrated to facilitate testing and to allow separating the user interface logic from business logic.

As Views were passive in MVP, here the View layer is much more flexibile as an indefinite number of Views can bind to a ViewModel. Also, MVVM enforces a clear separation between Views and their master - ViewModel, as the latter holds no reference to Views. The model layer is completely isolated and centralized through the repository pattern.

Presentation

Model Layer

The model layer is structured on repository pattern so that the ViewModel has no clue on the origins of the data.

The repository handles data interactions and transactions from two main data sources - local and remote:

  • QuakesRemoteDataSource defined by a REST API consumed with Retrofit
  • QuakesLocalDataSource defined by a SQL database consumed with Room

There are two main use-cases, online and offline. In both use cases, QuakesLocalDataSource has priority. In the online use-case if the local data is stale, new data is fetched from the NewsRemoteDataSource and the repository data is refreshed. In case of no internet connection, QuakesLocalDataSource is always queried.

Decoupling is also inforced within the Model layer (entirely consisted by QuakesRepository). Therefore, lower level components (which are the data sources: QuakesRemoteDataSource and QuakesLocalDatasource) are decoupled through QuakesDataSource interface. Also, through their dependence on the same interface, these data sources are interchangeable.

In this manner, the project respects the DIP (Dependency Inversion Principle) as both low and high level modules depend on abstractions.

Reactive approach

It is extremely important to note that this project is not essentially a reactive app as it is not capitalizing the enormous potential of a fully reactive approach. Nevertheless, the app was intended to have a flexible and efficient testing capability, rather than a fully reactive build.

Even in this case, we are able to notice RxJava's benefits when data is being retrieved from the repository through different sources and then is channeled through the ViewModel and finally consumed in Views.

  • Data Flow is centralized.
  • Threading is much easier, with no need for the dreaded AsyncTasks.
  • Error handling is straightforward and comfortable.

Dependency Injection

Dagger2 is used to externalize the creation of dependencies from the classes that use them. Android specific helpers are provided by Dagger-Android and the most significant advantage is that they generate a subcomponent for each Activity through a new code generator. Such subcomponent is:

@ActivityScoped
@ContributesAndroidInjector(modules = QuakesModule.class)
abstract QuakesActivity quakesActivity(); 

The below diagram illustrates the most significant relations between components and modules. An important note is the fact that the ViewModel is now @AppScoped whereas in MVP the Presenter is @ActivityScoped - this is mainly due to the fact that in MVVM the ViewModel is a Android Architecture Component so therefore has a greater scope than Views. You can also get a quick glance on how annotations help us define custom Scopes in order to properly handle classes instantiation. Dependecy Note: The above diagram might help you understand how Dagger-android works. Also, only essential components/modules/objects are included here, this is suggested by the "…"

Testing

The apps' components are extremely easy to test due to DI achieved through Dagger and the project's structure, but as well for the reason that the data flow is centralized with RxJava which results in highly testable pieces of code.

Unit tests are conducted with the help of Mockito and Instrumentation tests with the help of Espresso.

Strong points

  • Decoupling level is high.
  • Data Flow is centralized through RxJava.
  • Possess high flexibility to create variants for automated and manual testing.
  • Possess lightweight structure due to MVVM presentation pattern.
  • Is scalable and easy to expand.

Weak points

  • Possess high code base - simpler approaches will certainly lower code size
  • Possess medium complexity - other approaches might lower complexity and increase efficiency.

Final notes:

  • The app is not a polished ready-to-publish product, it acts as a boilerplate project or as a starting point for android enthusiasts out there.
  • Using this project as your starting point and expanding it is also encouraged, as at this point it is very easy to add new modules.
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].