mvi_demo is an Android sample project that demonstrates how to implement an application using the MVI (Model-View-Intent) architecture, Koin for dependency injection, Retrofit with OkHttp and Gson for network communication, and Kotlin Coroutines for asynchronous operations.
-
MVI Architecture
Implements unidirectional data flow by separating UI intents, states, and one-time effects for improved maintainability and testability. -
Dependency Injection with Koin
Uses Koin to manage dependencies across the app, including ViewModels, repositories, adapters, and network services. -
Network Requests
Uses Retrofit and OkHttp to perform API calls. JSON responses are parsed using Gson. The project utilizes suspend functions and a custom API call wrapper (safeApiCall) to handle errors and responses uniformly. -
ViewBinding
Enabled ViewBinding to reduce boilerplate code and improve type safety when accessing views.
-
api/
Contains Retrofit API interfaces and data model classes (e.g.,HttpResponse,CarParkDetailResponse). -
data/
Contains data classes likeCarParkInfoandUserInfo. -
intent/
Defines UI intents, states, and effects as per the MVI design pattern. -
repository/
Implements aBaseRepositorywith a common API call wrapper and concrete repositories (e.g.,CarParkInfoRepository) that handle network requests and error handling. -
viewmodel/
Contains ViewModel classes that use theviewModelScopeto make API calls and update the UI state. -
adapter/
RecyclerView adapters (e.g.,CarParkInfoAdapter) for displaying data in lists. -
koin/
Defines Koin modules (e.g.,networkModule,repositoryModule,viewModelModule,adapterModule) for dependency injection configuration.
- Android Studio (latest stable version recommended)
- Kotlin support and Gradle build system
-
Clone the Repository
git clone https://github.com/ShingHanHuang/MVI_DEMO.git cd mvi_demo