π¬
Movie App
πΊ
A movie & TV show exploration app that implements MVVM design pattern by following the clean architecture principles, using TMDB API.
β¨
Features
πΈ
Project Features
- Written in Kotlin
- Implementing MVVM design pattern with Android Architecture Components
- Following clean architecture principles*
- Dependency injection with Hilt
- Consuming a REST API
- Safe API call with Retrofit & Coroutines with the help of
Sealed Class
- Caching API response with
OkHttpClient
- Observing data changes and updating the UI state with
StateFlow
- Lifecycle-aware
RecyclerView
&ViewPager2
adapters with util classes that implementsDefaultLifecycleObserver
- Easing the binding process and handling common operations with base classes (
BaseActivity
,BaseFragment
, andBaseViewModel
) - Handling common view logic with
BindingAdapter
- Infinite scrolling with the help of
RecyclerView.OnScrollListener
(no paging library used) - ViewPager2 auto sliding functionality with the help of
Handler
&Runnable
- Detecting and fixing leaks with LeakCanary
πΉ
App Features
- Browse movies-TV shows through various categories on the Home screen
- Search movies-TV shows-people on the Search screen
- See the details of a movie-TV show-person
- Adjusted background color according to the dominant color of the poster
- Watch trailers directly in the app
- View more details by expanding the Details section
- Navigate to IMDb, Facebook, Instagram, or Twitter page in the browser or own app if installed
- Mark the movie-TV show as favorite by tapping the heart icon
- View favorite movies-TV shows on the Favorites screen
- Offline support (if cached data is available)
βΆ
Demos
Home_Movie-Person.Detail.Screen.mp4
Home_TV.Show-Season-Episode.Detail.Screen.mp4
Search.Screen.mp4
Favorites.Screen.mp4
π
Prerequisite
To build the project successfully, you need to get your TMDB API key and add a new line in the local.properties
file as shown below.
tmdb_api_key=Your_TMDB_API_Key
Do the same with YouTube Data API key.
youtube_api_key=Your_YouTube_Data_API_Key
π
Project Structure
The project separated into three main layers:
- Data
- Presentation
- Domain
πΈ
Data
Data layer contains application data that are fetched from either the network source or the local database.
Consists of four packages:
local
contains Room components to fetch data from the local databasemapper
contains mapping functions to map DTOs(Data Transfer Objects) and database entities to domain modelsremote
contains Retrofit components to fetch data from the network sourcerepository
contains implementations of repository interfaces that are defined in the domain layer
πΈ
Presentation
Presentation layer is responsible for displaying application data on the screen. It contains UI elements that render the data on the screen and ViewModel classes that store and manage data in a lifecycle-conscious way.
Consists of two packages:
adapter
contains RecyclerView & ViewPager2 adapter classesui
contains Activities & Fragments with their corresponding ViewModel classes
πΈ
Domain
Domain layer is the central layer of the project. This layer is a bridge between the data layer and the presentation layer-it retrieves data from the data layer and exposes it to the presentation layer. This layer is independent of other layers-any changes in other layers don't affect this layer.
Consists of three packages:
model
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 UIrepository
contains repository interfaces to abstract the domain layer from the data layerusecase
contains use cases(interactors) that handle the business logic, which are reused by multiple ViewModels
π
Note
This is a learning project. I'm not claiming that this project implements clean architecture immaculately, I'm still in the learning phase. I will update the project as I learn more about clean architecture and realize my mistakes. I'm also open to any kind of advice to make the project's code quality better.
π
Libraries
- Jetpack libraries
- Navigation - Handling navigation between destinations within the app
- 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
- DataStore - Persisting the key-value pairs or typed objects with protocol buffers
- Palette - Extracting prominent colors from images
- 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
- PhotoView - Implementing zoom functionality to ImageView
- ExpandableLayout - Animating the expansion and collapse of its child views
- YouTube Android Player - Playing YouTube video in app
- LeakCanary - Detecting leaks within the app
π±
Try the App
Check out the Releases and download & install the APK file to try the app.
π
License
Copyright (c) 2022 Bora Bor
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.