├── .gitignore
├── .idea
├── .gitignore
├── compiler.xml
├── gradle.xml
├── jarRepositories.xml
├── misc.xml
└── vcs.xml
├── README.md
├── app
├── .gitignore
├── build.gradle.kts
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── kl3jvi
│ │ └── mvvm_template
│ │ └── ExampleInstrumentedTest.kt
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── kl3jvi
│ │ │ └── mvvm_template
│ │ │ ├── application
│ │ │ └── MovieApplication.kt
│ │ │ └── presentation
│ │ │ └── NavigationActivity.kt
│ └── res
│ │ ├── drawable-v24
│ │ └── ic_launcher_foreground.xml
│ │ ├── drawable
│ │ ├── bottom_nav_colors.xml
│ │ ├── ic_launcher_background.xml
│ │ ├── ic_round_dashboard.xml
│ │ └── ic_round_favorite.xml
│ │ ├── layout
│ │ ├── activity_main.xml
│ │ └── view_toolbar.xml
│ │ ├── menu
│ │ └── bottom_nav_menu.xml
│ │ ├── mipmap-anydpi-v26
│ │ ├── ic_launcher.xml
│ │ └── ic_launcher_round.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── navigation
│ │ └── app_nav_graph.xml
│ │ ├── values-night
│ │ └── themes.xml
│ │ └── values
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── themes.xml
│ └── test
│ └── java
│ └── com
│ └── kl3jvi
│ └── mvvm_template
│ └── ExampleUnitTest.kt
├── assets
├── Screenshot_20220318_171359.png
└── header.png
├── build.gradle.kts
├── buildSrc
├── build.gradle.kts
└── src
│ └── main
│ └── kotlin
│ ├── Dependencies.kt
│ └── Versions.kt
├── feature_favorites
├── .gitignore
├── build.gradle.kts
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── kl3jvi
│ │ └── feature_favorites
│ │ └── ExampleInstrumentedTest.kt
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── kl3jvi
│ │ │ └── feature_favorites
│ │ │ └── presentation
│ │ │ └── favorites
│ │ │ ├── FavoritesFragment.kt
│ │ │ ├── FavoritesViewModel.kt
│ │ │ └── common
│ │ │ └── FragmentViewBinding.kt
│ └── res
│ │ ├── layout
│ │ └── favorites_fragment.xml
│ │ └── navigation
│ │ └── feature_fav_nav_graph.xml
│ └── test
│ └── java
│ └── com
│ └── kl3jvi
│ └── feature_favorites
│ └── ExampleUnitTest.kt
├── feature_home
├── .gitignore
├── build.gradle.kts
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── kl3jvi
│ │ └── feature_home
│ │ └── ExampleInstrumentedTest.kt
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── kl3jvi
│ │ │ └── feature_home
│ │ │ ├── common
│ │ │ ├── FragmentViewBinding.kt
│ │ │ └── ViewBindings.kt
│ │ │ ├── di
│ │ │ └── ViewModelModule.kt
│ │ │ └── presentation
│ │ │ ├── adpater
│ │ │ ├── BaseAdapter.kt
│ │ │ ├── BaseViewHolder.kt
│ │ │ ├── DiffUtil.kt
│ │ │ └── TestAdapter.kt
│ │ │ ├── details
│ │ │ ├── DetailsFragment.kt
│ │ │ └── DetailsViewModel.kt
│ │ │ └── home
│ │ │ ├── HomeFragment.kt
│ │ │ └── HomeViewModel.kt
│ └── res
│ │ ├── layout
│ │ ├── details_fragment.xml
│ │ ├── home_fragment.xml
│ │ └── item_movie_large.xml
│ │ ├── navigation
│ │ └── feature_home_nav_graph.xml
│ │ └── values
│ │ └── strings.xml
│ └── test
│ └── java
│ └── com
│ └── kl3jvi
│ └── feature_home
│ └── ExampleUnitTest.kt
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── libraries
├── core
│ ├── .gitignore
│ ├── build.gradle.kts
│ ├── consumer-rules.pro
│ ├── proguard-rules.pro
│ └── src
│ │ ├── androidTest
│ │ └── java
│ │ │ └── com
│ │ │ └── kl3jvi
│ │ │ └── core
│ │ │ └── ExampleInstrumentedTest.kt
│ │ ├── main
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ │ └── com
│ │ │ └── kl3jvi
│ │ │ └── core
│ │ │ └── utils
│ │ │ ├── Resource.kt
│ │ │ └── Utils.kt
│ │ └── test
│ │ └── java
│ │ └── com
│ │ └── kl3jvi
│ │ └── core
│ │ └── ExampleUnitTest.kt
├── data-api
│ ├── .gitignore
│ ├── build.gradle.kts
│ ├── consumer-rules.pro
│ ├── proguard-rules.pro
│ └── src
│ │ ├── androidTest
│ │ └── java
│ │ │ └── com
│ │ │ └── kl3jvi
│ │ │ └── data_api
│ │ │ └── ExampleInstrumentedTest.kt
│ │ ├── main
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ │ └── com
│ │ │ └── kl3jvi
│ │ │ └── data_api
│ │ │ ├── MovieService.kt
│ │ │ ├── data
│ │ │ └── remote
│ │ │ │ ├── ApiInterceptor.kt
│ │ │ │ └── MoviesRemoteSourceImpl.kt
│ │ │ ├── di
│ │ │ ├── ApiModule.kt
│ │ │ └── NetworkModule.kt
│ │ │ ├── mapper
│ │ │ └── MovieListResponseToRepositoryModelMapperImpl.kt
│ │ │ └── model
│ │ │ ├── ImageApi.kt
│ │ │ ├── MovieResponse.kt
│ │ │ └── TmdbApiResponse.kt
│ │ └── test
│ │ └── java
│ │ └── com
│ │ └── kl3jvi
│ │ └── data_api
│ │ └── ExampleUnitTest.kt
├── data
│ ├── .gitignore
│ ├── build.gradle.kts
│ ├── consumer-rules.pro
│ ├── proguard-rules.pro
│ └── src
│ │ ├── androidTest
│ │ └── java
│ │ │ └── com
│ │ │ └── kl3jvi
│ │ │ └── data
│ │ │ └── ExampleInstrumentedTest.kt
│ │ ├── main
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ │ └── com
│ │ │ └── kl3jvi
│ │ │ └── data
│ │ │ ├── MoviesRemoteSource.kt
│ │ │ ├── di
│ │ │ └── DataModule.kt
│ │ │ ├── mapper
│ │ │ └── MovieListResponseToDomainModelMapperImpl.kt
│ │ │ ├── model
│ │ │ └── MovieListRepositoryModel.kt
│ │ │ └── repository
│ │ │ └── MoviesRepositoryImpl.kt
│ │ └── test
│ │ └── java
│ │ └── com
│ │ └── kl3jvi
│ │ └── data
│ │ └── ExampleUnitTest.kt
└── domain
│ ├── .gitignore
│ ├── build.gradle.kts
│ ├── consumer-rules.pro
│ ├── proguard-rules.pro
│ └── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── kl3jvi
│ │ └── domain
│ │ └── ExampleInstrumentedTest.kt
│ ├── main
│ ├── AndroidManifest.xml
│ └── java
│ │ └── com
│ │ └── kl3jvi
│ │ └── domain
│ │ ├── MoviesRepository.kt
│ │ ├── common
│ │ └── Utils.kt
│ │ ├── di
│ │ └── DomainModule.kt
│ │ ├── model
│ │ └── MovieListDomainModel.kt
│ │ ├── uistate
│ │ └── State.kt
│ │ └── usecase
│ │ └── GetMoviesList.kt
│ └── test
│ └── java
│ └── com
│ └── kl3jvi
│ └── domain
│ └── ExampleUnitTest.kt
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | # Gradle files
2 | .gradle/
3 | build/
4 | buildSrc/build
5 |
6 | # Local configuration file (sdk path, etc)
7 | local.properties
8 |
9 | # Log/OS Files
10 | *.log
11 |
12 | # Android Studio generated files and folders
13 | captures/
14 | .externalNativeBuild/
15 | .cxx/
16 | *.apk
17 | output.json
18 |
19 | # IntelliJ
20 | *.iml
21 | .idea/
22 | misc.xml
23 | deploymentTargetDropDown.xml
24 | render.experimental.xml
25 |
26 | # Keystore files
27 | *.jks
28 | *.keystore
29 |
30 | # Google Services (e.g. APIs or Firebase)
31 | google-services.json
32 |
33 | # Android Profiling
34 | *.hprof
--------------------------------------------------------------------------------
/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
27 |
28 |
--------------------------------------------------------------------------------
/.idea/jarRepositories.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | 
2 |
3 | [](https://kotlinlang.org)
4 | [](https://developer.android.com/studio/releases/gradle-plugin)
5 | [](https://gradle.org)
6 |
7 | This is a sample project that presents a modern approach to [Android](https://en.wikipedia.org/wiki/Android_(operating_system)) application development.
8 |
9 | The goal of the project is to combine popular libraries/tools and demonstrate best developement practices by utilizing up to date tech-stack and presenting modern Android application [Architecture](#architecture) that is modular, scalable, maintainable, and testable. This application may look simple,
10 | but it has all the pieces that will provide the rock-solid foundation for the larger app suitable for bigger teams
11 | and long [application lifecycle](https://en.wikipedia.org/wiki/Application_lifecycle_management).
12 |
13 | This project is being maintained to match industry standards.
14 |
15 | ## Project characteristics and tech-stack
16 |
17 |
18 |
19 | This project takes advantage of best practices, many popular libraries and tools in the Android ecosystem. Most of the libraries are in the stable version unless there is a good reason to use non-stable dependency.
20 |
21 | * Tech-stack
22 | * [100% Kotlin](https://kotlinlang.org/) + [Coroutines](https://kotlinlang.org/docs/reference/coroutines-overview.html) - perform background operations
23 | * [Retrofit](https://square.github.io/retrofit/) - networking
24 | * [Jetpack](https://developer.android.com/jetpack)
25 | * [Navigation](https://developer.android.com/topic/libraries/architecture/navigation/) - in-app navigation
26 | * [LiveData](https://developer.android.com/topic/libraries/architecture/livedata) - notify views about database change
27 | * [Lifecycle](https://developer.android.com/topic/libraries/architecture/lifecycle) - perform an action when lifecycle state changes
28 | * [ViewModel](https://developer.android.com/topic/libraries/architecture/viewmodel) - store and manage UI-related data in a lifecycle conscious way
29 | * [Room](https://developer.android.com/jetpack/androidx/releases/room) - store offline cache
30 | * [Koin](https://insert-koin.io/) - dependency injection
31 | * [Coil](https://github.com/coil-kt/coil) - image loading library
32 | * [Lottie](http://airbnb.io/lottie) - animation library
33 | * [Stetho](http://facebook.github.io/stetho/) - application debugging
34 | * Modern Architecture
35 | * Clean Architecture (at feature module level)
36 | * Single activity architecture using [Navigation component](https://developer.android.com/guide/navigation/navigation-getting-started)
37 | * MVVM + MVI (presentation layer)
38 | * [Dynamic feature modules](https://developer.android.com/studio/projects/dynamic-delivery)
39 | * [Android Architecture components](https://developer.android.com/topic/libraries/architecture) ([ViewModel](https://developer.android.com/topic/libraries/architecture/viewmodel), [LiveData](https://developer.android.com/topic/libraries/architecture/livedata), [Navigation](https://developer.android.com/jetpack/androidx/releases/navigation))
40 | * [Android KTX](https://developer.android.com/kotlin/ktx) - Jetpack Kotlin extensions
41 | * CI
42 | * [GitHub Actions](https://github.com/features/actions)
43 | * Automatic PR verification including tests, linters and 3rd online tools
44 | * Testing
45 | * [Unit Tests](https://en.wikipedia.org/wiki/Unit_testing) ([JUnit 5](https://junit.org/junit5/) via
46 | [android-junit5](https://github.com/mannodermaus/android-junit5))
47 | * [UT Tests](https://en.wikipedia.org/wiki/Graphical_user_interface_testing) ([Espresso](https://developer.android.com/training/testing/espresso))
48 | * [Mockk](https://mockk.io/) - mocking framework
49 | * [Kluent](https://github.com/MarkusAmshove/Kluent) - assertion framework
50 | * UI
51 | * [Material design](https://material.io/design)
52 | * Reactive UI
53 | * Static analysis tools
54 | * [Ktlint](https://github.com/pinterest/ktlint) - validate code formating
55 | * [Detekt](https://github.com/arturbosch/detekt#with-gradle) - verify complexity look for and code smell
56 | * Gradle
57 | * [Gradle Kotlin DSL](https://docs.gradle.org/current/userguide/kotlin_dsl.html)
58 | * Custom tasks
59 | * Plugins ([SafeArgs](https://developer.android.com/guide/navigation/navigation-pass-data#Safe-args),
60 | [android-junit5](https://github.com/mannodermaus/android-junit5))
61 | * [Dependency locks](https://docs.gradle.org/current/userguide/dependency_locking.html)
62 | * [Versions catalog](https://docs.gradle.org/7.0-milestone-1/userguide/platforms.html)
63 |
64 | ## Architecture
65 |
66 | Feature related code is placed inside one of the feature modules.
67 | We can think about each feature as the reusable component, equivalent of [microservice](https://en.wikipedia.org/wiki/Microservices) or private library.
68 |
69 | The modularized code-base approach provides few benefits:
70 | - better [separation of concerns](https://en.wikipedia.org/wiki/Separation_of_concerns). Each module has a clear API., Feature related classes live in different modules and can't be referenced without explicit module dependency.
71 | - features can be developed in parallel eg. by different teams
72 | - each feature can be developed in isolation, independently from other features
73 | - faster compile time
74 |
75 | ## Package Structures
76 |
77 | ```
78 | com.kl3jvi.mvvm_template # Root Package
79 | ├─ app
80 | ├─ buildSrc
81 | ├─ feature_home
82 | └──feature_favorites
83 | ```
84 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/app/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | id(ANDROID_APPLICATION_PLUGIN)
3 | id(KOTLIN_ANDROID_PLUGIN)
4 | id(KOTLIN_KAPT_PLUGIN)
5 | id(NAVIGATION_SAFE_ARGS)
6 | }
7 |
8 |
9 | importCommonDependencies()
10 |
11 | android {
12 | defaultConfig {
13 | applicationId = Versions.App.id
14 | compileSdk = Versions.Android.sdk
15 | minSdk = Versions.Android.minSdk
16 | targetSdk = Versions.Android.sdk
17 | versionCode = Versions.App.versionCode
18 | versionName = Versions.App.versionName
19 | testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
20 |
21 | // TODO Scheme is created in data module but with which one, find out
22 | javaCompileOptions {
23 | annotationProcessorOptions {
24 | arguments["room.schemaLocation"] = "$projectDir/schemas"
25 | }
26 | }
27 | }
28 |
29 | buildTypes {
30 | getByName("release") {
31 | isMinifyEnabled = false
32 | proguardFiles(
33 | getDefaultProguardFile("proguard-android-optimize.txt"),
34 | "proguard-rules.pro"
35 | )
36 | }
37 | }
38 |
39 | dynamicFeatures.apply {
40 | add(Dependencies.DynamicFeature.FEATURE_HOME)
41 | add(Dependencies.DynamicFeature.FEATURE_FAVORITES)
42 | }
43 |
44 |
45 | buildFeatures {
46 | dataBinding = true
47 | viewBinding = true
48 | }
49 |
50 | compileOptions {
51 | sourceCompatibility = JavaVersion.VERSION_1_8
52 | targetCompatibility = JavaVersion.VERSION_1_8
53 | }
54 |
55 | }
56 |
57 |
58 |
59 | dependencies {
60 |
61 | implementation(Dependencies.dynamicFeaturePlugin)
62 | implementation(Dependencies.coil)
63 |
64 | implementation(project(Dependencies.AndroidLibrary.CORE))
65 | implementation(project(Dependencies.AndroidLibrary.DATA_API))
66 | implementation(project(Dependencies.AndroidLibrary.DOMAIN))
67 | implementation(project(Dependencies.AndroidLibrary.DATA))
68 |
69 |
70 | // implementation(project(Dependencies.DynamicFeature.FEATURE_HOME))
71 | // implementation(project(Dependencies.DynamicFeature.FEATURE_FAVORITES))
72 |
73 | implementation(Dependencies.Room.runtime)
74 | implementation(Dependencies.Room.ktx)
75 | "kapt"(Dependencies.Room.annotation)
76 |
77 |
78 | implementation(Dependencies.okhttp)
79 | implementation(Dependencies.okhttpLogging)
80 | implementation(Dependencies.Retrofit.core)
81 | implementation(Dependencies.Retrofit.moshiConverter)
82 |
83 | implementation(Dependencies.Koin.koin)
84 |
85 |
86 | implementation(Dependencies.Moshi.moshi)
87 | "kapt"(Dependencies.Moshi.moshiKapt)
88 |
89 | api(Dependencies.Navigation.navUi)
90 | api(Dependencies.Navigation.navRuntime)
91 | api(Dependencies.Navigation.navFragment)
92 | }
93 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.kts.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/kl3jvi/mvvm_template/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.kl3jvi.mvvm_template
2 |
3 | import androidx.test.platform.app.InstrumentationRegistry
4 | import androidx.test.ext.junit.runners.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * See [testing documentation](http://d.android.com/tools/testing).
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22 | assertEquals("com.kl3jvi.mvvm_template", appContext.packageName)
23 | }
24 | }
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
17 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/app/src/main/java/com/kl3jvi/mvvm_template/application/MovieApplication.kt:
--------------------------------------------------------------------------------
1 | package com.kl3jvi.mvvm_template.application
2 |
3 | import android.app.Application
4 | import com.kl3jvi.data.di.dataModule
5 | import com.kl3jvi.data_api.di.apiModule
6 | import com.kl3jvi.data_api.di.networkModule
7 | import com.kl3jvi.domain.di.domainModule
8 |
9 | import org.koin.android.ext.koin.androidContext
10 | import org.koin.android.ext.koin.androidLogger
11 | import org.koin.core.context.GlobalContext.startKoin
12 |
13 |
14 | class MovieApplication : Application() {
15 | override fun onCreate() {
16 | super.onCreate()
17 | startKoin {
18 | androidLogger()
19 | androidContext(this@MovieApplication)
20 | modules(
21 | apiModule,
22 | networkModule,
23 | domainModule,
24 | dataModule,
25 | )
26 | }
27 | }
28 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/kl3jvi/mvvm_template/presentation/NavigationActivity.kt:
--------------------------------------------------------------------------------
1 | package com.kl3jvi.mvvm_template.presentation
2 |
3 | import android.os.Bundle
4 | import androidx.appcompat.app.AppCompatActivity
5 | import androidx.navigation.NavController
6 | import androidx.navigation.findNavController
7 | import androidx.navigation.ui.setupWithNavController
8 | import com.google.android.material.bottomnavigation.BottomNavigationView
9 | import com.kl3jvi.mvvm_template.R
10 | import com.kl3jvi.mvvm_template.databinding.ActivityMainBinding
11 |
12 |
13 | class NavigationActivity : AppCompatActivity() {
14 |
15 | private lateinit var binding: ActivityMainBinding
16 | private lateinit var navController: NavController
17 |
18 | override fun onCreate(savedInstanceState: Bundle?) {
19 | super.onCreate(savedInstanceState)
20 | binding = ActivityMainBinding.inflate(layoutInflater)
21 | setContentView(binding.root)
22 |
23 | val navView: BottomNavigationView = binding.bottomNav
24 | navController = findNavController(R.id.navHostFragment)
25 | navView.setupWithNavController(navController)
26 | }
27 | }
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
15 |
18 |
21 |
22 |
23 |
24 |
30 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/bottom_nav_colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_round_dashboard.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_round_favorite.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
21 |
22 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/view_toolbar.xml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/bottom_nav_menu.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kl3jvi/clean_modularized/d1372621118173f39c44cae483e9e9c7a90683c1/app/src/main/res/mipmap-hdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kl3jvi/clean_modularized/d1372621118173f39c44cae483e9e9c7a90683c1/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kl3jvi/clean_modularized/d1372621118173f39c44cae483e9e9c7a90683c1/app/src/main/res/mipmap-mdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kl3jvi/clean_modularized/d1372621118173f39c44cae483e9e9c7a90683c1/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kl3jvi/clean_modularized/d1372621118173f39c44cae483e9e9c7a90683c1/app/src/main/res/mipmap-xhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kl3jvi/clean_modularized/d1372621118173f39c44cae483e9e9c7a90683c1/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kl3jvi/clean_modularized/d1372621118173f39c44cae483e9e9c7a90683c1/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kl3jvi/clean_modularized/d1372621118173f39c44cae483e9e9c7a90683c1/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kl3jvi/clean_modularized/d1372621118173f39c44cae483e9e9c7a90683c1/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kl3jvi/clean_modularized/d1372621118173f39c44cae483e9e9c7a90683c1/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/navigation/app_nav_graph.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
11 |
12 |
16 |
--------------------------------------------------------------------------------
/app/src/main/res/values-night/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
16 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #121e2d
4 | #121e2d
5 | #121e2d
6 |
7 | #3bdeee
8 | #FF018786
9 |
10 | #FF000000
11 | #FFFFFFFF
12 |
13 | #17293F
14 | #FFC42E
15 | #A7A7A9
16 |
17 | #293E58
18 | #293E58
19 | @color/colorPrimary
20 | @color/darkBlue
21 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 32dp
4 | 20dp
5 | 16dp
6 | 12dp
7 | 8dp
8 | 4dp
9 |
10 | 24sp
11 | 20sp
12 | 18sp
13 | 16sp
14 | 14sp
15 | 12sp
16 |
17 | @dimen/size_16
18 | @dimen/size_8
19 | @dimen/size_4
20 | @dimen/size_20
21 | 160dp
22 | 290dp
23 |
24 | 48dp
25 | 36dp
26 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | MVVM Template
3 | Home
4 | Favorites
5 | Favorites
6 | feature home
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/values/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
21 |
22 |
28 |
29 |
32 |
33 |
38 |
39 |
45 |
46 |
49 |
50 |
56 |
57 |
58 |
62 |
63 |
66 |
67 |
71 |
72 |
76 |
77 |
81 |
82 |
86 |
87 |
88 |
--------------------------------------------------------------------------------
/app/src/test/java/com/kl3jvi/mvvm_template/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.kl3jvi.mvvm_template
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * See [testing documentation](http://d.android.com/tools/testing).
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
--------------------------------------------------------------------------------
/assets/Screenshot_20220318_171359.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kl3jvi/clean_modularized/d1372621118173f39c44cae483e9e9c7a90683c1/assets/Screenshot_20220318_171359.png
--------------------------------------------------------------------------------
/assets/header.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kl3jvi/clean_modularized/d1372621118173f39c44cae483e9e9c7a90683c1/assets/header.png
--------------------------------------------------------------------------------
/build.gradle.kts:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 | buildscript {
3 | repositories {
4 | google()
5 | mavenCentral()
6 | maven(url = "https://plugins.gradle.org/m2/")
7 | maven(url = "https://jitpack.io")
8 | }
9 |
10 | dependencies {
11 | classpath(Dependencies.androidGradlePlugin)
12 | classpath(Dependencies.Kotlin.gradlePlugin)
13 | // classpath(Dependencies.Koin.gradlePluginHilt)
14 | classpath(Dependencies.safeNav)
15 | classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10")
16 | }
17 |
18 | }
19 |
20 | allprojects {
21 | repositories {
22 | google()
23 | mavenCentral()
24 | maven(url = "https://jitpack.io")
25 | }
26 | }
27 |
28 | subprojects {
29 |
30 | tasks.withType {
31 | maxParallelForks = (Runtime.getRuntime().availableProcessors() / 2).takeIf { it > 0 } ?: 1
32 | }
33 | }
34 |
35 | // JVM target applied to all Kotlin tasks across all sub-projects
36 | tasks.withType {
37 | kotlinOptions.jvmTarget = JavaVersion.VERSION_1_8.toString()
38 | }
39 |
40 | tasks.register("clean", Delete::class) {
41 | delete(rootProject.buildDir)
42 | }
--------------------------------------------------------------------------------
/buildSrc/build.gradle.kts:
--------------------------------------------------------------------------------
1 | repositories {
2 | mavenCentral()
3 | google()
4 | }
5 |
6 | plugins {
7 | `kotlin-dsl`
8 | }
--------------------------------------------------------------------------------
/buildSrc/src/main/kotlin/Dependencies.kt:
--------------------------------------------------------------------------------
1 | import org.gradle.api.Project
2 | import org.gradle.kotlin.dsl.dependencies
3 | import org.gradle.kotlin.dsl.getValue
4 | import org.gradle.kotlin.dsl.provideDelegate
5 |
6 | object Dependencies {
7 |
8 | const val androidGradlePlugin = "com.android.tools.build:gradle:${Versions.androidGradle}"
9 | const val material = "com.google.android.material:material:${Versions.material}"
10 |
11 |
12 | const val okhttp = "com.squareup.okhttp3:okhttp:${Versions.okhttp}"
13 | const val okhttpLogging = "com.squareup.okhttp3:logging-interceptor:${Versions.okhttp}"
14 |
15 | const val coil = "io.coil-kt:coil:${Versions.coil}"
16 | const val dynamicFeaturePlugin =
17 | "androidx.navigation:navigation-dynamic-features-fragment:${Versions.dynamicFeature}"
18 |
19 | const val safeNav =
20 | "androidx.navigation:navigation-safe-args-gradle-plugin:${Versions.ArchitectureComponents.navigation}"
21 |
22 | object Moshi {
23 | const val moshi = "com.squareup.moshi:moshi-kotlin:${Versions.moshi}"
24 | const val moshiKapt = "com.squareup.moshi:moshi-kotlin-codegen:${Versions.moshi}"
25 | }
26 |
27 | object Coroutines {
28 | const val coroutinesCore =
29 | "org.jetbrains.kotlinx:kotlinx-coroutines-core:${Versions.coroutine}"
30 | const val coroutinesAndroid =
31 | "org.jetbrains.kotlinx:kotlinx-coroutines-android:${Versions.coroutine}"
32 | }
33 |
34 | object Kotlin {
35 | const val gradlePlugin = "org.jetbrains.kotlin:kotlin-gradle-plugin:${Versions.kotlin}"
36 | const val stdLib = "org.jetbrains.kotlin:kotlin-stdlib-jdk8:${Versions.kotlin}"
37 | }
38 |
39 | object AndroidX {
40 | const val appCompat = "androidx.appcompat:appcompat:${Versions.AndroidX.appCompat}"
41 | const val coreKtx = "androidx.core:core-ktx:${Versions.AndroidX.core}"
42 | const val constraintLayout =
43 | "androidx.constraintlayout:constraintlayout:${Versions.AndroidX.constraintLayout}"
44 | const val swipeRefreshLayout =
45 | "androidx.swiperefreshlayout:swiperefreshlayout:${Versions.AndroidX.swipeRefreshLayout}"
46 | }
47 |
48 | object Test {
49 | const val junit = "junit:junit:${Versions.junit}"
50 | const val runner = "androidx.test:runner:${Versions.testRunner}"
51 | const val espressoCore = "androidx.test.espresso:espresso-core:${Versions.espresso}"
52 | }
53 |
54 | object Koin {
55 | const val koin = "io.insert-koin:koin-android:${Versions.koinVersion}"
56 | }
57 |
58 | object Retrofit {
59 | const val core = "com.squareup.retrofit2:retrofit:${Versions.retrofit}"
60 | const val moshiConverter = "com.squareup.retrofit2:converter-moshi:${Versions.retrofit}"
61 | }
62 |
63 |
64 | object Paging {
65 | const val runtime =
66 | "androidx.paging:paging-runtime:${Versions.ArchitectureComponents.paging}"
67 | }
68 |
69 | object Room {
70 | const val runtime = "androidx.room:room-runtime:${Versions.ArchitectureComponents.room}"
71 | const val annotation = "androidx.room:room-compiler:${Versions.ArchitectureComponents.room}"
72 | const val ktx = "androidx.room:room-ktx:${Versions.ArchitectureComponents.room}"
73 | }
74 |
75 | object Navigation {
76 | const val navRuntime =
77 | "androidx.navigation:navigation-runtime-ktx:${Versions.ArchitectureComponents.navigation}"
78 | const val navFragment =
79 | "androidx.navigation:navigation-fragment-ktx:${Versions.ArchitectureComponents.navigation}"
80 | const val navUi =
81 | "androidx.navigation:navigation-ui-ktx:${Versions.ArchitectureComponents.navigation}"
82 | }
83 |
84 | object Lifecycle {
85 | const val lifecycleRuntime = "androidx.lifecycle:lifecycle-runtime-ktx:${Versions.lifeCycleVersion}"
86 | // const val lifecycleExt = "androidx.lifecycle:lifecycle-extensions:${Versions.lifeCycleVersion}"
87 | const val lifecycleKapt = "androidx.lifecycle:lifecycle-compiler:${Versions.lifeCycleVersion}"
88 | }
89 |
90 |
91 | object DynamicFeature {
92 | const val APP = ":app"
93 | const val FEATURE_HOME = ":feature_home"
94 | const val FEATURE_FAVORITES = ":feature_favorites"
95 | }
96 |
97 | object AndroidLibrary {
98 | const val CORE = ":libraries:core"
99 | const val DATA = ":libraries:data"
100 | const val DATA_API = ":libraries:data-api"
101 | const val DOMAIN = ":libraries:domain"
102 | }
103 | }
104 |
105 |
106 | /**
107 | * Plugins
108 | */
109 | const val ANDROID_APPLICATION_PLUGIN = "com.android.application"
110 | const val ANDROID_DYNAMIC_FEATURE_PLUGIN = "com.android.dynamic-feature"
111 | const val ANDROID_LIBRARY_PLUGIN = "com.android.library"
112 |
113 | const val KOTLIN_ANDROID_PLUGIN = "kotlin-android"
114 |
115 | const val KOTLIN_KAPT_PLUGIN = "kotlin-kapt"
116 | const val NAVIGATION_SAFE_ARGS = "androidx.navigation.safeargs.kotlin"
117 |
118 |
119 | // apply common plugin
120 | fun Project.importCommonDependencies() {
121 | dependencies {
122 |
123 | // The two following syntax is applicable
124 | // source: https://github.com/gradle/kotlin-dsl-samples/issues/843
125 | "implementation"(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar"))))
126 | "implementation"(Dependencies.Kotlin.stdLib)
127 |
128 |
129 | val implementation by configurations
130 | val testImplementation by configurations
131 | val androidTestImplementation by configurations
132 |
133 | implementation(Dependencies.AndroidX.appCompat)
134 | implementation(Dependencies.AndroidX.coreKtx)
135 | implementation(Dependencies.AndroidX.constraintLayout)
136 | implementation(Dependencies.AndroidX.swipeRefreshLayout)
137 | implementation(Dependencies.material)
138 |
139 | implementation(Dependencies.Coroutines.coroutinesAndroid)
140 | implementation(Dependencies.Coroutines.coroutinesCore)
141 |
142 | implementation(Dependencies.Retrofit.core)
143 | implementation(Dependencies.okhttp)
144 | implementation(Dependencies.Moshi.moshi)
145 |
146 | implementation(Dependencies.Paging.runtime)
147 |
148 | implementation(Dependencies.Navigation.navFragment)
149 | implementation(Dependencies.Navigation.navRuntime)
150 | implementation(Dependencies.Navigation.navUi)
151 |
152 |
153 | testImplementation(Dependencies.Test.junit)
154 | androidTestImplementation(Dependencies.Test.runner)
155 | androidTestImplementation(Dependencies.Test.espressoCore)
156 | }
157 | }
158 |
--------------------------------------------------------------------------------
/buildSrc/src/main/kotlin/Versions.kt:
--------------------------------------------------------------------------------
1 | object Versions {
2 | const val kotlin = "1.6.10"
3 | const val androidGradle = "7.0.4"
4 | const val material = "1.4.0"
5 |
6 | const val coroutine = "1.6.0"
7 | const val moshi = "1.13.0"
8 |
9 | const val okhttp = "4.9.0"
10 | const val retrofit = "2.9.0"
11 | const val koinVersion = "3.2.0-beta-1"
12 |
13 | const val coil = "1.4.0"
14 | const val dynamicFeature = "2.4.1"
15 |
16 | // Test frameworks
17 | const val junit = "4.12"
18 | const val espresso = "3.2.0"
19 | const val testRunner = "1.2.0"
20 |
21 | object Android {
22 | const val sdk = 31
23 | const val minSdk = 21
24 | }
25 |
26 | object AndroidX {
27 | const val appCompat = "1.3.1"
28 | const val core = "1.3.0"
29 | const val constraintLayout = "2.1.0"
30 | const val swipeRefreshLayout = "1.1.0"
31 | }
32 |
33 | object App {
34 | const val id = "com.kl3jvi.mvvm_template"
35 | const val versionCode = 1
36 | const val versionName = "1.0.0"
37 | }
38 |
39 | object ArchitectureComponents {
40 | const val paging = "3.1.0"
41 | const val room = "2.4.0"
42 | const val navigation = "2.4.1"
43 | }
44 |
45 | const val lifeCycleVersion = "2.4.1"
46 | }
--------------------------------------------------------------------------------
/feature_favorites/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/feature_favorites/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | id(ANDROID_DYNAMIC_FEATURE_PLUGIN)
3 | id(KOTLIN_ANDROID_PLUGIN)
4 | id(KOTLIN_KAPT_PLUGIN)
5 | }
6 |
7 | android {
8 |
9 | compileSdk = (Versions.Android.sdk)
10 |
11 | defaultConfig {
12 | testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
13 | }
14 |
15 | buildTypes {
16 | getByName("release") {
17 | isMinifyEnabled = false
18 | proguardFiles(
19 | getDefaultProguardFile("proguard-android-optimize.txt"),
20 | "proguard-rules.pro"
21 | )
22 | }
23 | }
24 |
25 | packagingOptions {
26 | exclude("META-INF/AL2.0")
27 | }
28 |
29 | dataBinding.isEnabled = true
30 | // android.buildFeatures.viewBinding = true
31 |
32 | compileOptions {
33 | sourceCompatibility = JavaVersion.VERSION_1_8
34 | targetCompatibility = JavaVersion.VERSION_1_8
35 | }
36 | kotlinOptions {
37 | jvmTarget = "1.8"
38 | }
39 | }
40 |
41 |
42 | dependencies {
43 | importCommonDependencies()
44 | implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar"))))
45 | implementation(project(":app"))
46 |
47 | implementation(project(Dependencies.AndroidLibrary.DATA_API))
48 | implementation(project(Dependencies.AndroidLibrary.DOMAIN))
49 |
50 | // implementation(Dependencies.Lifecycle.lifecycleExt)
51 | implementation(Dependencies.Lifecycle.lifecycleRuntime)
52 | "kapt"(Dependencies.Lifecycle.lifecycleKapt)
53 |
54 | implementation(Dependencies.Koin.koin)
55 | }
--------------------------------------------------------------------------------
/feature_favorites/src/androidTest/java/com/kl3jvi/feature_favorites/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.kl3jvi.feature_favorites
2 |
3 | import androidx.test.platform.app.InstrumentationRegistry
4 | import androidx.test.ext.junit.runners.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * See [testing documentation](http://d.android.com/tools/testing).
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22 | assertEquals("com.kl3jvi.feature_favorites", appContext.packageName)
23 | }
24 | }
--------------------------------------------------------------------------------
/feature_favorites/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/feature_favorites/src/main/java/com/kl3jvi/feature_favorites/presentation/favorites/FavoritesFragment.kt:
--------------------------------------------------------------------------------
1 | package com.kl3jvi.feature_favorites.presentation.favorites
2 |
3 | import androidx.fragment.app.Fragment
4 | import androidx.fragment.app.viewModels
5 | import com.kl3jvi.feature_favorites.R
6 | import com.kl3jvi.feature_favorites.databinding.FavoritesFragmentBinding
7 | import com.kl3jvi.feature_favorites.presentation.favorites.common.viewBinding
8 |
9 | class FavoritesFragment : Fragment(R.layout.favorites_fragment) {
10 | private val viewModel: FavoritesViewModel by viewModels()
11 | // private val binding: FavoritesFragmentBinding by viewBinding()
12 |
13 | }
--------------------------------------------------------------------------------
/feature_favorites/src/main/java/com/kl3jvi/feature_favorites/presentation/favorites/FavoritesViewModel.kt:
--------------------------------------------------------------------------------
1 | package com.kl3jvi.feature_favorites.presentation.favorites
2 |
3 | import androidx.lifecycle.ViewModel
4 |
5 | class FavoritesViewModel : ViewModel() {
6 | // TODO: Implement the ViewModel
7 | }
--------------------------------------------------------------------------------
/feature_favorites/src/main/java/com/kl3jvi/feature_favorites/presentation/favorites/common/FragmentViewBinding.kt:
--------------------------------------------------------------------------------
1 | package com.kl3jvi.feature_favorites.presentation.favorites.common
2 |
3 | import android.view.View
4 | import androidx.fragment.app.Fragment
5 | import androidx.lifecycle.DefaultLifecycleObserver
6 | import androidx.lifecycle.Lifecycle
7 | import androidx.lifecycle.LifecycleOwner
8 | import androidx.lifecycle.Observer
9 | import androidx.viewbinding.ViewBinding
10 | import kotlin.properties.ReadOnlyProperty
11 | import kotlin.reflect.KProperty
12 |
13 |
14 | inline fun Fragment.viewBinding() =
15 | FragmentViewBindingDelegate(T::class.java, this)
16 |
17 | class FragmentViewBindingDelegate(
18 | bindingClass: Class,
19 | private val fragment: Fragment
20 | ) : ReadOnlyProperty {
21 |
22 | private var binding: T? = null
23 | private val bindMethod = bindingClass.getMethod("bind", View::class.java)
24 |
25 | init {
26 | fragment.lifecycle.addObserver(object : DefaultLifecycleObserver {
27 | val viewLifecycleOwnerLiveDataObserver =
28 | Observer {
29 | val viewLifecycleOwner = it ?: return@Observer
30 | viewLifecycleOwner.lifecycle.addObserver(object : DefaultLifecycleObserver {
31 | override fun onDestroy(owner: LifecycleOwner) {
32 | binding = null
33 | }
34 | })
35 | }
36 |
37 | override fun onCreate(owner: LifecycleOwner) {
38 | fragment.viewLifecycleOwnerLiveData.observeForever(
39 | viewLifecycleOwnerLiveDataObserver
40 | )
41 | }
42 |
43 | override fun onDestroy(owner: LifecycleOwner) {
44 | fragment.viewLifecycleOwnerLiveData.removeObserver(
45 | viewLifecycleOwnerLiveDataObserver
46 | )
47 | }
48 | })
49 | }
50 |
51 | @Suppress("UNCHECKED_CAST")
52 | override fun getValue(thisRef: Fragment, property: KProperty<*>): T {
53 |
54 | binding?.let { return it }
55 | val lifecycle = fragment.viewLifecycleOwner.lifecycle
56 |
57 | if (!lifecycle.currentState.isAtLeast(Lifecycle.State.INITIALIZED)) {
58 | error("Cannot access view bindings. View lifecycle is ${lifecycle.currentState}!")
59 | }
60 |
61 | val invoke = bindMethod.invoke(null, thisRef.requireView()) as T
62 | return invoke.also { this.binding = it }
63 | }
64 | }
--------------------------------------------------------------------------------
/feature_favorites/src/main/res/layout/favorites_fragment.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
10 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/feature_favorites/src/main/res/navigation/feature_fav_nav_graph.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
--------------------------------------------------------------------------------
/feature_favorites/src/test/java/com/kl3jvi/feature_favorites/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.kl3jvi.feature_favorites
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * See [testing documentation](http://d.android.com/tools/testing).
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
--------------------------------------------------------------------------------
/feature_home/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/feature_home/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | id(ANDROID_DYNAMIC_FEATURE_PLUGIN)
3 | id(KOTLIN_ANDROID_PLUGIN)
4 | id(KOTLIN_KAPT_PLUGIN)
5 | }
6 |
7 |
8 | android {
9 |
10 | compileSdk = (Versions.Android.sdk)
11 |
12 | defaultConfig {
13 | minSdk = 21
14 | }
15 |
16 | buildTypes {
17 | getByName("release") {
18 | isMinifyEnabled = false
19 | proguardFiles(
20 | getDefaultProguardFile("proguard-android-optimize.txt"),
21 | "proguard-rules.pro"
22 | )
23 | }
24 | }
25 |
26 | packagingOptions {
27 | exclude("META-INF/AL2.0")
28 | }
29 |
30 | dataBinding.isEnabled = true
31 | viewBinding.isEnabled = true
32 | }
33 |
34 | dependencies {
35 | importCommonDependencies()
36 | implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar"))))
37 | implementation(project(Dependencies.DynamicFeature.APP))
38 |
39 | implementation(project(Dependencies.AndroidLibrary.DATA_API))
40 | implementation(project(Dependencies.AndroidLibrary.DOMAIN))
41 |
42 | // implementation(Dependencies.Lifecycle.lifecycleExt)
43 | // implementation(Dependencies.Lifecycle.lifecycleViewModel)
44 | implementation(Dependencies.Lifecycle.lifecycleRuntime)
45 | "kapt"(Dependencies.Lifecycle.lifecycleKapt)
46 |
47 | implementation(Dependencies.coil)
48 |
49 | implementation(Dependencies.Koin.koin)
50 | }
--------------------------------------------------------------------------------
/feature_home/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
--------------------------------------------------------------------------------
/feature_home/src/androidTest/java/com/kl3jvi/feature_home/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.kl3jvi.feature_home
2 |
3 | import androidx.test.platform.app.InstrumentationRegistry
4 | import androidx.test.runner.AndroidJUnit4
5 | import org.junit.Assert.assertEquals
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | /**
10 | * Instrumented test, which will execute on an Android device.
11 | *
12 | * See [testing documentation](http://d.android.com/tools/testing).
13 | */
14 | @RunWith(AndroidJUnit4::class)
15 | class ExampleInstrumentedTest {
16 | @Test
17 | fun useAppContext() {
18 | // Context of the app under test.
19 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext
20 | assertEquals("com.kl3jvi.feature_home", appContext.packageName)
21 | }
22 | }
--------------------------------------------------------------------------------
/feature_home/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/feature_home/src/main/java/com/kl3jvi/feature_home/common/FragmentViewBinding.kt:
--------------------------------------------------------------------------------
1 | package com.kl3jvi.feature_home.common
2 |
3 | import android.view.View
4 | import androidx.fragment.app.Fragment
5 | import androidx.lifecycle.DefaultLifecycleObserver
6 | import androidx.lifecycle.Lifecycle
7 | import androidx.lifecycle.LifecycleOwner
8 | import androidx.lifecycle.Observer
9 | import androidx.viewbinding.ViewBinding
10 | import kotlin.properties.ReadOnlyProperty
11 | import kotlin.reflect.KProperty
12 |
13 |
14 | inline fun Fragment.viewBinding() =
15 | FragmentViewBindingDelegate(T::class.java, this)
16 |
17 | class FragmentViewBindingDelegate(
18 | bindingClass: Class,
19 | private val fragment: Fragment
20 | ) : ReadOnlyProperty {
21 |
22 | private var binding: T? = null
23 | private val bindMethod = bindingClass.getMethod("bind", View::class.java)
24 |
25 | init {
26 | fragment.lifecycle.addObserver(object : DefaultLifecycleObserver {
27 | val viewLifecycleOwnerLiveDataObserver =
28 | Observer {
29 | val viewLifecycleOwner = it ?: return@Observer
30 | viewLifecycleOwner.lifecycle.addObserver(object : DefaultLifecycleObserver {
31 | override fun onDestroy(owner: LifecycleOwner) {
32 | binding = null
33 | }
34 | })
35 | }
36 |
37 | override fun onCreate(owner: LifecycleOwner) {
38 | fragment.viewLifecycleOwnerLiveData.observeForever(
39 | viewLifecycleOwnerLiveDataObserver
40 | )
41 | }
42 |
43 | override fun onDestroy(owner: LifecycleOwner) {
44 | fragment.viewLifecycleOwnerLiveData.removeObserver(
45 | viewLifecycleOwnerLiveDataObserver
46 | )
47 | }
48 | })
49 | }
50 |
51 | @Suppress("UNCHECKED_CAST")
52 | override fun getValue(thisRef: Fragment, property: KProperty<*>): T {
53 |
54 | binding?.let { return it }
55 | val lifecycle = fragment.viewLifecycleOwner.lifecycle
56 |
57 | if (!lifecycle.currentState.isAtLeast(Lifecycle.State.INITIALIZED)) {
58 | error("Cannot access view bindings. View lifecycle is ${lifecycle.currentState}!")
59 | }
60 |
61 | val invoke = bindMethod.invoke(null, thisRef.requireView()) as T
62 | return invoke.also { this.binding = it }
63 | }
64 | }
--------------------------------------------------------------------------------
/feature_home/src/main/java/com/kl3jvi/feature_home/common/ViewBindings.kt:
--------------------------------------------------------------------------------
1 | package com.kl3jvi.feature_home.common
2 |
3 | import android.widget.ImageView
4 | import androidx.databinding.BindingAdapter
5 | import coil.load
6 | import coil.request.CachePolicy
7 |
8 | object ViewBindings {
9 |
10 | @JvmStatic
11 | @BindingAdapter("image")
12 | fun setImage(image: ImageView, url: String?) {
13 | if (!url.isNullOrEmpty()) {
14 | image.load(url) {
15 | diskCachePolicy(CachePolicy.ENABLED)
16 | }
17 | }
18 | }
19 | }
--------------------------------------------------------------------------------
/feature_home/src/main/java/com/kl3jvi/feature_home/di/ViewModelModule.kt:
--------------------------------------------------------------------------------
1 | package com.kl3jvi.feature_home.di
2 |
3 | import com.kl3jvi.feature_home.presentation.home.HomeViewModel
4 | import org.koin.androidx.viewmodel.dsl.viewModel
5 | import org.koin.dsl.module
6 |
7 | val viewModelModule = module { viewModel { (list: String) -> HomeViewModel(get(), list) } }
--------------------------------------------------------------------------------
/feature_home/src/main/java/com/kl3jvi/feature_home/presentation/adpater/BaseAdapter.kt:
--------------------------------------------------------------------------------
1 | package com.kl3jvi.feature_home.presentation.adpater
2 |
3 | import android.view.View
4 | import androidx.recyclerview.widget.DiffUtil
5 | import androidx.recyclerview.widget.ListAdapter
6 |
7 | abstract class BaseAdapter>(
8 | diffCallback: DiffUtil.ItemCallback
9 | ) : ListAdapter(diffCallback) {
10 |
11 | open var listener: OnAdapterListener? = null
12 | open fun removeListener() {
13 | listener = null
14 | }
15 | }
16 |
17 | interface OnAdapterListener {
18 | fun onAdapterClick(view: View, data: T)
19 | }
--------------------------------------------------------------------------------
/feature_home/src/main/java/com/kl3jvi/feature_home/presentation/adpater/BaseViewHolder.kt:
--------------------------------------------------------------------------------
1 | package com.kl3jvi.feature_home.presentation.adpater
2 |
3 | import android.view.View
4 | import androidx.recyclerview.widget.RecyclerView
5 |
6 | abstract class BaseViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
7 |
8 | abstract fun onClickAdapter(view: View, element: @UnsafeVariance T)
9 | open fun bindView(element: @UnsafeVariance T) {}
10 | }
--------------------------------------------------------------------------------
/feature_home/src/main/java/com/kl3jvi/feature_home/presentation/adpater/DiffUtil.kt:
--------------------------------------------------------------------------------
1 | package com.kl3jvi.feature_home.presentation.adpater
2 |
3 | import android.annotation.SuppressLint
4 | import androidx.recyclerview.widget.DiffUtil
5 |
6 | class MainDiffUtil : DiffUtil.ItemCallback() {
7 |
8 | override fun areItemsTheSame(oldItem: T, newItem: T): Boolean {
9 | return oldItem.toString() == newItem.toString()
10 | }
11 |
12 | @SuppressLint("DiffUtilEquals")
13 | override fun areContentsTheSame(oldItem: T, newItem: T): Boolean {
14 | return oldItem == newItem
15 | }
16 | }
--------------------------------------------------------------------------------
/feature_home/src/main/java/com/kl3jvi/feature_home/presentation/adpater/TestAdapter.kt:
--------------------------------------------------------------------------------
1 | package com.kl3jvi.feature_home.presentation.adpater
2 |
3 | import android.view.LayoutInflater
4 | import android.view.ViewGroup
5 | import androidx.recyclerview.widget.ListAdapter
6 | import androidx.recyclerview.widget.RecyclerView
7 | import com.kl3jvi.domain.model.MovieListDomainModel
8 | import com.kl3jvi.feature_home.databinding.ItemMovieLargeBinding
9 |
10 |
11 | class TestAdapter : ListAdapter(MainDiffUtil()) {
12 |
13 | inner class MovieViewHolder(private val binding: ItemMovieLargeBinding) :
14 | RecyclerView.ViewHolder(binding.root) {
15 |
16 | fun bind(item: MovieListDomainModel) {
17 | binding.movieInfo = item
18 | binding.executePendingBindings()
19 | }
20 | }
21 |
22 | override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MovieViewHolder {
23 | val binding =
24 | ItemMovieLargeBinding.inflate(LayoutInflater.from(parent.context), parent, false)
25 | return MovieViewHolder(binding)
26 | }
27 |
28 | override fun onBindViewHolder(holder: MovieViewHolder, position: Int) {
29 | if (getItem(position) != null) holder.bind(getItem(position))
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/feature_home/src/main/java/com/kl3jvi/feature_home/presentation/details/DetailsFragment.kt:
--------------------------------------------------------------------------------
1 | package com.kl3jvi.feature_home.presentation.details
2 |
3 | import androidx.fragment.app.Fragment
4 | import androidx.fragment.app.viewModels
5 | import com.kl3jvi.feature_home.R
6 | import com.kl3jvi.feature_home.common.viewBinding
7 | import com.kl3jvi.feature_home.databinding.DetailsFragmentBinding
8 |
9 | class DetailsFragment : Fragment(R.layout.details_fragment) {
10 |
11 | private val viewModel: DetailsViewModel by viewModels()
12 | private val binding: DetailsFragmentBinding by viewBinding()
13 |
14 |
15 | }
--------------------------------------------------------------------------------
/feature_home/src/main/java/com/kl3jvi/feature_home/presentation/details/DetailsViewModel.kt:
--------------------------------------------------------------------------------
1 | package com.kl3jvi.feature_home.presentation.details
2 |
3 | import androidx.lifecycle.ViewModel
4 |
5 | class DetailsViewModel : ViewModel() {
6 | // TODO: Implement the ViewModel
7 | }
--------------------------------------------------------------------------------
/feature_home/src/main/java/com/kl3jvi/feature_home/presentation/home/HomeFragment.kt:
--------------------------------------------------------------------------------
1 | package com.kl3jvi.feature_home.presentation.home
2 |
3 | import android.os.Bundle
4 | import android.util.Log
5 | import android.view.View
6 | import androidx.fragment.app.Fragment
7 | import androidx.lifecycle.lifecycleScope
8 | import com.kl3jvi.feature_home.R
9 | import com.kl3jvi.feature_home.common.viewBinding
10 | import com.kl3jvi.feature_home.databinding.HomeFragmentBinding
11 | import com.kl3jvi.feature_home.di.viewModelModule
12 | import com.kl3jvi.feature_home.presentation.adpater.TestAdapter
13 | import kotlinx.coroutines.launch
14 | import org.koin.androidx.viewmodel.ext.android.viewModel
15 | import org.koin.core.context.loadKoinModules
16 | import org.koin.core.parameter.parametersOf
17 |
18 |
19 | class HomeFragment : Fragment(R.layout.home_fragment) {
20 |
21 | override fun onCreate(savedInstanceState: Bundle?) {
22 | super.onCreate(savedInstanceState)
23 | loadKoinModules(module = viewModelModule)
24 | }
25 |
26 | private val viewModels: HomeViewModel by viewModel { parametersOf("popular") }
27 | private val binding: HomeFragmentBinding by viewBinding()
28 | private val adapter: TestAdapter = TestAdapter()
29 |
30 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
31 | super.onViewCreated(view, savedInstanceState)
32 | getMovies()
33 | binding.moviesRv.adapter = adapter
34 | }
35 |
36 | fun getMovies() {
37 | lifecycleScope.launch {
38 | viewModels.moviesListStateFlow.collect { state ->
39 | when (state) {
40 | is State.Error -> {}
41 | is State.Loading -> {}
42 | is State.Success -> {
43 | adapter.submitList(state.data.results)
44 | }
45 | }
46 |
47 | }
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/feature_home/src/main/java/com/kl3jvi/feature_home/presentation/home/HomeViewModel.kt:
--------------------------------------------------------------------------------
1 | package com.kl3jvi.feature_home.presentation.home
2 |
3 | import android.util.Log
4 | import androidx.lifecycle.ViewModel
5 | import androidx.lifecycle.viewModelScope
6 | import com.kl3jvi.domain.model.TmdbApiResponseDomain
7 | import com.kl3jvi.domain.usecase.GetMoviesList
8 | import kotlinx.coroutines.*
9 | import kotlinx.coroutines.flow.*
10 | import kotlin.coroutines.CoroutineContext
11 | import kotlin.coroutines.EmptyCoroutineContext
12 |
13 | sealed class State {
14 | class Loading : State()
15 | data class Success(val data: T) : State()
16 | data class Error(val message: String) : State()
17 |
18 | fun isLoading(): Boolean = this is Loading
19 | fun isSuccessful(): Boolean = this is Success
20 | fun isFailed(): Boolean = this is Error
21 | }
22 |
23 |
24 | class HomeViewModel(
25 | private val getMoviesList: GetMoviesList,
26 | private val list: String
27 | ) : ViewModel() {
28 | private val errorHandler = CoroutineExceptionHandler { context, exception ->
29 | Log.e("Context: $context", exception.message.orEmpty())
30 | }
31 |
32 | private var _moviesListStateFlow: MutableStateFlow> =
33 | MutableStateFlow(State.Loading())
34 | val moviesListStateFlow: StateFlow>
35 | get() = _moviesListStateFlow
36 |
37 | init {
38 | getMovies()
39 | }
40 |
41 |
42 | private fun getMovies() {
43 | viewModelScope.launch(Dispatchers.IO) {
44 | getMoviesList.execute(
45 | list = list,
46 | page = 1
47 | ).catch {
48 | _moviesListStateFlow.value = State.Error(message = it.message.orEmpty())
49 | }.onEach {
50 | _moviesListStateFlow.value = State.Success(data = it)
51 | }.stateIn(viewModelScope)
52 | }
53 | }
54 | }
55 |
56 |
57 |
--------------------------------------------------------------------------------
/feature_home/src/main/res/layout/details_fragment.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
11 |
12 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/feature_home/src/main/res/layout/home_fragment.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
18 |
19 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/feature_home/src/main/res/layout/item_movie_large.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
9 |
10 |
11 |
17 |
18 |
25 |
26 |
33 |
34 |
35 |
36 |
45 |
46 |
56 |
57 |
69 |
70 |
79 |
80 |
81 |
82 |
--------------------------------------------------------------------------------
/feature_home/src/main/res/navigation/feature_home_nav_graph.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
16 |
17 |
18 |
23 |
--------------------------------------------------------------------------------
/feature_home/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | %1$s Votes
4 |
5 |
--------------------------------------------------------------------------------
/feature_home/src/test/java/com/kl3jvi/feature_home/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.kl3jvi.feature_home
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * See [testing documentation](http://d.android.com/tools/testing).
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | # AndroidX package structure to make it clearer which packages are bundled with the
15 | # Android operating system, and which are packaged with your app"s APK
16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
17 | android.useAndroidX=true
18 | # Kotlin code style for this project: "official" or "obsolete":
19 | kotlin.code.style=official
20 | # Enables namespacing of each library's R class so that its R class includes only the
21 | # resources declared in the library itself and none from the library's dependencies,
22 | # thereby reducing the size of the R class for that library
23 | android.nonTransitiveRClass=true
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kl3jvi/clean_modularized/d1372621118173f39c44cae483e9e9c7a90683c1/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Mar 07 11:09:14 CET 2022
2 | distributionBase=GRADLE_USER_HOME
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
4 | distributionPath=wrapper/dists
5 | zipStorePath=wrapper/dists
6 | zipStoreBase=GRADLE_USER_HOME
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | #
4 | # Copyright 2015 the original author or authors.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # https://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | ##############################################################################
20 | ##
21 | ## Gradle start up script for UN*X
22 | ##
23 | ##############################################################################
24 |
25 | # Attempt to set APP_HOME
26 | # Resolve links: $0 may be a link
27 | PRG="$0"
28 | # Need this for relative symlinks.
29 | while [ -h "$PRG" ] ; do
30 | ls=`ls -ld "$PRG"`
31 | link=`expr "$ls" : '.*-> \(.*\)$'`
32 | if expr "$link" : '/.*' > /dev/null; then
33 | PRG="$link"
34 | else
35 | PRG=`dirname "$PRG"`"/$link"
36 | fi
37 | done
38 | SAVED="`pwd`"
39 | cd "`dirname \"$PRG\"`/" >/dev/null
40 | APP_HOME="`pwd -P`"
41 | cd "$SAVED" >/dev/null
42 |
43 | APP_NAME="Gradle"
44 | APP_BASE_NAME=`basename "$0"`
45 |
46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
48 |
49 | # Use the maximum available, or set MAX_FD != -1 to use that value.
50 | MAX_FD="maximum"
51 |
52 | warn () {
53 | echo "$*"
54 | }
55 |
56 | die () {
57 | echo
58 | echo "$*"
59 | echo
60 | exit 1
61 | }
62 |
63 | # OS specific support (must be 'true' or 'false').
64 | cygwin=false
65 | msys=false
66 | darwin=false
67 | nonstop=false
68 | case "`uname`" in
69 | CYGWIN* )
70 | cygwin=true
71 | ;;
72 | Darwin* )
73 | darwin=true
74 | ;;
75 | MINGW* )
76 | msys=true
77 | ;;
78 | NONSTOP* )
79 | nonstop=true
80 | ;;
81 | esac
82 |
83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
84 |
85 |
86 | # Determine the Java command to use to start the JVM.
87 | if [ -n "$JAVA_HOME" ] ; then
88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
89 | # IBM's JDK on AIX uses strange locations for the executables
90 | JAVACMD="$JAVA_HOME/jre/sh/java"
91 | else
92 | JAVACMD="$JAVA_HOME/bin/java"
93 | fi
94 | if [ ! -x "$JAVACMD" ] ; then
95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
96 |
97 | Please set the JAVA_HOME variable in your environment to match the
98 | location of your Java installation."
99 | fi
100 | else
101 | JAVACMD="java"
102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
103 |
104 | Please set the JAVA_HOME variable in your environment to match the
105 | location of your Java installation."
106 | fi
107 |
108 | # Increase the maximum file descriptors if we can.
109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
110 | MAX_FD_LIMIT=`ulimit -H -n`
111 | if [ $? -eq 0 ] ; then
112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
113 | MAX_FD="$MAX_FD_LIMIT"
114 | fi
115 | ulimit -n $MAX_FD
116 | if [ $? -ne 0 ] ; then
117 | warn "Could not set maximum file descriptor limit: $MAX_FD"
118 | fi
119 | else
120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
121 | fi
122 | fi
123 |
124 | # For Darwin, add options to specify how the application appears in the dock
125 | if $darwin; then
126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
127 | fi
128 |
129 | # For Cygwin or MSYS, switch paths to Windows format before running java
130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
133 |
134 | JAVACMD=`cygpath --unix "$JAVACMD"`
135 |
136 | # We build the pattern for arguments to be converted via cygpath
137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
138 | SEP=""
139 | for dir in $ROOTDIRSRAW ; do
140 | ROOTDIRS="$ROOTDIRS$SEP$dir"
141 | SEP="|"
142 | done
143 | OURCYGPATTERN="(^($ROOTDIRS))"
144 | # Add a user-defined pattern to the cygpath arguments
145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
147 | fi
148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
149 | i=0
150 | for arg in "$@" ; do
151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
153 |
154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
156 | else
157 | eval `echo args$i`="\"$arg\""
158 | fi
159 | i=`expr $i + 1`
160 | done
161 | case $i in
162 | 0) set -- ;;
163 | 1) set -- "$args0" ;;
164 | 2) set -- "$args0" "$args1" ;;
165 | 3) set -- "$args0" "$args1" "$args2" ;;
166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
172 | esac
173 | fi
174 |
175 | # Escape application args
176 | save () {
177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
178 | echo " "
179 | }
180 | APP_ARGS=`save "$@"`
181 |
182 | # Collect all arguments for the java command, following the shell quoting and substitution rules
183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
184 |
185 | exec "$JAVACMD" "$@"
186 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%" == "" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%" == "" set DIRNAME=.
29 | set APP_BASE_NAME=%~n0
30 | set APP_HOME=%DIRNAME%
31 |
32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
34 |
35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
37 |
38 | @rem Find java.exe
39 | if defined JAVA_HOME goto findJavaFromJavaHome
40 |
41 | set JAVA_EXE=java.exe
42 | %JAVA_EXE% -version >NUL 2>&1
43 | if "%ERRORLEVEL%" == "0" goto execute
44 |
45 | echo.
46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
47 | echo.
48 | echo Please set the JAVA_HOME variable in your environment to match the
49 | echo location of your Java installation.
50 |
51 | goto fail
52 |
53 | :findJavaFromJavaHome
54 | set JAVA_HOME=%JAVA_HOME:"=%
55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
56 |
57 | if exist "%JAVA_EXE%" goto execute
58 |
59 | echo.
60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
61 | echo.
62 | echo Please set the JAVA_HOME variable in your environment to match the
63 | echo location of your Java installation.
64 |
65 | goto fail
66 |
67 | :execute
68 | @rem Setup the command line
69 |
70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
71 |
72 |
73 | @rem Execute Gradle
74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
75 |
76 | :end
77 | @rem End local scope for the variables with windows NT shell
78 | if "%ERRORLEVEL%"=="0" goto mainEnd
79 |
80 | :fail
81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
82 | rem the _cmd.exe /c_ return code!
83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
84 | exit /b 1
85 |
86 | :mainEnd
87 | if "%OS%"=="Windows_NT" endlocal
88 |
89 | :omega
90 |
--------------------------------------------------------------------------------
/libraries/core/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/libraries/core/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | id("com.android.library")
3 | id("org.jetbrains.kotlin.android")
4 | id("kotlin-kapt")
5 | }
6 |
7 | android {
8 | compileSdk = 32
9 |
10 | defaultConfig {
11 | minSdk = 21
12 | targetSdk = 32
13 |
14 | testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
15 | consumerProguardFiles("consumer-rules.pro")
16 | }
17 |
18 | buildTypes {
19 | release {
20 | isMinifyEnabled = false
21 | proguardFiles(
22 | getDefaultProguardFile("proguard-android-optimize.txt"),
23 | "proguard-rules.pro"
24 | )
25 | }
26 | }
27 | compileOptions {
28 | sourceCompatibility = JavaVersion.VERSION_1_8
29 | targetCompatibility = JavaVersion.VERSION_1_8
30 | }
31 | dataBinding.isEnabled = true
32 | viewBinding.isEnabled = true
33 | kotlinOptions {
34 | jvmTarget = "1.8"
35 | }
36 | }
37 |
38 | dependencies {
39 | importCommonDependencies()
40 |
41 | //UNIQUE PER MODULE
42 | implementation(Dependencies.coil)
43 | implementation(Dependencies.Koin.koin)
44 |
45 |
46 | implementation(Dependencies.okhttp)
47 | implementation(Dependencies.okhttpLogging)
48 | implementation(Dependencies.Retrofit.core)
49 | implementation(Dependencies.Retrofit.moshiConverter)
50 | implementation(Dependencies.Moshi.moshi)
51 | "kapt"(Dependencies.Moshi.moshiKapt)
52 | }
--------------------------------------------------------------------------------
/libraries/core/consumer-rules.pro:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kl3jvi/clean_modularized/d1372621118173f39c44cae483e9e9c7a90683c1/libraries/core/consumer-rules.pro
--------------------------------------------------------------------------------
/libraries/core/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
--------------------------------------------------------------------------------
/libraries/core/src/androidTest/java/com/kl3jvi/core/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.kl3jvi.core
2 |
3 | import androidx.test.platform.app.InstrumentationRegistry
4 | import androidx.test.ext.junit.runners.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * See [testing documentation](http://d.android.com/tools/testing).
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22 | assertEquals("com.kl3jvi.core.test", appContext.packageName)
23 | }
24 | }
--------------------------------------------------------------------------------
/libraries/core/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/libraries/core/src/main/java/com/kl3jvi/core/utils/Resource.kt:
--------------------------------------------------------------------------------
1 | package com.kl3jvi.core.utils
2 |
3 | sealed class Resource {
4 | class Success(val data: T) : Resource()
5 | class Failed(val message: String) : Resource()
6 | }
7 |
--------------------------------------------------------------------------------
/libraries/core/src/main/java/com/kl3jvi/core/utils/Utils.kt:
--------------------------------------------------------------------------------
1 | package com.kl3jvi.core.utils
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/libraries/core/src/test/java/com/kl3jvi/core/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.kl3jvi.core
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * See [testing documentation](http://d.android.com/tools/testing).
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
--------------------------------------------------------------------------------
/libraries/data-api/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/libraries/data-api/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | id("com.android.library")
3 | id("org.jetbrains.kotlin.android")
4 | id("kotlin-kapt")
5 | }
6 |
7 | android {
8 | compileSdk = 32
9 |
10 | defaultConfig {
11 | minSdk = 21
12 | targetSdk = 32
13 |
14 | testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
15 | consumerProguardFiles("consumer-rules.pro")
16 | }
17 |
18 | buildTypes {
19 | release {
20 | isMinifyEnabled = false
21 | proguardFiles(
22 | getDefaultProguardFile("proguard-android-optimize.txt"),
23 | "proguard-rules.pro"
24 | )
25 | }
26 | }
27 | compileOptions {
28 | sourceCompatibility = JavaVersion.VERSION_1_8
29 | targetCompatibility = JavaVersion.VERSION_1_8
30 | }
31 | kotlinOptions {
32 | jvmTarget = "1.8"
33 | }
34 | }
35 |
36 | dependencies {
37 | importCommonDependencies()
38 | implementation(project(Dependencies.AndroidLibrary.DATA))
39 |
40 | implementation(Dependencies.Koin.koin)
41 |
42 | implementation(Dependencies.okhttp)
43 | implementation(Dependencies.okhttpLogging)
44 | implementation(Dependencies.Retrofit.core)
45 | implementation(Dependencies.Retrofit.moshiConverter)
46 | implementation(Dependencies.Moshi.moshi)
47 | "kapt"(Dependencies.Moshi.moshiKapt)
48 |
49 | implementation(Dependencies.Room.runtime)
50 | implementation(Dependencies.Room.ktx)
51 | "kapt"(Dependencies.Room.annotation)
52 | }
--------------------------------------------------------------------------------
/libraries/data-api/consumer-rules.pro:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kl3jvi/clean_modularized/d1372621118173f39c44cae483e9e9c7a90683c1/libraries/data-api/consumer-rules.pro
--------------------------------------------------------------------------------
/libraries/data-api/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
--------------------------------------------------------------------------------
/libraries/data-api/src/androidTest/java/com/kl3jvi/data_api/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.kl3jvi.data_api
2 |
3 | import androidx.test.platform.app.InstrumentationRegistry
4 | import androidx.test.ext.junit.runners.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * See [testing documentation](http://d.android.com/tools/testing).
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22 | assertEquals("com.kl3jvi.data_api.test", appContext.packageName)
23 | }
24 | }
--------------------------------------------------------------------------------
/libraries/data-api/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/libraries/data-api/src/main/java/com/kl3jvi/data_api/MovieService.kt:
--------------------------------------------------------------------------------
1 | package com.kl3jvi.data_api
2 |
3 | import com.kl3jvi.data_api.model.GenreListing
4 | import com.kl3jvi.data_api.model.TmdbApiResponse
5 | import retrofit2.Response
6 | import retrofit2.http.GET
7 | import retrofit2.http.Path
8 | import retrofit2.http.Query
9 |
10 | interface MovieService {
11 |
12 | companion object {
13 | private const val PARAM_MOVIE_ID = "movieId"
14 | private const val PATH_MOVIE_DETAIL = "movie/{$PARAM_MOVIE_ID}"
15 | }
16 |
17 | @GET("genre/movie/list")
18 | suspend fun fetchGenreList(): GenreListing
19 |
20 | @GET("movie/{list}")
21 | suspend fun fetchMovieList(
22 | @Path("list") list: String,
23 | @Query("page") page: Int? = null
24 | ): Response
25 |
26 | // @GET(PATH_MOVIE_DETAIL)
27 | // fun fetchMovieDetail(@Path(PARAM_MOVIE_ID) movieId: String): MovieDetailResponse
28 | //
29 | // @GET("$PATH_MOVIE_DETAIL/videos")
30 | // fun fetchMovieVideos(@Path(PARAM_MOVIE_ID) movieId: String): TmdbApiResponse