This is a demo of movie & TV show that implements MVVM design pattern by following the Clean Architecture principles, using TMDB API which is available on Github Public APIs page.
- Minimum SDK level 26 to latest
- Written in Kotlin
- Implementing MVVM design pattern with Android Architecture Components by following clean architecture principles.
- Dependency injection with Hilt
- Consuming a REST API of TMDB API
- Safe API call with Retrofit & Coroutines
- Caching API response with OkHttpClient from medium article
- Observing data changes and updating the UI state with StateFlow
- Handling common view logic with BindingAdapter
- Infinite scrolling with the help of RecyclerView.OnScrollListener (no paging library used)
- Stetho to check API response directly on Brave web browser.
- Used Jetpack Compose in one of the module with Material 3 UI
- Room Database
- Jetpack libraries
- Navigation - Handling navigation between destinations within the app
- Jetpack Compose
- Lifecycle - Handling lifecycles with lifecycle-aware component
- DataBinding - Binding UI components in layouts to data sources using a declarative format
- ViewModel - Storing and managing UI-related data in a lifecycle-conscious way
- Hilt - Injecting dependencies
- Room - Constructing SQLite database more easily
- Kotlin Coroutines - Allowing asynchronous programming with Kotlin
- Retrofit - Interacting with the REST API
- OkHttp - Implementing interceptors
- Gson - Converting JSON to Kotlin data class
- Glide - Loading and caching images
- Glide Transformations - Providing image transformations for Glide
- Glide Compose Image - Loads image directly from compose.
- ExpandableLayout - Animating the expansion and collapse of its child views
- Splash Screen API - New Splash screen API
- Robolectric for Unit testing
- Espresso for UI testing
- Mockito mocking framework for unit tests
- Browse popular and top rated movies/tv shows on the Home page
- Search movies/tv shows on the Search page
- See the details of a movie/tv show
- Watch trailers tiles and navigated to youtube
- You can choose the movie/tv show as favorite by tapping the favourite icon
- View favorite movies/tv shows on the Favorites page
- Offline support (if cached data is available)
- Light and Dark mode support
- androidTest (Instrumentation Tests Espresso and Hilt Test Lib)
- debug (HiltTestActivity for UI tests)
- main
- sharedTest (directory act as bridge between unit and instrumentation tests. It contains files like Fake Hilt Modules, fake Repository, Hilt Test Runner)
- test (Unittest cases Robolectric, Mockito and Hilt)
The project is structured into three distinct layers that have been designed to address concerns related to Separation of Concerns and Testability.
- Data
- Presentation
- Domain
The first layer is the Data layer, which is responsible for managing the application data that is fetched from either the network or the local database.
This layer consists of four packages
local
: The local package comprises the Room components that are used to fetch data from the local database.mapper
: The mapper package contains mapping functions to map the data retrieved from various sources to domain models.remote
: The remote package comprises the Retrofit components used to fetch data from the network source.repository
: The repository package contains the implementations of repository interfaces defined in the domain layer.
The second layer is the Presentation layer, which is responsible for rendering the application data on the screen.
This layer consists of two packages
adapter
: The adapter package contains RecyclerView and ViewPager2 adapter classesui
: The ui package comprises Activities and Fragments with their corresponding ViewModel classes.
The third and central layer of the project is the Domain layer.
This layer acts as a bridge between the data and presentation layers, retrieving data from the former and exposing it to the latter.
The Domain layer is independent of other layers, which means that changes in other layers do not affect it.
The Domain layer consists of three packages
model
: The model package contains data classes that hold the data retrieved from the data layer, to be used later on in the presentation layer to expose it to the UI.repository
: The repository package contains repository interfaces that abstract the domain layer from the data layer.usecase
: The usecase package contains use cases that handle the business logic, which can be reused by multiple ViewModels.
Youtube: https://youtu.be/-HLev0uGmlg
Check out the Releases and download & install the APK file to try the app.