├── .gitignore ├── .idea ├── .gitignore ├── codeStyles │ ├── Project.xml │ └── codeStyleConfig.xml ├── compiler.xml ├── gradle.xml ├── jarRepositories.xml ├── misc.xml └── vcs.xml ├── README.md ├── app ├── .gitignore ├── build.gradle ├── data │ ├── .gitignore │ ├── build.gradle │ ├── consumer-rules.pro │ ├── proguard-rules.pro │ └── src │ │ ├── androidTest │ │ └── java │ │ │ └── com │ │ │ └── joydeep │ │ │ └── data │ │ │ └── ExampleInstrumentedTest.kt │ │ ├── main │ │ └── AndroidManifest.xml │ │ └── test │ │ └── java │ │ └── com │ │ └── joydeep │ │ └── data │ │ └── ExampleUnitTest.kt ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── joydeep │ │ └── hiltcleanarchitecture │ │ └── ExampleInstrumentedTest.kt │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── joydeep │ │ │ └── hiltcleanarchitecture │ │ │ ├── HiltCleanArchitectureApplication.kt │ │ │ ├── account │ │ │ ├── view │ │ │ │ └── AccountActivity.kt │ │ │ └── viewmodel │ │ │ │ └── AccountActivityViewModel.kt │ │ │ ├── common │ │ │ ├── di │ │ │ │ ├── AppModule.kt │ │ │ │ ├── LoggedInScope.kt │ │ │ │ └── NetworkModule.kt │ │ │ └── utils │ │ │ │ └── Extensions.kt │ │ │ ├── dashboard │ │ │ ├── view │ │ │ │ └── DashboardActivity.kt │ │ │ └── viewmodel │ │ │ │ └── DashBoardActivityViewModel.kt │ │ │ ├── employee │ │ │ ├── view │ │ │ │ ├── EmployeeActivity.kt │ │ │ │ └── adapter │ │ │ │ │ └── EmployeeAdapter.kt │ │ │ └── viewmodel │ │ │ │ ├── EmployeeActivityViewModel.kt │ │ │ │ └── UserStatus.kt │ │ │ ├── login │ │ │ ├── di │ │ │ │ ├── component │ │ │ │ │ └── UserComponent.kt │ │ │ │ ├── entryPoint │ │ │ │ │ └── UserComponentEntryPoint.kt │ │ │ │ ├── handler │ │ │ │ │ ├── UserComponentHandler.kt │ │ │ │ │ └── UserComponentHandlerImpl.kt │ │ │ │ └── module │ │ │ │ │ └── UserModule.kt │ │ │ ├── entity │ │ │ │ └── LoggedInUser.kt │ │ │ ├── view │ │ │ │ └── LoginActivity.kt │ │ │ └── viewmodel │ │ │ │ └── LoginActivityViewModel.kt │ │ │ └── splash │ │ │ ├── view │ │ │ └── SplashActivity.kt │ │ │ └── viewmodel │ │ │ └── SplashActivityViewModel.kt │ └── res │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ └── ic_launcher_background.xml │ │ ├── layout │ │ ├── activity_account.xml │ │ ├── activity_dashboard.xml │ │ ├── activity_employee.xml │ │ ├── activity_login.xml │ │ ├── activity_splash.xml │ │ └── view_user.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── values-night │ │ └── themes.xml │ │ └── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── themes.xml │ └── test │ └── java │ └── com │ └── joydeep │ └── hiltcleanarchitecture │ └── ExampleUnitTest.kt ├── build.gradle ├── data ├── .gitignore ├── build.gradle ├── consumer-rules.pro ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── joydeep │ │ └── data │ │ └── ExampleInstrumentedTest.kt │ ├── main │ ├── AndroidManifest.xml │ └── java │ │ └── com │ │ └── joydeep │ │ └── data │ │ └── login │ │ ├── api │ │ └── Api.kt │ │ └── repositoryImpl │ │ ├── UserDataRepositoryImpl.kt │ │ └── UserRepositoryImpl.kt │ └── test │ └── java │ └── com │ └── joydeep │ └── data │ └── ExampleUnitTest.kt ├── domain ├── .gitignore ├── build.gradle └── src │ └── main │ └── java │ └── com │ └── joydeep │ └── domain │ ├── common │ └── usecase │ │ └── BaseUseCase.kt │ └── login │ ├── entity │ ├── UserResponse.kt │ └── UsersResponse.kt │ ├── repository │ ├── UserDataRepository.kt │ └── UserRepository.kt │ └── usecase │ ├── GetAllUsersUseCase.kt │ └── GetUserUseCase.kt ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/caches 5 | /.idea/libraries 6 | /.idea/modules.xml 7 | /.idea/workspace.xml 8 | /.idea/navEditor.xml 9 | /.idea/assetWizardSettings.xml 10 | .DS_Store 11 | /build 12 | /captures 13 | .externalNativeBuild 14 | .cxx 15 | local.properties 16 | -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /.idea/codeStyles/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 20 | 22 | 23 | 135 | 136 | 138 | 139 | -------------------------------------------------------------------------------- /.idea/codeStyles/codeStyleConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 23 | 24 | -------------------------------------------------------------------------------- /.idea/jarRepositories.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 9 | 10 | 14 | 15 | 19 | 20 | 24 | 25 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 9 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # HiltCleanArchitecture 2 | A Clean Architecture App to show use of Hilt in a multi-module architecture 3 | 4 | This app is a PoC to showcase the use of Hilt in a multi module architecture. The modules are as follow: 5 | 1. app: Presentation Layer 6 | 2. domain: Business Logic Layer 7 | 3. data: Data Access Layer 8 | 9 | Some major highlights and libraries used are: 10 | 1. Hilt 11 | 2. Dagger 12 | 3. Coroutines 13 | 4. Retrofit 14 | 5. View Binding 15 | 6. Clean Architecture based on Uncle Bob 16 | 7. SOLID principles 17 | 18 | The app has two branches: 19 | 1. master: This is a skeleton branch which you can used to suit your use case. 20 | 2. loginFlow: This is a branch based on the master which shows a dummy login flow. 21 | 22 | More on loginFlow branch: 23 | 24 | This branch is showcasing how to use Custom Scopes and Components with Hilt which is a bit tricky to implement. The scope is @LoggedInScope and the custom component is 25 | UserComponent. Please have a look at it and contribute if you feel so. 26 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'com.android.application' 3 | id 'kotlin-android' 4 | id 'kotlin-kapt' 5 | id 'dagger.hilt.android.plugin' 6 | id "scabbard.gradle" version "0.4.0" 7 | } 8 | 9 | android { 10 | compileSdkVersion 30 11 | buildToolsVersion "30.0.2" 12 | 13 | defaultConfig { 14 | applicationId "com.joydeep.hiltcleanarchitecture" 15 | minSdkVersion 26 16 | targetSdkVersion 30 17 | versionCode 1 18 | versionName "1.0" 19 | 20 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 21 | } 22 | 23 | buildTypes { 24 | release { 25 | minifyEnabled false 26 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 27 | } 28 | } 29 | compileOptions { 30 | sourceCompatibility JavaVersion.VERSION_1_8 31 | targetCompatibility JavaVersion.VERSION_1_8 32 | } 33 | kotlinOptions { 34 | jvmTarget = '1.8' 35 | } 36 | buildFeatures { 37 | viewBinding true 38 | } 39 | scabbard { 40 | enabled true 41 | outputFormat "svg" 42 | } 43 | } 44 | 45 | scabbard { 46 | enabled true 47 | outputFormat "svg" 48 | } 49 | 50 | dependencies { 51 | implementation fileTree(include: ['*.jar'], dir: 'libs') 52 | 53 | implementation project(':data') 54 | 55 | implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" 56 | implementation 'androidx.core:core-ktx:1.3.2' 57 | implementation 'androidx.appcompat:appcompat:1.2.0' 58 | implementation 'com.google.android.material:material:1.2.1' 59 | implementation 'androidx.constraintlayout:constraintlayout:2.0.4' 60 | testImplementation 'junit:junit:4.+' 61 | androidTestImplementation 'androidx.test.ext:junit:1.1.2' 62 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' 63 | 64 | // Hilt 65 | implementation "com.google.dagger:hilt-android:2.29.1-alpha" 66 | kapt "com.google.dagger:hilt-android-compiler:2.29.1-alpha" 67 | implementation 'androidx.hilt:hilt-lifecycle-viewmodel:1.0.0-alpha02' 68 | kapt 'androidx.hilt:hilt-compiler:1.0.0-alpha02' 69 | 70 | // Fragment KTX 71 | implementation "androidx.fragment:fragment-ktx:1.2.5" 72 | 73 | // ViewModel 74 | implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0" 75 | // LiveData 76 | implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.2.0" 77 | // Annotation processor 78 | kapt "androidx.lifecycle:lifecycle-compiler:2.2.0" 79 | 80 | // Coroutines 81 | implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.2' 82 | 83 | // Retrofit 84 | implementation 'com.squareup.retrofit2:retrofit:2.9.0' 85 | implementation 'com.squareup.retrofit2:converter-gson:2.9.0' 86 | implementation 'com.squareup.okhttp3:logging-interceptor:4.9.0' 87 | 88 | // Dagger 89 | implementation 'com.google.dagger:dagger:2.29.1' 90 | kapt 'com.google.dagger:dagger-compiler:2.29.1' 91 | 92 | // Glide 93 | implementation 'com.github.bumptech.glide:glide:4.11.0' 94 | kapt 'com.github.bumptech.glide:compiler:4.11.0' 95 | 96 | // Recyclerview 97 | implementation "androidx.recyclerview:recyclerview:1.1.0" 98 | } -------------------------------------------------------------------------------- /app/data/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /app/data/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'com.android.library' 3 | id 'kotlin-android' 4 | } 5 | 6 | android { 7 | compileSdkVersion 30 8 | buildToolsVersion "30.0.2" 9 | 10 | defaultConfig { 11 | minSdkVersion 26 12 | targetSdkVersion 30 13 | versionCode 1 14 | versionName "1.0" 15 | 16 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 17 | consumerProguardFiles "consumer-rules.pro" 18 | } 19 | 20 | buildTypes { 21 | release { 22 | minifyEnabled false 23 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 24 | } 25 | } 26 | compileOptions { 27 | sourceCompatibility JavaVersion.VERSION_1_8 28 | targetCompatibility JavaVersion.VERSION_1_8 29 | } 30 | kotlinOptions { 31 | jvmTarget = '1.8' 32 | } 33 | } 34 | 35 | dependencies { 36 | 37 | implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" 38 | implementation 'androidx.core:core-ktx:1.3.2' 39 | implementation 'androidx.appcompat:appcompat:1.2.0' 40 | implementation 'com.google.android.material:material:1.2.1' 41 | testImplementation 'junit:junit:4.+' 42 | androidTestImplementation 'androidx.test.ext:junit:1.1.2' 43 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' 44 | } -------------------------------------------------------------------------------- /app/data/consumer-rules.pro: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OverLordAct/HiltCleanArchitecture/f037d83b79c11f3d2026d328765c16eed988558e/app/data/consumer-rules.pro -------------------------------------------------------------------------------- /app/data/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 -------------------------------------------------------------------------------- /app/data/src/androidTest/java/com/joydeep/data/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package com.joydeep.data 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.joydeep.data.test", appContext.packageName) 23 | } 24 | } -------------------------------------------------------------------------------- /app/data/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | -------------------------------------------------------------------------------- /app/data/src/test/java/com/joydeep/data/ExampleUnitTest.kt: -------------------------------------------------------------------------------- 1 | package com.joydeep.data 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 | } -------------------------------------------------------------------------------- /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. 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/joydeep/hiltcleanarchitecture/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package com.joydeep.hiltcleanarchitecture 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.joydeep.hiltcleanarchitecture", appContext.packageName) 23 | } 24 | } -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /app/src/main/java/com/joydeep/hiltcleanarchitecture/HiltCleanArchitectureApplication.kt: -------------------------------------------------------------------------------- 1 | package com.joydeep.hiltcleanarchitecture 2 | 3 | import android.app.Application 4 | import dagger.hilt.android.HiltAndroidApp 5 | 6 | @HiltAndroidApp 7 | class HiltCleanArchitectureApplication: Application() -------------------------------------------------------------------------------- /app/src/main/java/com/joydeep/hiltcleanarchitecture/account/view/AccountActivity.kt: -------------------------------------------------------------------------------- 1 | package com.joydeep.hiltcleanarchitecture.account.view 2 | 3 | import android.content.Intent 4 | import android.os.Bundle 5 | import androidx.activity.viewModels 6 | import androidx.appcompat.app.AppCompatActivity 7 | import com.joydeep.hiltcleanarchitecture.account.viewmodel.AccountActivityViewModel 8 | import com.joydeep.hiltcleanarchitecture.databinding.ActivityAccountBinding 9 | import com.joydeep.hiltcleanarchitecture.login.view.LoginActivity 10 | import dagger.hilt.android.AndroidEntryPoint 11 | 12 | @AndroidEntryPoint 13 | class AccountActivity : AppCompatActivity() { 14 | 15 | private val viewModel: AccountActivityViewModel by viewModels() 16 | private lateinit var binding: ActivityAccountBinding 17 | 18 | override fun onCreate(savedInstanceState: Bundle?) { 19 | super.onCreate(savedInstanceState) 20 | binding = ActivityAccountBinding.inflate(layoutInflater) 21 | setContentView(binding.root) 22 | 23 | binding.refreshButton.setOnClickListener { 24 | viewModel.refreshNotification() 25 | } 26 | 27 | binding.logoutButton.setOnClickListener { 28 | viewModel.logout() 29 | val intent = Intent(this, LoginActivity::class.java) 30 | intent.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP or 31 | Intent.FLAG_ACTIVITY_CLEAR_TASK or 32 | Intent.FLAG_ACTIVITY_NEW_TASK 33 | startActivity(intent) 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /app/src/main/java/com/joydeep/hiltcleanarchitecture/account/viewmodel/AccountActivityViewModel.kt: -------------------------------------------------------------------------------- 1 | package com.joydeep.hiltcleanarchitecture.account.viewmodel 2 | 3 | import android.util.Log 4 | import androidx.hilt.lifecycle.ViewModelInject 5 | import androidx.lifecycle.ViewModel 6 | import com.joydeep.domain.login.repository.UserDataRepository 7 | import com.joydeep.hiltcleanarchitecture.login.di.entryPoint.UserComponentEntryPoint 8 | import com.joydeep.hiltcleanarchitecture.login.di.handler.UserComponentHandler 9 | import dagger.hilt.EntryPoints 10 | 11 | class AccountActivityViewModel @ViewModelInject constructor( 12 | private val userComponentHandler: UserComponentHandler 13 | ) : ViewModel() { 14 | 15 | private var userDataRepository: UserDataRepository 16 | 17 | init { 18 | val entryPoint = EntryPoints.get(userComponentHandler, UserComponentEntryPoint::class.java) 19 | userDataRepository = entryPoint.getUserDataRepository() 20 | } 21 | 22 | fun logout() { 23 | userComponentHandler.logout() 24 | } 25 | 26 | fun refreshNotification() { 27 | userDataRepository.refreshNotification() 28 | Log.d("REPOSITORY", userDataRepository.toString()) 29 | } 30 | } -------------------------------------------------------------------------------- /app/src/main/java/com/joydeep/hiltcleanarchitecture/common/di/AppModule.kt: -------------------------------------------------------------------------------- 1 | package com.joydeep.hiltcleanarchitecture.common.di 2 | 3 | import android.content.Context 4 | import android.content.SharedPreferences 5 | import com.joydeep.hiltcleanarchitecture.login.di.handler.UserComponentHandler 6 | import com.joydeep.hiltcleanarchitecture.login.di.handler.UserComponentHandlerImpl 7 | import dagger.Module 8 | import dagger.Provides 9 | import dagger.hilt.InstallIn 10 | import dagger.hilt.android.qualifiers.ApplicationContext 11 | import dagger.hilt.components.SingletonComponent 12 | import javax.inject.Singleton 13 | 14 | @Module 15 | @InstallIn(SingletonComponent::class) 16 | class AppModule { 17 | @Provides 18 | @Singleton 19 | fun getLocalStorage(@ApplicationContext context: Context): SharedPreferences { 20 | return context.getSharedPreferences("Account", Context.MODE_PRIVATE) 21 | } 22 | 23 | @Provides 24 | @Singleton 25 | fun getUserComponentHandler(userComponentHandler: UserComponentHandlerImpl): UserComponentHandler { 26 | return userComponentHandler 27 | } 28 | } -------------------------------------------------------------------------------- /app/src/main/java/com/joydeep/hiltcleanarchitecture/common/di/LoggedInScope.kt: -------------------------------------------------------------------------------- 1 | package com.joydeep.hiltcleanarchitecture.common.di 2 | 3 | import javax.inject.Scope 4 | 5 | @Scope 6 | @MustBeDocumented 7 | @Retention(value = AnnotationRetention.RUNTIME) 8 | annotation class LoggedInScope 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/java/com/joydeep/hiltcleanarchitecture/common/di/NetworkModule.kt: -------------------------------------------------------------------------------- 1 | package com.joydeep.hiltcleanarchitecture.common.di 2 | 3 | import com.google.gson.Gson 4 | import com.google.gson.GsonBuilder 5 | import com.joydeep.data.login.api.Api 6 | import com.joydeep.data.login.repositoryImpl.UserRepositoryImpl 7 | import com.joydeep.domain.login.repository.UserRepository 8 | import dagger.Module 9 | import dagger.Provides 10 | import dagger.hilt.InstallIn 11 | import dagger.hilt.android.components.ApplicationComponent 12 | import okhttp3.OkHttpClient 13 | import okhttp3.logging.HttpLoggingInterceptor 14 | import retrofit2.Retrofit 15 | import retrofit2.converter.gson.GsonConverterFactory 16 | import javax.inject.Singleton 17 | 18 | @Module 19 | @InstallIn(ApplicationComponent::class) 20 | class NetworkModule { 21 | 22 | private val baseUrl = "https://reqres.in" 23 | 24 | @Singleton 25 | @Provides 26 | fun provideGsonBuilder(): Gson { 27 | return GsonBuilder() 28 | .excludeFieldsWithoutExposeAnnotation() 29 | .create() 30 | } 31 | 32 | @Singleton 33 | @Provides 34 | fun providesRetrofitBuilder(okHttpClient: OkHttpClient): Retrofit.Builder { 35 | return Retrofit.Builder() 36 | .baseUrl(baseUrl) 37 | .client(okHttpClient) 38 | .addConverterFactory(GsonConverterFactory.create()) 39 | } 40 | 41 | @Singleton 42 | @Provides 43 | fun providesAPI(retrofit: Retrofit.Builder): Api { 44 | return retrofit.build().create(Api::class.java) 45 | } 46 | 47 | @Singleton 48 | @Provides 49 | fun providesUserRepository(userRepository: UserRepositoryImpl): UserRepository { 50 | return userRepository 51 | } 52 | 53 | @Provides 54 | @Singleton 55 | fun providesLoggingInterceptor(): OkHttpClient { 56 | val httpInterceptor = HttpLoggingInterceptor() 57 | httpInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY) 58 | 59 | return OkHttpClient.Builder() 60 | .addInterceptor(httpInterceptor) 61 | .build() 62 | } 63 | } -------------------------------------------------------------------------------- /app/src/main/java/com/joydeep/hiltcleanarchitecture/common/utils/Extensions.kt: -------------------------------------------------------------------------------- 1 | package com.joydeep.hiltcleanarchitecture.common.utils 2 | 3 | import android.app.Activity 4 | import android.content.Context 5 | import android.view.View 6 | import android.view.inputmethod.InputMethodManager 7 | 8 | fun View.hideKeyboard(context: Context) { 9 | val imm = context.getSystemService(Activity.INPUT_METHOD_SERVICE) as InputMethodManager 10 | imm.hideSoftInputFromWindow(this.windowToken, 0) 11 | } -------------------------------------------------------------------------------- /app/src/main/java/com/joydeep/hiltcleanarchitecture/dashboard/view/DashboardActivity.kt: -------------------------------------------------------------------------------- 1 | package com.joydeep.hiltcleanarchitecture.dashboard.view 2 | 3 | import android.content.Intent 4 | import android.os.Bundle 5 | import androidx.activity.viewModels 6 | import androidx.appcompat.app.AppCompatActivity 7 | import com.joydeep.hiltcleanarchitecture.account.view.AccountActivity 8 | import com.joydeep.hiltcleanarchitecture.dashboard.viewmodel.DashBoardActivityViewModel 9 | import com.joydeep.hiltcleanarchitecture.databinding.ActivityDashboardBinding 10 | import com.joydeep.hiltcleanarchitecture.employee.view.EmployeeActivity 11 | import dagger.hilt.android.AndroidEntryPoint 12 | 13 | @AndroidEntryPoint 14 | class DashboardActivity : AppCompatActivity() { 15 | 16 | private val viewModel: DashBoardActivityViewModel by viewModels() 17 | private lateinit var binding: ActivityDashboardBinding 18 | 19 | override fun onCreate(savedInstanceState: Bundle?) { 20 | super.onCreate(savedInstanceState) 21 | binding = ActivityDashboardBinding.inflate(layoutInflater) 22 | setContentView(binding.root) 23 | 24 | viewModel.userDataLiveData.observe(this) { 25 | val username = it?.username 26 | binding.nameText.text = "Welcome back $username" 27 | } 28 | 29 | viewModel.notificationLiveData.observe(this) { 30 | val notification = it 31 | binding.notificationText.text = "You have $notification unread notifications!" 32 | } 33 | 34 | binding.accountButton.setOnClickListener { 35 | startActivity(Intent(this, AccountActivity::class.java)) 36 | } 37 | 38 | binding.coworkersButton.setOnClickListener { 39 | startActivity(Intent(this, EmployeeActivity::class.java)) 40 | } 41 | } 42 | 43 | override fun onResume() { 44 | super.onResume() 45 | viewModel.getNotifications() 46 | } 47 | } -------------------------------------------------------------------------------- /app/src/main/java/com/joydeep/hiltcleanarchitecture/dashboard/viewmodel/DashBoardActivityViewModel.kt: -------------------------------------------------------------------------------- 1 | package com.joydeep.hiltcleanarchitecture.dashboard.viewmodel 2 | 3 | import android.util.Log 4 | import androidx.hilt.lifecycle.ViewModelInject 5 | import androidx.lifecycle.MutableLiveData 6 | import androidx.lifecycle.ViewModel 7 | import com.joydeep.domain.login.repository.UserDataRepository 8 | import com.joydeep.hiltcleanarchitecture.login.di.entryPoint.UserComponentEntryPoint 9 | import com.joydeep.hiltcleanarchitecture.login.di.handler.UserComponentHandler 10 | import com.joydeep.hiltcleanarchitecture.login.entity.LoggedInUser 11 | import dagger.hilt.EntryPoints 12 | 13 | class DashBoardActivityViewModel @ViewModelInject constructor( 14 | private val userComponentHandler: UserComponentHandler 15 | ) : ViewModel() { 16 | var userDataLiveData = MutableLiveData() 17 | var notificationLiveData = MutableLiveData() 18 | private var userDataRepository: UserDataRepository 19 | 20 | init { 21 | val entryPoint = EntryPoints.get(userComponentHandler, UserComponentEntryPoint::class.java) 22 | userDataLiveData.value = entryPoint.getLoggedInUser() 23 | userDataRepository = entryPoint.getUserDataRepository() 24 | 25 | userDataRepository.refreshNotification() 26 | Log.d("REPOSITORY", userDataRepository.toString()) 27 | } 28 | 29 | fun getNotifications() { 30 | Log.d("REPOSITORY", userDataRepository.toString()) 31 | notificationLiveData.value = userDataRepository.unreadNotification 32 | } 33 | } -------------------------------------------------------------------------------- /app/src/main/java/com/joydeep/hiltcleanarchitecture/employee/view/EmployeeActivity.kt: -------------------------------------------------------------------------------- 1 | package com.joydeep.hiltcleanarchitecture.employee.view 2 | 3 | import android.os.Bundle 4 | import android.view.View 5 | import android.widget.Toast 6 | import androidx.activity.viewModels 7 | import androidx.appcompat.app.AppCompatActivity 8 | import androidx.recyclerview.widget.LinearLayoutManager 9 | import com.joydeep.domain.login.entity.UsersResponse 10 | import com.joydeep.hiltcleanarchitecture.common.utils.hideKeyboard 11 | import com.joydeep.hiltcleanarchitecture.databinding.ActivityEmployeeBinding 12 | import com.joydeep.hiltcleanarchitecture.employee.view.adapter.EmployeeAdapter 13 | import com.joydeep.hiltcleanarchitecture.employee.viewmodel.EmployeeActivityViewModel 14 | import com.joydeep.hiltcleanarchitecture.employee.viewmodel.UserStatus 15 | import dagger.hilt.android.AndroidEntryPoint 16 | 17 | 18 | @AndroidEntryPoint 19 | class EmployeeActivity : AppCompatActivity() { 20 | 21 | private val viewModel: EmployeeActivityViewModel by viewModels() 22 | private lateinit var binding: ActivityEmployeeBinding 23 | private lateinit var adapter: EmployeeAdapter 24 | 25 | override fun onCreate(savedInstanceState: Bundle?) { 26 | super.onCreate(savedInstanceState) 27 | binding = ActivityEmployeeBinding.inflate(layoutInflater) 28 | setContentView(binding.root) 29 | 30 | viewModel.userStatusLiveData.observe(this, ::userStatusUpdate) 31 | 32 | binding.getAllButton.setOnClickListener { 33 | viewModel.getAllUsers(1) 34 | it.hideKeyboard(this) 35 | } 36 | 37 | binding.getUserButton.setOnClickListener { 38 | val id = binding.userIdInput.text.toString().toInt() 39 | 40 | viewModel.getUser(id) 41 | it.hideKeyboard(this) 42 | } 43 | 44 | setRecyclerView() 45 | } 46 | 47 | private fun userStatusUpdate(result: UserStatus>) { 48 | when (result) { 49 | is UserStatus.Loading -> { 50 | binding.progress.visibility = View.VISIBLE 51 | } 52 | is UserStatus.Success -> { 53 | binding.progress.visibility = View.GONE 54 | 55 | adapter.updateData(result.data) 56 | } 57 | 58 | is UserStatus.Failure -> { 59 | binding.progress.visibility = View.GONE 60 | Toast.makeText(this, "Error: ${result.message}", Toast.LENGTH_SHORT).show() 61 | } 62 | } 63 | } 64 | 65 | private fun setRecyclerView() { 66 | val linearLayoutManager = LinearLayoutManager(this) 67 | binding.recycler.layoutManager = linearLayoutManager 68 | adapter = EmployeeAdapter(mutableListOf()) 69 | binding.recycler.adapter = adapter 70 | } 71 | } -------------------------------------------------------------------------------- /app/src/main/java/com/joydeep/hiltcleanarchitecture/employee/view/adapter/EmployeeAdapter.kt: -------------------------------------------------------------------------------- 1 | package com.joydeep.hiltcleanarchitecture.employee.view.adapter 2 | 3 | import android.view.LayoutInflater 4 | import android.view.ViewGroup 5 | import androidx.recyclerview.widget.RecyclerView 6 | import com.bumptech.glide.Glide 7 | import com.joydeep.domain.login.entity.UsersResponse 8 | import com.joydeep.hiltcleanarchitecture.R 9 | import com.joydeep.hiltcleanarchitecture.databinding.ViewUserBinding 10 | 11 | class EmployeeAdapter( 12 | private val usersList: MutableList 13 | ) : RecyclerView.Adapter() { 14 | override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): EmployeeViewHolder { 15 | return EmployeeViewHolder(parent) 16 | } 17 | 18 | override fun onBindViewHolder(holder: EmployeeViewHolder, position: Int) { 19 | holder.setData(usersList[position]) 20 | } 21 | 22 | override fun getItemCount(): Int = usersList.size 23 | 24 | fun updateData(usersList: List) { 25 | this.usersList.clear() 26 | this.usersList.addAll(usersList) 27 | notifyDataSetChanged() 28 | } 29 | 30 | class EmployeeViewHolder(private val parent: ViewGroup) : RecyclerView.ViewHolder( 31 | LayoutInflater.from(parent.context).inflate(R.layout.view_user, parent, false) 32 | ) { 33 | fun setData(user: UsersResponse.User) { 34 | val binding = ViewUserBinding.bind(itemView) 35 | 36 | // ID 37 | val userId = user.id 38 | binding.userId.text = "UserId: $userId" 39 | 40 | // Name 41 | val name = user.first_name + " " + user.last_name 42 | binding.userName.text = "Name: $name" 43 | 44 | // Email 45 | val email = user.email 46 | binding.userEmail.text = "Email: $email" 47 | 48 | // avatar 49 | val url = user.avatar 50 | Glide 51 | .with(parent) 52 | .load(url) 53 | .centerCrop() 54 | .into(binding.userIcon) 55 | } 56 | } 57 | } -------------------------------------------------------------------------------- /app/src/main/java/com/joydeep/hiltcleanarchitecture/employee/viewmodel/EmployeeActivityViewModel.kt: -------------------------------------------------------------------------------- 1 | package com.joydeep.hiltcleanarchitecture.employee.viewmodel 2 | 3 | import androidx.hilt.lifecycle.ViewModelInject 4 | import androidx.lifecycle.MutableLiveData 5 | import androidx.lifecycle.ViewModel 6 | import androidx.lifecycle.viewModelScope 7 | import com.joydeep.domain.common.usecase.BaseUseCase 8 | import com.joydeep.domain.login.entity.UserResponse 9 | import com.joydeep.domain.login.entity.UsersResponse 10 | import com.joydeep.domain.login.usecase.GetAllUsersUseCase 11 | import com.joydeep.domain.login.usecase.GetUserUseCase 12 | import kotlinx.coroutines.launch 13 | 14 | class EmployeeActivityViewModel @ViewModelInject constructor( 15 | private val getAllUsersUseCase: GetAllUsersUseCase, 16 | private val getUserUseCase: GetUserUseCase 17 | ) : ViewModel() { 18 | 19 | var userStatusLiveData = MutableLiveData>>() 20 | 21 | private val allUsersUseCaseCallback = object : BaseUseCase.Callback { 22 | override fun onSuccess(result: UsersResponse) { 23 | userStatusLiveData.value = UserStatus.Success(result.data) 24 | } 25 | 26 | override fun onError(throwable: Throwable) { 27 | userStatusLiveData.value = UserStatus.Failure(throwable.toString()) 28 | } 29 | } 30 | 31 | private val userUseCaseCallback = object : BaseUseCase.Callback { 32 | override fun onSuccess(result: UserResponse) { 33 | val userList = listOf(result.data) 34 | userStatusLiveData.value = UserStatus.Success(userList) 35 | } 36 | 37 | override fun onError(throwable: Throwable) { 38 | userStatusLiveData.value = UserStatus.Failure(throwable.toString()) 39 | } 40 | 41 | } 42 | 43 | fun getAllUsers(page: Int) { 44 | viewModelScope.launch { 45 | getAllUsersUseCase.execute(page, allUsersUseCaseCallback) 46 | } 47 | } 48 | 49 | fun getUser(id: Int) { 50 | viewModelScope.launch { 51 | getUserUseCase.execute(id, userUseCaseCallback) 52 | } 53 | } 54 | } -------------------------------------------------------------------------------- /app/src/main/java/com/joydeep/hiltcleanarchitecture/employee/viewmodel/UserStatus.kt: -------------------------------------------------------------------------------- 1 | package com.joydeep.hiltcleanarchitecture.employee.viewmodel 2 | 3 | sealed class UserStatus { 4 | object Loading: UserStatus() 5 | 6 | data class Success(val data: R): UserStatus() 7 | 8 | data class Failure(val message: String): UserStatus() 9 | } -------------------------------------------------------------------------------- /app/src/main/java/com/joydeep/hiltcleanarchitecture/login/di/component/UserComponent.kt: -------------------------------------------------------------------------------- 1 | package com.joydeep.hiltcleanarchitecture.login.di.component 2 | 3 | import com.joydeep.hiltcleanarchitecture.common.di.LoggedInScope 4 | import dagger.hilt.DefineComponent 5 | import dagger.hilt.components.SingletonComponent 6 | 7 | @LoggedInScope 8 | @DefineComponent(parent = SingletonComponent::class) 9 | interface UserComponent { 10 | @DefineComponent.Builder 11 | interface Factory { 12 | fun create(): UserComponent 13 | } 14 | } -------------------------------------------------------------------------------- /app/src/main/java/com/joydeep/hiltcleanarchitecture/login/di/entryPoint/UserComponentEntryPoint.kt: -------------------------------------------------------------------------------- 1 | package com.joydeep.hiltcleanarchitecture.login.di.entryPoint 2 | 3 | import com.joydeep.domain.login.repository.UserDataRepository 4 | import com.joydeep.hiltcleanarchitecture.login.di.component.UserComponent 5 | import com.joydeep.hiltcleanarchitecture.login.entity.LoggedInUser 6 | import dagger.hilt.EntryPoint 7 | import dagger.hilt.InstallIn 8 | 9 | @EntryPoint 10 | @InstallIn(UserComponent::class) 11 | interface UserComponentEntryPoint { 12 | fun getLoggedInUser(): LoggedInUser 13 | fun getUserDataRepository(): UserDataRepository 14 | } -------------------------------------------------------------------------------- /app/src/main/java/com/joydeep/hiltcleanarchitecture/login/di/handler/UserComponentHandler.kt: -------------------------------------------------------------------------------- 1 | package com.joydeep.hiltcleanarchitecture.login.di.handler 2 | 3 | interface UserComponentHandler { 4 | fun login(username: String, password: String) 5 | 6 | fun logout() 7 | 8 | fun isLoggedIn(): Boolean 9 | } -------------------------------------------------------------------------------- /app/src/main/java/com/joydeep/hiltcleanarchitecture/login/di/handler/UserComponentHandlerImpl.kt: -------------------------------------------------------------------------------- 1 | package com.joydeep.hiltcleanarchitecture.login.di.handler 2 | 3 | import android.content.SharedPreferences 4 | import com.joydeep.hiltcleanarchitecture.login.di.component.UserComponent 5 | import dagger.hilt.internal.GeneratedComponentManager 6 | import javax.inject.Inject 7 | import javax.inject.Singleton 8 | 9 | @Singleton 10 | class UserComponentHandlerImpl @Inject constructor( 11 | private val userComponentFactory: UserComponent.Factory, 12 | private val preferences: SharedPreferences 13 | ) : GeneratedComponentManager, UserComponentHandler { 14 | 15 | var userComponent: UserComponent? = null 16 | private set 17 | 18 | init { 19 | if (isLoggedIn()) { 20 | userComponent = userComponentFactory.create() 21 | } 22 | } 23 | 24 | override fun generatedComponent(): UserComponent { 25 | return userComponent!! 26 | } 27 | 28 | override fun login(username: String, password: String) { 29 | userComponent = userComponentFactory.create() 30 | preferences.edit() 31 | .putString("username", username) 32 | .putString("password", password) 33 | .apply() 34 | } 35 | 36 | override fun logout() { 37 | userComponent = null 38 | preferences.edit() 39 | .remove("username") 40 | .remove("password") 41 | .apply() 42 | } 43 | 44 | override fun isLoggedIn(): Boolean { 45 | val username = preferences.getString("username", "") 46 | return !username?.isEmpty()!! 47 | } 48 | } -------------------------------------------------------------------------------- /app/src/main/java/com/joydeep/hiltcleanarchitecture/login/di/module/UserModule.kt: -------------------------------------------------------------------------------- 1 | package com.joydeep.hiltcleanarchitecture.login.di.module 2 | 3 | import android.content.SharedPreferences 4 | import com.joydeep.data.login.repositoryImpl.UserDataRepositoryImpl 5 | import com.joydeep.domain.login.repository.UserDataRepository 6 | import com.joydeep.hiltcleanarchitecture.common.di.LoggedInScope 7 | import com.joydeep.hiltcleanarchitecture.login.di.component.UserComponent 8 | import com.joydeep.hiltcleanarchitecture.login.entity.LoggedInUser 9 | import dagger.Module 10 | import dagger.Provides 11 | import dagger.hilt.InstallIn 12 | 13 | @Module 14 | @InstallIn(UserComponent::class) 15 | class UserModule { 16 | @Provides 17 | @LoggedInScope 18 | fun providesUserData(preferences: SharedPreferences): LoggedInUser{ 19 | return LoggedInUser(preferences.getString("username", "Joydeep")!!) 20 | } 21 | 22 | @Provides 23 | @LoggedInScope 24 | fun providesUserDataRepository(userDataRepository: UserDataRepositoryImpl): UserDataRepository { 25 | return userDataRepository 26 | } 27 | } -------------------------------------------------------------------------------- /app/src/main/java/com/joydeep/hiltcleanarchitecture/login/entity/LoggedInUser.kt: -------------------------------------------------------------------------------- 1 | package com.joydeep.hiltcleanarchitecture.login.entity 2 | 3 | data class LoggedInUser( 4 | val username: String 5 | ) -------------------------------------------------------------------------------- /app/src/main/java/com/joydeep/hiltcleanarchitecture/login/view/LoginActivity.kt: -------------------------------------------------------------------------------- 1 | package com.joydeep.hiltcleanarchitecture.login.view 2 | 3 | import android.content.Intent 4 | import android.os.Bundle 5 | import android.widget.Toast 6 | import androidx.activity.viewModels 7 | import androidx.appcompat.app.AppCompatActivity 8 | import androidx.lifecycle.observe 9 | import com.joydeep.hiltcleanarchitecture.dashboard.view.DashboardActivity 10 | import com.joydeep.hiltcleanarchitecture.databinding.ActivityLoginBinding 11 | import com.joydeep.hiltcleanarchitecture.login.viewmodel.LoginActivityViewModel 12 | import com.joydeep.hiltcleanarchitecture.login.viewmodel.LoginStatus 13 | import dagger.hilt.android.AndroidEntryPoint 14 | 15 | @AndroidEntryPoint 16 | class LoginActivity : AppCompatActivity() { 17 | 18 | private val viewModel: LoginActivityViewModel by viewModels() 19 | private lateinit var binding: ActivityLoginBinding 20 | 21 | override fun onCreate(savedInstanceState: Bundle?) { 22 | super.onCreate(savedInstanceState) 23 | binding = ActivityLoginBinding.inflate(layoutInflater) 24 | setContentView(binding.root) 25 | 26 | viewModel.loginStatusLiveData.observe(this, ::onLoginStatusUpdate) 27 | 28 | binding.submitButton.setOnClickListener { 29 | val username = binding.userIdInput.text.toString() 30 | val password = binding.passwordInput.text.toString() 31 | 32 | viewModel.login(username, password) 33 | } 34 | } 35 | 36 | private fun onLoginStatusUpdate(loginStatus: LoginStatus) { 37 | when (loginStatus) { 38 | is LoginStatus.Success -> { 39 | val intent = Intent(this, DashboardActivity::class.java) 40 | startActivity(intent) 41 | finish() 42 | } 43 | is LoginStatus.Failure -> { 44 | Toast.makeText(this, "Something went wrong", Toast.LENGTH_SHORT).show() 45 | } 46 | } 47 | } 48 | } -------------------------------------------------------------------------------- /app/src/main/java/com/joydeep/hiltcleanarchitecture/login/viewmodel/LoginActivityViewModel.kt: -------------------------------------------------------------------------------- 1 | package com.joydeep.hiltcleanarchitecture.login.viewmodel 2 | 3 | import androidx.hilt.lifecycle.ViewModelInject 4 | import androidx.lifecycle.MutableLiveData 5 | import androidx.lifecycle.ViewModel 6 | import com.joydeep.hiltcleanarchitecture.login.di.handler.UserComponentHandler 7 | 8 | class LoginActivityViewModel @ViewModelInject constructor( 9 | private val userComponentHandler: UserComponentHandler 10 | ) : ViewModel() { 11 | var loginStatusLiveData = MutableLiveData() 12 | 13 | fun login(username: String, password: String) { 14 | userComponentHandler.login(username, password) 15 | loginStatusLiveData.value = LoginStatus.Success 16 | } 17 | } 18 | 19 | sealed class LoginStatus { 20 | object Success : LoginStatus() 21 | 22 | object Failure : LoginStatus() 23 | } -------------------------------------------------------------------------------- /app/src/main/java/com/joydeep/hiltcleanarchitecture/splash/view/SplashActivity.kt: -------------------------------------------------------------------------------- 1 | package com.joydeep.hiltcleanarchitecture.splash.view 2 | 3 | import android.content.Intent 4 | import android.os.Bundle 5 | import androidx.activity.viewModels 6 | import androidx.appcompat.app.AppCompatActivity 7 | import com.joydeep.hiltcleanarchitecture.dashboard.view.DashboardActivity 8 | import com.joydeep.hiltcleanarchitecture.databinding.ActivitySplashBinding 9 | import com.joydeep.hiltcleanarchitecture.login.view.LoginActivity 10 | import com.joydeep.hiltcleanarchitecture.splash.viewmodel.SplashActivityViewModel 11 | import dagger.hilt.android.AndroidEntryPoint 12 | 13 | @AndroidEntryPoint 14 | class SplashActivity : AppCompatActivity() { 15 | 16 | private val viewModel: SplashActivityViewModel by viewModels() 17 | private lateinit var binding: ActivitySplashBinding 18 | 19 | override fun onCreate(savedInstanceState: Bundle?) { 20 | super.onCreate(savedInstanceState) 21 | binding = ActivitySplashBinding.inflate(layoutInflater) 22 | setContentView(binding.root) 23 | 24 | viewModel.loginStatusLiveData.observe(this) { 25 | when (it) { 26 | true -> { 27 | startActivity(Intent(this, DashboardActivity::class.java)) 28 | } 29 | false -> { 30 | startActivity(Intent(this, LoginActivity::class.java)) 31 | } 32 | } 33 | finish() 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /app/src/main/java/com/joydeep/hiltcleanarchitecture/splash/viewmodel/SplashActivityViewModel.kt: -------------------------------------------------------------------------------- 1 | package com.joydeep.hiltcleanarchitecture.splash.viewmodel 2 | 3 | import androidx.hilt.lifecycle.ViewModelInject 4 | import androidx.lifecycle.MutableLiveData 5 | import androidx.lifecycle.ViewModel 6 | import androidx.lifecycle.viewModelScope 7 | import com.joydeep.hiltcleanarchitecture.login.di.handler.UserComponentHandler 8 | import kotlinx.coroutines.delay 9 | import kotlinx.coroutines.launch 10 | 11 | class SplashActivityViewModel @ViewModelInject constructor( 12 | userComponentHandler: UserComponentHandler 13 | ) : ViewModel() { 14 | 15 | var loginStatusLiveData = MutableLiveData() 16 | 17 | init { 18 | viewModelScope.launch { 19 | delay(2000) 20 | loginStatusLiveData.value = userComponentHandler.isLoggedIn() 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /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/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/layout/activity_account.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 19 | 20 | 30 | 31 | 41 | 42 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_dashboard.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 19 | 20 | 30 | 31 | 41 | 42 | 52 | 53 | 63 | 64 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_employee.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 19 | 20 | 29 | 30 | 36 | 37 | 38 | 39 | 49 | 50 | 60 | 61 | 72 | 73 | 82 | 83 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_login.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 19 | 20 | 29 | 30 | 35 | 36 | 37 | 38 | 47 | 48 | 54 | 55 | 56 | 57 | 66 | 67 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_splash.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 19 | 20 | -------------------------------------------------------------------------------- /app/src/main/res/layout/view_user.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 15 | 16 | 24 | 25 | 33 | 34 | 42 | 43 | -------------------------------------------------------------------------------- /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.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OverLordAct/HiltCleanArchitecture/f037d83b79c11f3d2026d328765c16eed988558e/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OverLordAct/HiltCleanArchitecture/f037d83b79c11f3d2026d328765c16eed988558e/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OverLordAct/HiltCleanArchitecture/f037d83b79c11f3d2026d328765c16eed988558e/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OverLordAct/HiltCleanArchitecture/f037d83b79c11f3d2026d328765c16eed988558e/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OverLordAct/HiltCleanArchitecture/f037d83b79c11f3d2026d328765c16eed988558e/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OverLordAct/HiltCleanArchitecture/f037d83b79c11f3d2026d328765c16eed988558e/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OverLordAct/HiltCleanArchitecture/f037d83b79c11f3d2026d328765c16eed988558e/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OverLordAct/HiltCleanArchitecture/f037d83b79c11f3d2026d328765c16eed988558e/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OverLordAct/HiltCleanArchitecture/f037d83b79c11f3d2026d328765c16eed988558e/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OverLordAct/HiltCleanArchitecture/f037d83b79c11f3d2026d328765c16eed988558e/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/values-night/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #FFBB86FC 4 | #FF6200EE 5 | #FF3700B3 6 | #FF03DAC5 7 | #FF018786 8 | #FF000000 9 | #FFFFFFFF 10 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | HiltCleanArchitecture 3 | -------------------------------------------------------------------------------- /app/src/main/res/values/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | -------------------------------------------------------------------------------- /app/src/test/java/com/joydeep/hiltcleanarchitecture/ExampleUnitTest.kt: -------------------------------------------------------------------------------- 1 | package com.joydeep.hiltcleanarchitecture 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 | } -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | buildscript { 3 | ext.kotlin_version = "1.4.21" 4 | repositories { 5 | google() 6 | jcenter() 7 | } 8 | dependencies { 9 | classpath "com.android.tools.build:gradle:4.1.1" 10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 11 | classpath 'com.google.dagger:hilt-android-gradle-plugin:2.28-alpha' 12 | 13 | // NOTE: Do not place your application dependencies here; they belong 14 | // in the individual module build.gradle files 15 | } 16 | } 17 | 18 | allprojects { 19 | repositories { 20 | google() 21 | jcenter() 22 | } 23 | } 24 | 25 | task clean(type: Delete) { 26 | delete rootProject.buildDir 27 | } -------------------------------------------------------------------------------- /data/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /data/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'com.android.library' 3 | id 'kotlin-android' 4 | } 5 | 6 | android { 7 | compileSdkVersion 30 8 | buildToolsVersion "30.0.2" 9 | 10 | defaultConfig { 11 | minSdkVersion 26 12 | targetSdkVersion 30 13 | versionCode 1 14 | versionName "1.0" 15 | 16 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 17 | consumerProguardFiles "consumer-rules.pro" 18 | } 19 | 20 | buildTypes { 21 | release { 22 | minifyEnabled false 23 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 24 | } 25 | } 26 | compileOptions { 27 | sourceCompatibility JavaVersion.VERSION_1_8 28 | targetCompatibility JavaVersion.VERSION_1_8 29 | } 30 | kotlinOptions { 31 | jvmTarget = '1.8' 32 | } 33 | } 34 | 35 | dependencies { 36 | api project(':domain') 37 | 38 | implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" 39 | implementation 'androidx.core:core-ktx:1.3.2' 40 | implementation 'androidx.appcompat:appcompat:1.2.0' 41 | implementation 'com.google.android.material:material:1.2.1' 42 | testImplementation 'junit:junit:4.+' 43 | androidTestImplementation 'androidx.test.ext:junit:1.1.2' 44 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' 45 | 46 | implementation 'com.squareup.retrofit2:retrofit:2.9.0' 47 | implementation 'com.squareup.retrofit2:converter-gson:2.9.0' 48 | 49 | api group: 'javax.inject', name: 'javax.inject', version: '1' 50 | } -------------------------------------------------------------------------------- /data/consumer-rules.pro: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OverLordAct/HiltCleanArchitecture/f037d83b79c11f3d2026d328765c16eed988558e/data/consumer-rules.pro -------------------------------------------------------------------------------- /data/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 -------------------------------------------------------------------------------- /data/src/androidTest/java/com/joydeep/data/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package com.joydeep.data 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.joydeep.data.test", appContext.packageName) 23 | } 24 | } -------------------------------------------------------------------------------- /data/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | -------------------------------------------------------------------------------- /data/src/main/java/com/joydeep/data/login/api/Api.kt: -------------------------------------------------------------------------------- 1 | package com.joydeep.data.login.api 2 | 3 | import com.joydeep.domain.login.entity.UserResponse 4 | import com.joydeep.domain.login.entity.UsersResponse 5 | import retrofit2.http.GET 6 | import retrofit2.http.Path 7 | import retrofit2.http.Query 8 | 9 | interface Api { 10 | @GET("/api/users") 11 | suspend fun getUsers(@Query("page") page: Int): UsersResponse 12 | 13 | @GET("/api/users/{userId}") 14 | suspend fun getUser(@Path("userId") userId: Int): UserResponse 15 | } -------------------------------------------------------------------------------- /data/src/main/java/com/joydeep/data/login/repositoryImpl/UserDataRepositoryImpl.kt: -------------------------------------------------------------------------------- 1 | package com.joydeep.data.login.repositoryImpl 2 | 3 | import com.joydeep.domain.login.repository.UserDataRepository 4 | import javax.inject.Inject 5 | import kotlin.random.Random 6 | 7 | class UserDataRepositoryImpl @Inject constructor() : UserDataRepository { 8 | override var unreadNotification: Int = 0 9 | 10 | init { 11 | unreadNotification = refreshNotification() 12 | } 13 | 14 | override fun refreshNotification(): Int { 15 | val newNotification = Random.nextInt(until = 200) 16 | unreadNotification = newNotification 17 | return newNotification 18 | } 19 | } -------------------------------------------------------------------------------- /data/src/main/java/com/joydeep/data/login/repositoryImpl/UserRepositoryImpl.kt: -------------------------------------------------------------------------------- 1 | package com.joydeep.data.login.repositoryImpl 2 | 3 | import com.joydeep.data.login.api.Api 4 | import com.joydeep.domain.login.entity.UserResponse 5 | import com.joydeep.domain.login.entity.UsersResponse 6 | import com.joydeep.domain.login.repository.UserRepository 7 | import javax.inject.Inject 8 | 9 | class UserRepositoryImpl @Inject constructor(private val api: Api): UserRepository { 10 | override suspend fun getUsers(page: Int): UsersResponse { 11 | return api.getUsers(page) 12 | } 13 | 14 | override suspend fun getUser(userId: Int): UserResponse { 15 | return api.getUser(userId) 16 | } 17 | } -------------------------------------------------------------------------------- /data/src/test/java/com/joydeep/data/ExampleUnitTest.kt: -------------------------------------------------------------------------------- 1 | package com.joydeep.data 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 | } -------------------------------------------------------------------------------- /domain/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /domain/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'java-library' 3 | id 'kotlin' 4 | } 5 | 6 | java { 7 | sourceCompatibility = JavaVersion.VERSION_1_7 8 | targetCompatibility = JavaVersion.VERSION_1_7 9 | } 10 | 11 | dependencies { 12 | implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" 13 | implementation 'com.google.code.gson:gson:2.8.6' 14 | compile group: 'javax.inject', name: 'javax.inject', version: '1' 15 | } -------------------------------------------------------------------------------- /domain/src/main/java/com/joydeep/domain/common/usecase/BaseUseCase.kt: -------------------------------------------------------------------------------- 1 | package com.joydeep.domain.common.usecase 2 | 3 | interface BaseUseCase { 4 | interface Callback { 5 | fun onSuccess(result: R) 6 | fun onError(throwable: Throwable) 7 | } 8 | 9 | suspend fun execute(params: P, callback: Callback) 10 | } -------------------------------------------------------------------------------- /domain/src/main/java/com/joydeep/domain/login/entity/UserResponse.kt: -------------------------------------------------------------------------------- 1 | package com.joydeep.domain.login.entity 2 | 3 | import com.google.gson.annotations.SerializedName 4 | 5 | data class UserResponse( 6 | @SerializedName("data") 7 | val `data`: UsersResponse.User, 8 | @SerializedName("support") 9 | val support: Support 10 | ) { 11 | data class Support( 12 | @SerializedName("text") 13 | val text: String, 14 | @SerializedName("url") 15 | val url: String 16 | ) 17 | } -------------------------------------------------------------------------------- /domain/src/main/java/com/joydeep/domain/login/entity/UsersResponse.kt: -------------------------------------------------------------------------------- 1 | package com.joydeep.domain.login.entity 2 | 3 | import com.google.gson.annotations.SerializedName 4 | 5 | data class UsersResponse( 6 | @SerializedName("page") val page: Int, 7 | @SerializedName("per_page") val per_page: Int, 8 | @SerializedName("total") val total: Int, 9 | @SerializedName("total_pages") val total_pages: Int, 10 | @SerializedName("data") val data: List, 11 | @SerializedName("support") val support: Support 12 | ) { 13 | data class User( 14 | @SerializedName("id") val id: Int, 15 | @SerializedName("email") val email: String, 16 | @SerializedName("first_name") val first_name: String, 17 | @SerializedName("last_name") val last_name: String, 18 | @SerializedName("avatar") val avatar: String 19 | ) 20 | 21 | data class Support( 22 | @SerializedName("url") val url: String, 23 | @SerializedName("text") val text: String 24 | ) 25 | } 26 | 27 | -------------------------------------------------------------------------------- /domain/src/main/java/com/joydeep/domain/login/repository/UserDataRepository.kt: -------------------------------------------------------------------------------- 1 | package com.joydeep.domain.login.repository 2 | 3 | interface UserDataRepository { 4 | var unreadNotification: Int 5 | 6 | fun refreshNotification(): Int 7 | } -------------------------------------------------------------------------------- /domain/src/main/java/com/joydeep/domain/login/repository/UserRepository.kt: -------------------------------------------------------------------------------- 1 | package com.joydeep.domain.login.repository 2 | 3 | import com.joydeep.domain.login.entity.UserResponse 4 | import com.joydeep.domain.login.entity.UsersResponse 5 | 6 | interface UserRepository { 7 | suspend fun getUsers(page: Int): UsersResponse 8 | 9 | suspend fun getUser(userId: Int): UserResponse 10 | } -------------------------------------------------------------------------------- /domain/src/main/java/com/joydeep/domain/login/usecase/GetAllUsersUseCase.kt: -------------------------------------------------------------------------------- 1 | package com.joydeep.domain.login.usecase 2 | 3 | import com.joydeep.domain.common.usecase.BaseUseCase 4 | import com.joydeep.domain.login.entity.UsersResponse 5 | import com.joydeep.domain.login.repository.UserRepository 6 | import javax.inject.Inject 7 | 8 | class GetAllUsersUseCase @Inject constructor(private val userRepository: UserRepository) : 9 | BaseUseCase { 10 | override suspend fun execute(params: Int, callback: BaseUseCase.Callback) { 11 | try { 12 | val result = userRepository.getUsers(params) 13 | callback.onSuccess(result) 14 | } catch (e: Exception) { 15 | callback.onError(e) 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /domain/src/main/java/com/joydeep/domain/login/usecase/GetUserUseCase.kt: -------------------------------------------------------------------------------- 1 | package com.joydeep.domain.login.usecase 2 | 3 | import com.joydeep.domain.common.usecase.BaseUseCase 4 | import com.joydeep.domain.login.entity.UserResponse 5 | import com.joydeep.domain.login.repository.UserRepository 6 | import javax.inject.Inject 7 | 8 | class GetUserUseCase @Inject constructor(private val userRepository: UserRepository) : 9 | BaseUseCase { 10 | override suspend fun execute(params: Int, callback: BaseUseCase.Callback) { 11 | try { 12 | val result = userRepository.getUser(params) 13 | callback.onSuccess(result) 14 | } catch (e: Exception) { 15 | callback.onError(e) 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /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 | # Automatically convert third-party libraries to use AndroidX 19 | android.enableJetifier=true 20 | # Kotlin code style for this project: "official" or "obsolete": 21 | kotlin.code.style=official -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OverLordAct/HiltCleanArchitecture/f037d83b79c11f3d2026d328765c16eed988558e/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Tue Dec 15 23:32:15 IST 2020 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Attempt to set APP_HOME 10 | # Resolve links: $0 may be a link 11 | PRG="$0" 12 | # Need this for relative symlinks. 13 | while [ -h "$PRG" ] ; do 14 | ls=`ls -ld "$PRG"` 15 | link=`expr "$ls" : '.*-> \(.*\)$'` 16 | if expr "$link" : '/.*' > /dev/null; then 17 | PRG="$link" 18 | else 19 | PRG=`dirname "$PRG"`"/$link" 20 | fi 21 | done 22 | SAVED="`pwd`" 23 | cd "`dirname \"$PRG\"`/" >/dev/null 24 | APP_HOME="`pwd -P`" 25 | cd "$SAVED" >/dev/null 26 | 27 | APP_NAME="Gradle" 28 | APP_BASE_NAME=`basename "$0"` 29 | 30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 31 | DEFAULT_JVM_OPTS="" 32 | 33 | # Use the maximum available, or set MAX_FD != -1 to use that value. 34 | MAX_FD="maximum" 35 | 36 | warn () { 37 | echo "$*" 38 | } 39 | 40 | die () { 41 | echo 42 | echo "$*" 43 | echo 44 | exit 1 45 | } 46 | 47 | # OS specific support (must be 'true' or 'false'). 48 | cygwin=false 49 | msys=false 50 | darwin=false 51 | nonstop=false 52 | case "`uname`" in 53 | CYGWIN* ) 54 | cygwin=true 55 | ;; 56 | Darwin* ) 57 | darwin=true 58 | ;; 59 | MINGW* ) 60 | msys=true 61 | ;; 62 | NONSTOP* ) 63 | nonstop=true 64 | ;; 65 | esac 66 | 67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 68 | 69 | # Determine the Java command to use to start the JVM. 70 | if [ -n "$JAVA_HOME" ] ; then 71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 72 | # IBM's JDK on AIX uses strange locations for the executables 73 | JAVACMD="$JAVA_HOME/jre/sh/java" 74 | else 75 | JAVACMD="$JAVA_HOME/bin/java" 76 | fi 77 | if [ ! -x "$JAVACMD" ] ; then 78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 79 | 80 | Please set the JAVA_HOME variable in your environment to match the 81 | location of your Java installation." 82 | fi 83 | else 84 | JAVACMD="java" 85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 86 | 87 | Please set the JAVA_HOME variable in your environment to match the 88 | location of your Java installation." 89 | fi 90 | 91 | # Increase the maximum file descriptors if we can. 92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 93 | MAX_FD_LIMIT=`ulimit -H -n` 94 | if [ $? -eq 0 ] ; then 95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 96 | MAX_FD="$MAX_FD_LIMIT" 97 | fi 98 | ulimit -n $MAX_FD 99 | if [ $? -ne 0 ] ; then 100 | warn "Could not set maximum file descriptor limit: $MAX_FD" 101 | fi 102 | else 103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 104 | fi 105 | fi 106 | 107 | # For Darwin, add options to specify how the application appears in the dock 108 | if $darwin; then 109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 110 | fi 111 | 112 | # For Cygwin, switch paths to Windows format before running java 113 | if $cygwin ; then 114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 116 | JAVACMD=`cygpath --unix "$JAVACMD"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Escape application args 158 | save () { 159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 160 | echo " " 161 | } 162 | APP_ARGS=$(save "$@") 163 | 164 | # Collect all arguments for the java command, following the shell quoting and substitution rules 165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 166 | 167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 169 | cd "$(dirname "$0")" 170 | fi 171 | 172 | exec "$JAVACMD" "$@" 173 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':domain' 2 | include ':data' 3 | include ':app' 4 | rootProject.name = "HiltCleanArchitecture" --------------------------------------------------------------------------------