Skip to content

Matthew-R-Rohr/MVVMSampleProject

Repository files navigation

Android SpaceX MVVM Architecture Project

This Android project is using a MVVM (Model-View-ViewModel) architecture, implemented with several different example observer patterns and data storage strategies.

This project is still under development, see the TODO

Introduction

My name is Matthew Rohr, an Android Developer. I recently finished a two year contract working as an Android Developer/Consultant on the Hulu Android mobile app. I have been developing Android projects since 2012.

This GitHub project was created and made public for a couple reasons:

  • Show & Tell for tech/contracting interviews
  • Quick Reference Guide - As a contractor, moving between client Android tech stacks can be dizzying. In my experience, most clients are moving toward MVVM but still differ on how it is implemented. Having a quick reference for interview prep and development is helpful.
  • FLOW/Coroutine Implementation - Been eager to play with this, to get an idea how it compares to RxJava. Loving it so far.

Why Multiple Patterns??

The data layer (observer choices and cache management) is the most complex part of the app. I have worked on numerous Android projects that moved toward MVVM but implemented the actual observer pattern and data storage strategy several different ways. This in part is why I included these as example implementations:

  • Flow using Coroutines with Room DB
  • RxJava with Room DB
  • LiveData with an InMemCache
  • Traditional Callbacks with an InMemCache - transitions into LiveData within the ViewModel to help facilitate the MVVM architecture

App Screenshots

Simple four screen app using the SpaceX Launches api:

welcome screen listing screen details screen debugging screen

Pattern Implementations - Quick Links

Flow
LaunchFlowFragment <-> FlowViewModel <-> FlowRepository <- (SpaceXDatabase || SpaceXApi)

RxJava
LaunchRxJavaFragment <-> RxJavaViewModel <-> RxJavaRepository <- (SpaceXDatabase || SpaceXApi)

LiveData
LaunchLiveDataFragment <-> LiveDataViewModel <-> LiveDataRepository <- (AgedMemoryCache || SpaceXApi)

Callbacks
LaunchCallbackFragment <-> CallBackViewModel <-> CallbackRepository <- (AgedMemoryCache || SpaceXApi)

Technology Stack

  1. MVVM Architecture
  2. Android Jetpack Components
  3. Kotlin & Extensions
  4. ViewModel
  5. RxJava (observer/data pattern example)
  6. LiveData (observer/data pattern example)
  7. Flow (observer/data pattern example)
  8. Traditional Callbacks (pattern example)
  9. Coroutines
  10. ConstraintLayout
  11. InMemory Cache
  12. ROOM Database (disk cache)
  13. Retrofit (for api communications)
  14. Picasso (for images)
  15. SpaceX API (free and easy to use)
  16. MocKK (testing library which is more friendly with Kotlin than Mockito)

//TODO - all the things

Still lots todo on this project

Dependency Injection

Several files in this project are screaming to be Singletons, which I plan to implement with DI.

Last project I worked on used Toothpick for DI, but I personally would like to try Dagger, which appears to be a bit more main stream.

Additional Test Coverage

You can never have enough test coverage:

  • Fragment Scenario Tests
  • Additional Unit Tests
  • Android Instrumentation Tests
Single Activity Architecture

This is fascinating and seems to work well with Androids new Navigation component

About

SpaceX Android MVVM Sample Architecture Project

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages