A project to show the best way to build an Android app on 2022 (by me).

Overview

Hello Architecture

I create this project to show what's for me the best way to build an Android app on 2022.

Architecture

Architecture Diagram
I use this diagram as and idea to build this app because it approaches to famous Clean Architecture (that's what I try to follow). It has 3 layers:

  • Presentation
  • Domain
  • Data

Every layer is complete independent from another, that allow us to test every layer more easy.

I tried to follow this layer independency with package structure too, it looks like this:
Package structure

  • DI: dependency injection, this time I use Koin because everyone was talking about it and I need to try it. Conclusion: I LOVE IT!
  • Repository: to get, save and show every call that user ask.
  • UseCase: every request that UI needs it's translated to an usecase (for example, fetch every user from backend)
  • UI: for all UI classes, as Fragments, Adapters, Activities...

Presentation layer

Starting with the UI part, I tried the "Single Activity Architecture" because I want try it with the new Navigation Component which makes build the app more easy. (You only have to have one Activity and the rest is all Fragments)

I use SafeArgs for avoid NPE and inconsistency with Animations. It's a big jump from the old way.

I use the famous MVVM pattern to build the app, UI layer has his own model, LiveData on ViewModel which are observerd from fragments. I tried to have light fragments which only needs to observe data from ViewModel.

Every time user wants can refresh the user list with a simple swipe (SwipeRefreshLayout) and always show user when something it has been updated, removed, created... (and of course, if something fail, it's displayed to user)

And to prove how easy is to have an adaptable layout and did it in this way. Creating a values integer files different depends on weight if it's more than 600dp:
Values integer files Contain
If it's more thant 600 it has 2 gallery per column, if's not, only 1. And with this code it allows you to show more or less columns:
Code Portrait mode Landscape mode

Domain layer

Where every UseCase live.
I use again Flow to comunicate with viewmodels.
I always create and interface for every usecase to make me testing more easy.

Data

I use Room to save user data (using own model which saves remoteId from backend) with Flow too. I use Retrofit to call backend with suspend functions.

Repository data flow

Repository data flow

  1. Use case ask repository to fecth user data
  2. Repository ask backend to get new data
  3. Remote gives this data to the repo
  4. The repo save this data in local
  5. When data is save in local it's notified repo
  6. Repo inform usecase with new data

Testing

I tested one view model to show how it's possible to test coroutines and I tested every mapper to show how simple is to unit test in Android.

For ViewModel is easy to test the behaviour because you can implement an usecase interface and do whatever you want.

You might also like...
A starter project to build command-line tools in Kotlin Multiplatform
A starter project to build command-line tools in Kotlin Multiplatform

A starter project to build command-line tools in Kotlin Multiplatform Contains a re-implementation of a real world CLI tool: git-standup Installation

📒 NotyKT is a complete 💎Kotlin-stack (Backend + Android) 📱 application built to demonstrate the use of Modern development tools with best practices implementation🦸.
📒 NotyKT is a complete 💎Kotlin-stack (Backend + Android) 📱 application built to demonstrate the use of Modern development tools with best practices implementation🦸.

NotyKT 🖊️ NotyKT is the complete Kotlin-stack note taking 🖊️ application 📱 built to demonstrate a use of Kotlin programming language in server-side

📚  Sample Android Components Architecture on a modular word focused on the scalability, testability and maintainability written in Kotlin, following best practices using Jetpack.
📚 Sample Android Components Architecture on a modular word focused on the scalability, testability and maintainability written in Kotlin, following best practices using Jetpack.

Android Components Architecture in a Modular Word Android Components Architecture in a Modular Word is a sample project that presents modern, 2020 app

A complete Kotlin application built to demonstrate the use of Modern development tools with best practices implementation using multi-module architecture developed using SOLID principles
A complete Kotlin application built to demonstrate the use of Modern development tools with best practices implementation using multi-module architecture developed using SOLID principles

This repository serves as template and demo for building android applications for scale. It is suited for large teams where individuals can work independently on feature wise and layer wise reducing the dependency on each other.

If you had one month to visit the best places in Kenya, where would you go?
If you had one month to visit the best places in Kenya, where would you go?

VisitKenya If you had one month to visit the best places in Kenya, where would you go? This app just shows you sample places where you could visit, wi

Use Android Jetpack libraries, Android Architecture Components, ViewModel and LiveData to build this app.

Unscramble App Starter code for Android Basics codelab - Store the data in a ViewModel Unscramble is a single player game app that displays scrambled

Build with Jetpack Compose & all modern techniques and architecture of android app development
Build with Jetpack Compose & all modern techniques and architecture of android app development

IMDB Movie App Build with Jetpack Compose & all modern techniques and architecture of android app development ScreenShots 🛠 Built With 🛠 Kotlin - Fi

Owner
Martín Fernández
I am a Software Engineer that likes to investigate new technologies and try them out. #kotlin #android #java #spring #javascript #nodejs
Martín Fernández
OO Boot Camp reference implementation for Jordanian client in Kotlin in January 2022

oo_boot_camp_2022-01-24_kotlin Copyright (c) 2022 by Fred George May be used fre

Fred George 0 Mar 6, 2022
Programación - 02 Programación Estructurada y Modular. 1DAM. Curso 2022-2023

Programación - 02 Programación Estructurada y Modular Tema 02 Programación Estructurada y Modular. 1DAM. Curso 2022/2023. Programación - 02 Programaci

José Luis González Sánchez 31 Dec 29, 2022
Guía de supervivencia de Kotlin para 2º DAM. Curso 2022/2023

Kotlin Supervivencia para 2º DAM Ejemplos de la supervivencia en Kotlin para 2º DAM. Curso 2022/2023. Kotlin Supervivencia para 2º DAM 1. Programación

José Luis González Sánchez 27 Dec 28, 2022
Programación - 04 Programación Orientada a Objetos. 1DAM. Curso 2022-2023

Programación - 04 Programación Orientada a Objetos Tema 04 Programación Orientada a Objetos. 1DAM. Curso 2022/2023. Programación - 04 Programación Ori

José Luis González Sánchez 13 Dec 27, 2022
Acceso a Datos - 03 Bases de Datos Relacionales. 2DAM. Curso 2022-2023

Acceso a Datos - 03 Bases de Datos Relacionales Tema 03 Bases de Datos Relacionales. 2DAM. Curso 2022/2023. Contenidos Bases de datos Relacionales El

José Luis González Sánchez 15 Jan 11, 2023
A project that showcases best practices for MAD (Modern Android Development).

MAD Dictionary Is this dictionary mad? Well yes, but actually no. MAD = Modern Android Development, this app is built using the very new and very awes

Abhishek Choudhary 11 Mar 12, 2022
App with plant list 🌱 , the app reminds you when to water 💦 your best plant at a certain time.

Plant Life App with plant list ?? , the app reminds you when to water ?? your best plant at a certain time.. Table of Contents Introduction Features U

Haya Saud Alrawdhan 0 Jan 6, 2022
An Android template you can use to build your project with gradle kotlin dsl

Android Gradle KTS An Android template you can use to build your project with gradle kotlin dsl Build.gradle.kts You can use your project's build.grad

Deep 17 Sep 12, 2022
This is a Ktor project to build your own Url shortener

Ktor URL Shortner This project is a implementation for creating Short URL using Ktor + Kotlin + MongoDB Usage It contains two routes if you want to im

Himanshu Singh 25 Dec 15, 2022
Project build to understand the concepts of Git and GitHub

Project build to understand the concepts of Git and GitHub. Summarizing the concepts learnt. Created a project in Android Studio Before installing And

Rifah A Khan 0 Oct 6, 2021