← all projects

learn this topic (theory + diagrams) →

Learn-Kotlin-Coroutines

Learn-by-example Android project teaching Kotlin Coroutines through runnable network, Room, timeout, and error-handling examples.

View on GitHub ↗Kotlinupdated 2d ago

KotlinCoroutinesRetrofitRoomMVVM

High-level design

A teaching app structured as a menu of self-contained examples — each concept is an Activity + ViewModel pair you can open, read, and run in isolation, so theory is always backed by a runnable screen.

data/api

Retrofit ApiHelper, ApiService, RetrofitBuilder for network examples

data/local

Room AppDatabase, UserDao, DatabaseHelper for the DB example

ui/retrofit

single, series, and parallel network calls

ui/task

one and two long-running background tasks

ui/timeout

withTimeout — cancelling a task past a deadline

ui/errorhandling

try/catch, CoroutineExceptionHandler, supervisorScope

ui/base

shared UiState, adapters, and a ViewModelFactory

Low-level design

The teaching thesis: series vs parallel is the same operation with a different structure — and the repo makes you read both.

  • Series calls = withContext back-to-back; parallel = async + awaitAll — the example index links both side by side
  • Every ViewModel exposes a sealed UiState (Loading / Success / Error) so the UI can't render an invalid state
  • supervisorScope example shows one failing child not killing its siblings — the exception model in a runnable form