├── .gitignore ├── .idea ├── .name ├── codeStyles │ ├── Project.xml │ └── codeStyleConfig.xml ├── compiler.xml ├── gradle.xml ├── jarRepositories.xml ├── misc.xml ├── runConfigurations.xml └── vcs.xml ├── AppNavigator ├── .gitignore ├── build.gradle ├── consumer-rules.pro ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── mvvm │ │ └── appnavigator │ │ └── ExampleInstrumentedTest.kt │ ├── main │ ├── AndroidManifest.xml │ └── java │ │ └── com │ │ └── mvvm │ │ └── appnavigator │ │ └── NavigationHelper.kt │ └── test │ └── java │ └── com │ └── mvvm │ └── appnavigator │ └── ExampleUnitTest.kt ├── BottomSheet ├── .gitignore ├── build.gradle ├── consumer-rules.pro ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── bottomsheet │ │ └── ExampleInstrumentedTest.kt │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── bottomsheet │ │ │ └── BottomSheetActivity.kt │ └── res │ │ ├── layout │ │ ├── activity_bottom_sheet.xml │ │ ├── bottomsheet_layout.xml │ │ └── layout_bottom_sheet_dialog.xml │ │ └── values │ │ └── strings.xml │ └── test │ └── java │ └── com │ └── bottomsheet │ └── ExampleUnitTest.kt ├── Common ├── .gitignore ├── build.gradle ├── consumer-rules.pro ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── mvvm │ │ └── common │ │ └── ExampleInstrumentedTest.kt │ ├── main │ ├── AndroidManifest.xml │ ├── ic_default_icon-playstore.png │ ├── java │ │ └── com │ │ │ └── mvvm │ │ │ └── common │ │ │ ├── CommonActivity.kt │ │ │ ├── di │ │ │ ├── RetroRxModule.kt │ │ │ └── RetroURL.kt │ │ │ ├── modalbottomsheetdialog │ │ │ ├── ModalBottomSheet.kt │ │ │ └── ModalCustomBottomSheet.kt │ │ │ └── utils │ │ │ ├── SharedPreferencesHelper.kt │ │ │ └── Utils.kt │ └── res │ │ ├── drawable │ │ └── ic_default_icon_foreground.xml │ │ ├── layout │ │ ├── activity_common.xml │ │ ├── bottomsheet_common_layout.xml │ │ ├── modal_bottom_sheet_dialog.xml │ │ └── toolbar_layout.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_default_icon.xml │ │ └── ic_default_icon_round.xml │ │ ├── mipmap-hdpi │ │ ├── ic_default_icon.png │ │ ├── ic_default_icon_background.png │ │ └── ic_default_icon_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_default_icon.png │ │ ├── ic_default_icon_background.png │ │ └── ic_default_icon_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_default_icon.png │ │ ├── ic_default_icon_background.png │ │ └── ic_default_icon_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_default_icon.png │ │ ├── ic_default_icon_background.png │ │ └── ic_default_icon_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_default_icon.png │ │ ├── ic_default_icon_background.png │ │ └── ic_default_icon_round.png │ │ └── values │ │ ├── dimens.xml │ │ └── strings.xml │ └── test │ └── java │ └── com │ └── mvvm │ └── common │ └── ExampleUnitTest.kt ├── DaggerPractice ├── .gitignore ├── build.gradle ├── consumer-rules.pro ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── dagger │ │ └── practice │ │ └── ExampleInstrumentedTest.kt │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── dagger │ │ │ └── practice │ │ │ ├── AppApplication.kt │ │ │ ├── AppLevelSingletonActivity.kt │ │ │ ├── ConstructorInjectionActivity.kt │ │ │ ├── CricketActivity.kt │ │ │ ├── FieldInjection │ │ │ ├── Student.kt │ │ │ ├── StudentComponent.kt │ │ │ ├── StudentDetails.kt │ │ │ └── StudentModule.kt │ │ │ ├── FieldInjectionActivity.kt │ │ │ ├── InterfaceInjectionActivity.kt │ │ │ ├── NamedInjectionActivity.kt │ │ │ ├── SingletonInjectionActivity.kt │ │ │ ├── TennisActivity.kt │ │ │ ├── applevelsingletoInjection │ │ │ ├── AppComponent.kt │ │ │ ├── ApplicationModule.kt │ │ │ ├── Driver.kt │ │ │ ├── Passenger.kt │ │ │ ├── PassengerModule.kt │ │ │ ├── PerActivity.kt │ │ │ └── PerActivityComponent.kt │ │ │ ├── constructorDI │ │ │ ├── EmployeeInfoComponent.kt │ │ │ └── emp │ │ │ │ ├── EmpDetails.kt │ │ │ │ └── EmployeeInfo.kt │ │ │ ├── interfaceInjection │ │ │ ├── Doctor.kt │ │ │ ├── DoctorAge.kt │ │ │ ├── DoctorComponent.kt │ │ │ ├── DoctorType.kt │ │ │ ├── GovtDoctor.kt │ │ │ ├── GovtDoctorModule.kt │ │ │ ├── PrivateDoctor.kt │ │ │ └── PrivateDoctorModule.kt │ │ │ ├── namedInjection │ │ │ ├── Movie.kt │ │ │ ├── MovieComponent.kt │ │ │ ├── MovieDetails.kt │ │ │ └── MovieModule.kt │ │ │ ├── singletonInjection │ │ │ ├── Driver.kt │ │ │ ├── Student.kt │ │ │ ├── StudentComponent.kt │ │ │ └── StudentModule.kt │ │ │ └── subComponentInjection │ │ │ ├── Cricket.kt │ │ │ ├── CricketComponent.kt │ │ │ ├── CricketModule.kt │ │ │ ├── PerCricketActivity.kt │ │ │ ├── PerTennisActivity.kt │ │ │ ├── Sports.kt │ │ │ ├── SportsComponent.kt │ │ │ ├── SportsModule.kt │ │ │ ├── Tennis.kt │ │ │ ├── TennisComponent.kt │ │ │ └── TennisModule.kt │ └── res │ │ ├── layout │ │ ├── activity_app_level_singleton.xml │ │ ├── activity_constructor_injection.xml │ │ ├── activity_cricket.xml │ │ ├── activity_dagger_practice.xml │ │ ├── activity_field_injection.xml │ │ ├── activity_interface_injection.xml │ │ ├── activity_main.xml │ │ ├── activity_named_injection.xml │ │ ├── activity_singleton_injection.xml │ │ ├── activity_sub_component_main.xml │ │ ├── activity_sub_component_sub.xml │ │ └── activity_tennis.xml │ │ └── values │ │ └── strings.xml │ └── test │ └── java │ └── com │ └── dagger │ └── practice │ └── ExampleUnitTest.kt ├── KotlinPractice ├── .gitignore ├── build.gradle ├── consumer-rules.pro ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── kotlinpractice │ │ └── ExampleInstrumentedTest.kt │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── kotlinpractice │ │ │ └── KotlinPracticeActivity.kt │ └── res │ │ ├── layout │ │ └── activity_kotlin_practice.xml │ │ └── values │ │ └── strings.xml │ └── test │ └── java │ └── com │ └── kotlinpractice │ └── ExampleUnitTest.kt ├── MVVMCleanArchitecture ├── .gitignore ├── build.gradle ├── consumer-rules.pro ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── mvvm │ │ └── cleanarchitecture │ │ └── ExampleInstrumentedTest.kt │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── mvvm │ │ │ └── cleanarchitecture │ │ │ ├── CleanArchitectureTheory.kt │ │ │ ├── framework │ │ │ ├── PostListViewModel.kt │ │ │ ├── PostViewModel.kt │ │ │ ├── RoomPostDataSource.kt │ │ │ ├── UseCases.kt │ │ │ ├── db │ │ │ │ ├── DataBaseService.kt │ │ │ │ ├── PostDao.kt │ │ │ │ └── PostEntity.kt │ │ │ └── di │ │ │ │ ├── ApplicationModule.kt │ │ │ │ ├── RepositoryModule.kt │ │ │ │ ├── UseCasesModule.kt │ │ │ │ └── ViewModelComponent.kt │ │ │ └── presentation │ │ │ ├── CleanArchitectureActivity.kt │ │ │ ├── ListClickListener.kt │ │ │ ├── PostFragment.kt │ │ │ ├── PostListAdapter.kt │ │ │ └── PostListFragment.kt │ └── res │ │ ├── drawable │ │ ├── ic_check.xml │ │ ├── ic_create.xml │ │ └── ic_delete.xml │ │ ├── layout │ │ ├── activity_clean_architecture.xml │ │ ├── fragment_post.xml │ │ ├── fragment_post_list.xml │ │ └── item_post.xml │ │ ├── menu │ │ └── menu_delete.xml │ │ ├── navigation │ │ └── navigation.xml │ │ └── values │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── mvvm │ └── cleanarchitecture │ └── ExampleUnitTest.kt ├── MVVMCore ├── .gitignore ├── build.gradle └── src │ └── main │ └── java │ └── com │ └── mvvmcore │ ├── data │ └── PostModel.kt │ ├── repository │ ├── PostDataRepository.kt │ ├── PostDataSource.kt │ ├── PostRemoteDataRepository.kt │ └── PostRemoteDataSource.kt │ └── usecases │ ├── AddPost.kt │ ├── FetchRemotePosts.kt │ ├── GetPost.kt │ ├── GetPostCount.kt │ ├── GetPosts.kt │ └── RemovePost.kt ├── MVVMCoroutineRetrofit ├── .gitignore ├── build.gradle ├── consumer-rules.pro ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── mvvmcoroutine │ │ └── retrofit │ │ └── ExampleInstrumentedTest.kt │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── mvvmcoroutine │ │ │ └── retrofit │ │ │ ├── di │ │ │ ├── NetworkComponent.kt │ │ │ └── NetworkModule.kt │ │ │ ├── login │ │ │ ├── model │ │ │ │ ├── LoginModel.kt │ │ │ │ └── TokenModel.kt │ │ │ ├── view │ │ │ │ ├── RetrofitLoginActivity.kt │ │ │ │ └── RetrofitLoginFragment.kt │ │ │ └── viewmodel │ │ │ │ ├── LoginViewModel.kt │ │ │ │ └── LoginViewModelFactory.kt │ │ │ ├── network │ │ │ ├── NetworkAPIService.kt │ │ │ └── NetworkURL.kt │ │ │ └── userlist │ │ │ ├── ItemClickListener.kt │ │ │ ├── model │ │ │ ├── RetroResult.kt │ │ │ ├── RetroResultUser.kt │ │ │ └── User.kt │ │ │ ├── view │ │ │ ├── UserListActivity.kt │ │ │ ├── UserListAdapter.kt │ │ │ ├── UserListDetailFragment.kt │ │ │ └── UserListFragment.kt │ │ │ └── viewmodel │ │ │ ├── UserListViewModel.kt │ │ │ └── UserListViewModelFactory.kt │ └── res │ │ ├── drawable │ │ └── ic_sync.xml │ │ ├── layout │ │ ├── activity_retrofit_login.xml │ │ ├── activity_user_list.xml │ │ ├── fragment_retrofit_login.xml │ │ ├── fragment_user_list.xml │ │ ├── fragment_user_list_detail.xml │ │ └── item_user_list.xml │ │ └── values │ │ └── strings.xml │ └── test │ └── java │ └── com │ └── mvvmcoroutine │ └── retrofit │ ├── ExampleUnitTest.kt │ ├── RetroCoroutineLoginViewModelTest.kt │ ├── RetroCouroutineListViewHolderTest.kt │ └── TestCoroutineRule.kt ├── MVVMDataBinding ├── .gitignore ├── build.gradle ├── consumer-rules.pro ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── mvvm │ │ └── databinding │ │ └── ExampleInstrumentedTest.kt │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── mvvm │ │ │ └── databinding │ │ │ ├── model │ │ │ └── BindingAdapters.kt │ │ │ ├── view │ │ │ ├── BasicDataBidingFragment.kt │ │ │ ├── BasicDataBindingActivity.kt │ │ │ ├── DataBindingListActivity.kt │ │ │ ├── DataBindingListAdapter.kt │ │ │ ├── DataBindingListFragment.kt │ │ │ └── DataBindingViewHolder.kt │ │ │ └── viewmodel │ │ │ └── DataBidingViewModel.kt │ └── res │ │ ├── layout │ │ ├── activity_basic_data_binding.xml │ │ ├── activity_data_binding_list.xml │ │ ├── fragment_basic_data_biding.xml │ │ ├── fragment_data_binding_list.xml │ │ └── fragment_data_binding_list_item.xml │ │ └── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── mvvm │ └── databinding │ └── ExampleUnitTest.kt ├── MVVMLauncher ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── logs │ │ └── launcher │ │ ├── ExampleInstrumentedTest.kt │ │ ├── LauncherActivityTest.kt │ │ ├── LoginActivityTest_positive.kt │ │ ├── MVVMLoginTest.kt │ │ └── RoomDBActivityTest.kt │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── logs │ │ │ └── launcher │ │ │ ├── LauncherActivity.kt │ │ │ ├── model │ │ │ └── Launcher.kt │ │ │ ├── view │ │ │ ├── AdapterClickListener.kt │ │ │ ├── LauncherAdapter.kt │ │ │ ├── LauncherFragment.kt │ │ │ └── LauncherViewHolder.kt │ │ │ └── viewmodel │ │ │ └── LauncherViewModel.kt │ └── res │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ └── ic_launcher_background.xml │ │ ├── layout │ │ ├── activity_launcher.xml │ │ ├── fragment_launcher.xml │ │ └── launcher_list_item.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 │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── logs │ └── launcher │ └── ExampleUnitTest.kt ├── MVVMLogin ├── .gitignore ├── build.gradle ├── consumer-rules.pro ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── mvvmlogin │ │ └── ExampleInstrumentedTest.kt │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── mvvmlogin │ │ │ ├── model │ │ │ └── LoginModel.kt │ │ │ ├── view │ │ │ ├── LoginActivity.kt │ │ │ └── LoginFragment.kt │ │ │ └── viewmodel │ │ │ └── LoginViewModel.kt │ └── res │ │ ├── layout │ │ ├── activity_login.xml │ │ └── fragment_login.xml │ │ └── values │ │ ├── dimens.xml │ │ └── strings.xml │ └── test │ └── java │ └── com │ └── mvvmlogin │ ├── ExampleUnitTest.kt │ └── LoginViewModelTest.kt ├── MVVMNavigator ├── .gitignore ├── build.gradle ├── consumer-rules.pro ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── mvvm │ │ └── navigator │ │ └── ExampleInstrumentedTest.kt │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── mvvm │ │ │ └── navigator │ │ │ ├── NavigationMainActivity.kt │ │ │ ├── model │ │ │ └── LoginModel.kt │ │ │ ├── view │ │ │ ├── LoginFragment.kt │ │ │ ├── LoginSuccessFragment.kt │ │ │ └── RegistrationFragment.kt │ │ │ └── viewmodel │ │ │ └── LoginViewModel.kt │ └── res │ │ ├── layout │ │ ├── fragment_login_navigator.xml │ │ ├── fragment_login_success.xml │ │ ├── navigation_main.xml │ │ └── register_user_layout.xml │ │ ├── navigation │ │ └── nav_graph.xml │ │ └── values │ │ └── strings.xml │ └── test │ └── java │ └── com │ └── mvvm │ └── navigator │ └── ExampleUnitTest.kt ├── MVVMRoom ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── mvvm_kotlin │ │ └── ExampleInstrumentedTest.kt │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── mvvm_kotlin │ │ │ ├── OnBottomSheetItemSelected.kt │ │ │ ├── RoomDBActivity.kt │ │ │ ├── view │ │ │ ├── AddUserFragment.kt │ │ │ ├── RoomDataBaseAdapter.kt │ │ │ ├── RoomDataBaseFragment.kt │ │ │ └── RoomViewHolder.kt │ │ │ └── viewmodel │ │ │ └── RoomListViewModel.kt │ └── res │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ └── ic_launcher_background.xml │ │ ├── layout │ │ ├── activity_main.xml │ │ ├── add_user_layout.xml │ │ ├── confirmation_bottom_sheet.xml │ │ ├── fragment_add_user.xml │ │ ├── fragment_room_data_base.xml │ │ └── room_list_item.xml │ │ ├── menu │ │ └── menu.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 │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── mvvm_kotlin │ └── ExampleUnitTest.kt ├── MVVMRxRetrofit ├── .gitignore ├── build.gradle ├── consumer-rules.pro ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── rxretrofit │ │ └── ExampleInstrumentedTest.kt │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── rxretrofit │ │ │ ├── DI │ │ │ └── RetroRxComponent.kt │ │ │ ├── model │ │ │ └── RetroRxModel.kt │ │ │ ├── view │ │ │ ├── RetroRXFragment.kt │ │ │ ├── RetroRxActivity.kt │ │ │ ├── RetroRxCoroutineActivity.kt │ │ │ ├── RetroRxCoroutineFragment.kt │ │ │ ├── RetroViewHolder.kt │ │ │ └── RetrofitAdapter.kt │ │ │ └── viewmodel │ │ │ ├── APIService.kt │ │ │ ├── RetroCoroutineViewModel.kt │ │ │ ├── RetroCoroutineViewModelFactory.kt │ │ │ ├── RetroRXViewModel.kt │ │ │ └── RetroViewModelFactory.kt │ └── res │ │ ├── layout │ │ ├── activity_retro_rx.xml │ │ ├── activity_retro_rx_coroutine.xml │ │ ├── fragment_retro_rx.xml │ │ ├── fragment_retro_rx_coroutine.xml │ │ └── retro_list_item.xml │ │ └── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ ├── java │ └── com │ │ └── rxretrofit │ │ ├── ExampleUnitTest.kt │ │ ├── RetroCoroutineViewModelTest.kt │ │ ├── RetroRXViewModelPrivateMethodTest.kt │ │ ├── RetroRXViewModelTest.kt │ │ ├── RetroRXViewModelToTest.kt │ │ ├── RxImmediateSchedulerRule.kt │ │ └── TestCoroutineRule.kt │ └── resources │ └── mockito-extensions │ └── org.mockito.plugins.MockMaker ├── README.md ├── RoomRepository ├── .gitignore ├── build.gradle ├── consumer-rules.pro ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── room │ │ └── db │ │ └── ExampleInstrumentedTest.kt │ ├── main │ ├── AndroidManifest.xml │ └── java │ │ └── com │ │ └── room │ │ └── db │ │ ├── database │ │ └── RepositoryDB.kt │ │ └── userRepo │ │ ├── UserInfo.kt │ │ └── UserInfoDao.kt │ └── test │ └── java │ └── com │ └── room │ └── db │ └── ExampleUnitTest.kt ├── RxJavaPractice ├── .gitignore ├── build.gradle ├── consumer-rules.pro ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── rxjava │ │ └── practice │ │ └── ExampleInstrumentedTest.kt │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── rxjava │ │ │ └── practice │ │ │ ├── Address.kt │ │ │ ├── DataSource.kt │ │ │ ├── Employee.kt │ │ │ ├── RxJavaPracticeActivity.kt │ │ │ └── User.kt │ └── res │ │ ├── layout │ │ └── activity_rx_java_practice.xml │ │ └── values │ │ └── strings.xml │ └── test │ └── java │ └── com │ └── rxjava │ └── practice │ └── ExampleUnitTest.kt ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── utilslibrary-release ├── build.gradle └── utilslibrary-release.aar /.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/.name: -------------------------------------------------------------------------------- 1 | MVVM_Kotlin -------------------------------------------------------------------------------- /.idea/codeStyles/codeStyleConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /.idea/jarRepositories.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 9 | 10 | 14 | 15 | 19 | 20 | 24 | 25 | 29 | 30 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 9 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /AppNavigator/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /AppNavigator/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'com.android.library' 3 | id 'kotlin-android' 4 | id 'kotlin-android-extensions' 5 | } 6 | 7 | android { 8 | compileSdkVersion 29 9 | buildToolsVersion "29.0.3" 10 | 11 | defaultConfig { 12 | minSdkVersion 23 13 | targetSdkVersion 29 14 | versionCode 1 15 | versionName "1.0" 16 | 17 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 18 | consumerProguardFiles "consumer-rules.pro" 19 | } 20 | 21 | buildTypes { 22 | release { 23 | minifyEnabled false 24 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 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 | //implementation project(path: ':MVVMLogin') 38 | implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" 39 | implementation 'androidx.core:core-ktx:1.2.0' 40 | implementation 'androidx.appcompat:appcompat:1.1.0' 41 | testImplementation 'junit:junit:4.12' 42 | androidTestImplementation 'androidx.test.ext:junit:1.1.1' 43 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' 44 | } -------------------------------------------------------------------------------- /AppNavigator/consumer-rules.pro: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chandragithub2014/MVVM_Kotlin/29dead56325654276055caa9e0e2cb62240a99f2/AppNavigator/consumer-rules.pro -------------------------------------------------------------------------------- /AppNavigator/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 -------------------------------------------------------------------------------- /AppNavigator/src/androidTest/java/com/mvvm/appnavigator/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package com.mvvm.appnavigator 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.mvvm.appnavigator.test", appContext.packageName) 23 | } 24 | } -------------------------------------------------------------------------------- /AppNavigator/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | -------------------------------------------------------------------------------- /AppNavigator/src/test/java/com/mvvm/appnavigator/ExampleUnitTest.kt: -------------------------------------------------------------------------------- 1 | package com.mvvm.appnavigator 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 | } -------------------------------------------------------------------------------- /BottomSheet/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /BottomSheet/consumer-rules.pro: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chandragithub2014/MVVM_Kotlin/29dead56325654276055caa9e0e2cb62240a99f2/BottomSheet/consumer-rules.pro -------------------------------------------------------------------------------- /BottomSheet/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 -------------------------------------------------------------------------------- /BottomSheet/src/androidTest/java/com/bottomsheet/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package com.bottomsheet 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.bottomsheet.test", appContext.packageName) 23 | } 24 | } -------------------------------------------------------------------------------- /BottomSheet/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /BottomSheet/src/main/res/layout/layout_bottom_sheet_dialog.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 17 | -------------------------------------------------------------------------------- /BottomSheet/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /BottomSheet/src/test/java/com/bottomsheet/ExampleUnitTest.kt: -------------------------------------------------------------------------------- 1 | package com.bottomsheet 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 | } -------------------------------------------------------------------------------- /Common/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /Common/consumer-rules.pro: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chandragithub2014/MVVM_Kotlin/29dead56325654276055caa9e0e2cb62240a99f2/Common/consumer-rules.pro -------------------------------------------------------------------------------- /Common/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 -------------------------------------------------------------------------------- /Common/src/androidTest/java/com/mvvm/common/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package com.mvvm.common 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.mvvm.common.test", appContext.packageName) 23 | } 24 | } -------------------------------------------------------------------------------- /Common/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Common/src/main/ic_default_icon-playstore.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chandragithub2014/MVVM_Kotlin/29dead56325654276055caa9e0e2cb62240a99f2/Common/src/main/ic_default_icon-playstore.png -------------------------------------------------------------------------------- /Common/src/main/java/com/mvvm/common/CommonActivity.kt: -------------------------------------------------------------------------------- 1 | package com.mvvm.common 2 | 3 | import androidx.appcompat.app.AppCompatActivity 4 | import android.os.Bundle 5 | 6 | class CommonActivity : AppCompatActivity() { 7 | override fun onCreate(savedInstanceState: Bundle?) { 8 | super.onCreate(savedInstanceState) 9 | setContentView(R.layout.activity_common) 10 | } 11 | } -------------------------------------------------------------------------------- /Common/src/main/java/com/mvvm/common/di/RetroRxModule.kt: -------------------------------------------------------------------------------- 1 | package com.mvvm.common.di 2 | 3 | 4 | import dagger.Module 5 | import dagger.Provides 6 | import retrofit2.Retrofit 7 | import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory 8 | import retrofit2.converter.gson.GsonConverterFactory 9 | 10 | @Module 11 | class RetroRxModule { 12 | 13 | 14 | @Provides 15 | fun provideRetroInfo() : Retrofit{ 16 | return Retrofit 17 | .Builder() 18 | .baseUrl(RetroURL.BASE_URL) 19 | .addConverterFactory(GsonConverterFactory.create()) 20 | .addCallAdapterFactory(RxJava2CallAdapterFactory.create()) 21 | .build() 22 | 23 | } 24 | } -------------------------------------------------------------------------------- /Common/src/main/java/com/mvvm/common/di/RetroURL.kt: -------------------------------------------------------------------------------- 1 | package com.mvvm.common.di 2 | 3 | class RetroURL { 4 | companion object { 5 | const val BASE_URL = "https://jsonplaceholder.typicode.com" 6 | 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /Common/src/main/java/com/mvvm/common/utils/SharedPreferencesHelper.kt: -------------------------------------------------------------------------------- 1 | package com.mvvm.common.utils 2 | 3 | import android.content.Context 4 | import android.content.SharedPreferences 5 | import androidx.core.content.edit 6 | import androidx.preference.PreferenceManager 7 | 8 | 9 | 10 | class SharedPreferencesHelper { 11 | 12 | companion object{ 13 | private const val PREF_NAME = "emp_name" 14 | private var prefs:SharedPreferences ? = null 15 | @Volatile private var INSTANCE: SharedPreferencesHelper? = null 16 | private val LOCK = Any() 17 | operator fun invoke(context: Context): SharedPreferencesHelper = 18 | INSTANCE ?: synchronized(LOCK) { 19 | INSTANCE ?: buildSharedPreferencesHelper(context).also { 20 | INSTANCE = it 21 | } 22 | } 23 | 24 | private fun buildSharedPreferencesHelper(context: Context): SharedPreferencesHelper { 25 | prefs = PreferenceManager.getDefaultSharedPreferences(context) 26 | return SharedPreferencesHelper() 27 | } 28 | 29 | } 30 | 31 | fun saveEmpName(name : String){ 32 | prefs?.edit(commit = true){ 33 | putString(PREF_NAME,name) 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /Common/src/main/java/com/mvvm/common/utils/Utils.kt: -------------------------------------------------------------------------------- 1 | package com.mvvm.common.utils 2 | 3 | import android.content.Context 4 | import android.graphics.Color 5 | import android.widget.ImageView 6 | import android.widget.TextView 7 | 8 | import androidx.appcompat.app.AppCompatActivity 9 | import androidx.appcompat.widget.Toolbar 10 | import androidx.swiperefreshlayout.widget.CircularProgressDrawable 11 | import com.bumptech.glide.Glide 12 | import com.bumptech.glide.request.RequestOptions 13 | import com.mvvm.common.R 14 | 15 | 16 | fun initToolBar(toolbar: Toolbar, textView: TextView, title:String, activity:AppCompatActivity){ 17 | 18 | toolbar.setBackgroundColor(Color.CYAN) 19 | textView.text = title 20 | activity?.setSupportActionBar(toolbar) 21 | activity?.let{ 22 | activity.supportActionBar?.setDisplayHomeAsUpEnabled(false) 23 | activity.supportActionBar?.title = "" 24 | } 25 | 26 | } 27 | 28 | fun getCircularDrawable(context:Context):CircularProgressDrawable{ 29 | 30 | return CircularProgressDrawable(context).apply { 31 | strokeWidth = 10f 32 | centerRadius = 50f 33 | start() 34 | } 35 | } 36 | 37 | fun ImageView.loadImage(uri:String?, progressDrawable: CircularProgressDrawable){ 38 | var options:RequestOptions = RequestOptions() 39 | .placeholder(progressDrawable) 40 | .error(R.mipmap.ic_default_icon) 41 | Glide.with(context) 42 | .setDefaultRequestOptions(options) 43 | .load(uri) 44 | .into(this) 45 | 46 | } -------------------------------------------------------------------------------- /Common/src/main/res/drawable/ic_default_icon_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 11 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /Common/src/main/res/layout/activity_common.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | -------------------------------------------------------------------------------- /Common/src/main/res/layout/bottomsheet_common_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /Common/src/main/res/layout/modal_bottom_sheet_dialog.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 18 | -------------------------------------------------------------------------------- /Common/src/main/res/layout/toolbar_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 13 | 14 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /Common/src/main/res/mipmap-anydpi-v26/ic_default_icon.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /Common/src/main/res/mipmap-anydpi-v26/ic_default_icon_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /Common/src/main/res/mipmap-hdpi/ic_default_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chandragithub2014/MVVM_Kotlin/29dead56325654276055caa9e0e2cb62240a99f2/Common/src/main/res/mipmap-hdpi/ic_default_icon.png -------------------------------------------------------------------------------- /Common/src/main/res/mipmap-hdpi/ic_default_icon_background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chandragithub2014/MVVM_Kotlin/29dead56325654276055caa9e0e2cb62240a99f2/Common/src/main/res/mipmap-hdpi/ic_default_icon_background.png -------------------------------------------------------------------------------- /Common/src/main/res/mipmap-hdpi/ic_default_icon_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chandragithub2014/MVVM_Kotlin/29dead56325654276055caa9e0e2cb62240a99f2/Common/src/main/res/mipmap-hdpi/ic_default_icon_round.png -------------------------------------------------------------------------------- /Common/src/main/res/mipmap-mdpi/ic_default_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chandragithub2014/MVVM_Kotlin/29dead56325654276055caa9e0e2cb62240a99f2/Common/src/main/res/mipmap-mdpi/ic_default_icon.png -------------------------------------------------------------------------------- /Common/src/main/res/mipmap-mdpi/ic_default_icon_background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chandragithub2014/MVVM_Kotlin/29dead56325654276055caa9e0e2cb62240a99f2/Common/src/main/res/mipmap-mdpi/ic_default_icon_background.png -------------------------------------------------------------------------------- /Common/src/main/res/mipmap-mdpi/ic_default_icon_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chandragithub2014/MVVM_Kotlin/29dead56325654276055caa9e0e2cb62240a99f2/Common/src/main/res/mipmap-mdpi/ic_default_icon_round.png -------------------------------------------------------------------------------- /Common/src/main/res/mipmap-xhdpi/ic_default_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chandragithub2014/MVVM_Kotlin/29dead56325654276055caa9e0e2cb62240a99f2/Common/src/main/res/mipmap-xhdpi/ic_default_icon.png -------------------------------------------------------------------------------- /Common/src/main/res/mipmap-xhdpi/ic_default_icon_background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chandragithub2014/MVVM_Kotlin/29dead56325654276055caa9e0e2cb62240a99f2/Common/src/main/res/mipmap-xhdpi/ic_default_icon_background.png -------------------------------------------------------------------------------- /Common/src/main/res/mipmap-xhdpi/ic_default_icon_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chandragithub2014/MVVM_Kotlin/29dead56325654276055caa9e0e2cb62240a99f2/Common/src/main/res/mipmap-xhdpi/ic_default_icon_round.png -------------------------------------------------------------------------------- /Common/src/main/res/mipmap-xxhdpi/ic_default_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chandragithub2014/MVVM_Kotlin/29dead56325654276055caa9e0e2cb62240a99f2/Common/src/main/res/mipmap-xxhdpi/ic_default_icon.png -------------------------------------------------------------------------------- /Common/src/main/res/mipmap-xxhdpi/ic_default_icon_background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chandragithub2014/MVVM_Kotlin/29dead56325654276055caa9e0e2cb62240a99f2/Common/src/main/res/mipmap-xxhdpi/ic_default_icon_background.png -------------------------------------------------------------------------------- /Common/src/main/res/mipmap-xxhdpi/ic_default_icon_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chandragithub2014/MVVM_Kotlin/29dead56325654276055caa9e0e2cb62240a99f2/Common/src/main/res/mipmap-xxhdpi/ic_default_icon_round.png -------------------------------------------------------------------------------- /Common/src/main/res/mipmap-xxxhdpi/ic_default_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chandragithub2014/MVVM_Kotlin/29dead56325654276055caa9e0e2cb62240a99f2/Common/src/main/res/mipmap-xxxhdpi/ic_default_icon.png -------------------------------------------------------------------------------- /Common/src/main/res/mipmap-xxxhdpi/ic_default_icon_background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chandragithub2014/MVVM_Kotlin/29dead56325654276055caa9e0e2cb62240a99f2/Common/src/main/res/mipmap-xxxhdpi/ic_default_icon_background.png -------------------------------------------------------------------------------- /Common/src/main/res/mipmap-xxxhdpi/ic_default_icon_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chandragithub2014/MVVM_Kotlin/29dead56325654276055caa9e0e2cb62240a99f2/Common/src/main/res/mipmap-xxxhdpi/ic_default_icon_round.png -------------------------------------------------------------------------------- /Common/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 8dp 5 | -------------------------------------------------------------------------------- /Common/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Common/src/test/java/com/mvvm/common/ExampleUnitTest.kt: -------------------------------------------------------------------------------- 1 | package com.mvvm.common 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 | } -------------------------------------------------------------------------------- /DaggerPractice/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /DaggerPractice/consumer-rules.pro: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chandragithub2014/MVVM_Kotlin/29dead56325654276055caa9e0e2cb62240a99f2/DaggerPractice/consumer-rules.pro -------------------------------------------------------------------------------- /DaggerPractice/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 -------------------------------------------------------------------------------- /DaggerPractice/src/androidTest/java/com/dagger/practice/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package com.dagger.practice 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.dagger.practice.test", appContext.packageName) 23 | } 24 | } -------------------------------------------------------------------------------- /DaggerPractice/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /DaggerPractice/src/main/java/com/dagger/practice/AppApplication.kt: -------------------------------------------------------------------------------- 1 | package com.dagger.practice 2 | import android.app.Application 3 | import android.content.Context 4 | import com.dagger.practice.applevelsingletoInjection.AppComponent 5 | import com.dagger.practice.applevelsingletoInjection.ApplicationModule 6 | import com.dagger.practice.applevelsingletoInjection.DaggerAppComponent 7 | import com.dagger.practice.subComponentInjection.DaggerSportsComponent 8 | import com.dagger.practice.subComponentInjection.SportsComponent 9 | import com.dagger.practice.subComponentInjection.SportsModule 10 | 11 | 12 | class AppApplication : Application() 13 | { 14 | 15 | companion object 16 | { 17 | var ctx: Context? = null 18 | lateinit var appComponent: AppComponent 19 | lateinit var sportsComponent : SportsComponent 20 | 21 | } 22 | 23 | override fun onCreate() 24 | { 25 | super.onCreate() 26 | ctx = applicationContext 27 | appComponent = initDaggerComponent() 28 | sportsComponent = initSportsComponent() 29 | } 30 | 31 | fun getMyComponent(): AppComponent 32 | { 33 | return appComponent 34 | 35 | 36 | } 37 | 38 | private fun initSportsComponent(): SportsComponent{ 39 | sportsComponent = DaggerSportsComponent.builder().sportsModule(SportsModule("Eden")).build() 40 | return sportsComponent 41 | } 42 | private fun initDaggerComponent(): AppComponent 43 | { 44 | appComponent = DaggerAppComponent.builder(). 45 | applicationModule(ApplicationModule("John")). 46 | build() 47 | 48 | return appComponent 49 | 50 | 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /DaggerPractice/src/main/java/com/dagger/practice/AppLevelSingletonActivity.kt: -------------------------------------------------------------------------------- 1 | package com.dagger.practice 2 | 3 | import android.os.Bundle 4 | import androidx.appcompat.app.AppCompatActivity 5 | import com.dagger.practice.applevelsingletoInjection.* 6 | import javax.inject.Inject 7 | import javax.inject.Named 8 | 9 | class AppLevelSingletonActivity : AppCompatActivity() { 10 | 11 | @Inject 12 | lateinit var passengerName : String 13 | 14 | 15 | /* @Inject 16 | lateinit var driver: Driver 17 | */ 18 | @Inject 19 | lateinit var passenger: Passenger 20 | 21 | 22 | override fun onCreate(savedInstanceState: Bundle?) { 23 | super.onCreate(savedInstanceState) 24 | setContentView(R.layout.activity_app_level_singleton) 25 | 26 | var appComponent : AppComponent = AppApplication.appComponent 27 | /*appComponent.inject(this)*/ 28 | 29 | val component: PerActivityComponent = /*(application as AppApplication).getMyComponent()*/ 30 | appComponent.getActivityComponent(PassengerModule("Pollock")) 31 | component.inject(this) 32 | passenger.displayPassengerInfo() 33 | 34 | } 35 | } -------------------------------------------------------------------------------- /DaggerPractice/src/main/java/com/dagger/practice/ConstructorInjectionActivity.kt: -------------------------------------------------------------------------------- 1 | package com.dagger.practice 2 | 3 | import androidx.appcompat.app.AppCompatActivity 4 | import android.os.Bundle 5 | import com.dagger.practice.constructorDI.DaggerEmployeeInfoComponent 6 | 7 | class ConstructorInjectionActivity : AppCompatActivity() { 8 | override fun onCreate(savedInstanceState: Bundle?) { 9 | super.onCreate(savedInstanceState) 10 | setContentView(R.layout.activity_constructor_injection) 11 | var component = DaggerEmployeeInfoComponent.create() 12 | 13 | var empInfo = component.getEmpl() 14 | empInfo.empDetailsInfo() 15 | } 16 | } -------------------------------------------------------------------------------- /DaggerPractice/src/main/java/com/dagger/practice/CricketActivity.kt: -------------------------------------------------------------------------------- 1 | package com.dagger.practice 2 | 3 | import androidx.appcompat.app.AppCompatActivity 4 | import android.os.Bundle 5 | import com.dagger.practice.applevelsingletoInjection.AppComponent 6 | import com.dagger.practice.subComponentInjection.Cricket 7 | import com.dagger.practice.subComponentInjection.CricketModule 8 | import com.dagger.practice.subComponentInjection.Sports 9 | import com.dagger.practice.subComponentInjection.SportsComponent 10 | import com.mvvm.appnavigator.openActivity 11 | import kotlinx.android.synthetic.main.activity_cricket.* 12 | import javax.inject.Inject 13 | 14 | class CricketActivity : AppCompatActivity() { 15 | @Inject 16 | lateinit var sports: Sports 17 | 18 | @Inject 19 | lateinit var cricket: Cricket 20 | 21 | override fun onCreate(savedInstanceState: Bundle?) { 22 | super.onCreate(savedInstanceState) 23 | setContentView(R.layout.activity_cricket) 24 | 25 | var sportsComponent : SportsComponent = AppApplication.sportsComponent 26 | var cricketComponent = sportsComponent.getCricketComponent(CricketModule("Sachin")) 27 | cricketComponent.inject(this) 28 | sports.displaySportsCenterInfo() 29 | cricket.displayCricketInfo() 30 | 31 | navigate_tennis.setOnClickListener { 32 | 33 | this?.openActivity(Class.forName("com.dagger.practice.TennisActivity")) 34 | } 35 | 36 | 37 | 38 | } 39 | } -------------------------------------------------------------------------------- /DaggerPractice/src/main/java/com/dagger/practice/FieldInjection/Student.kt: -------------------------------------------------------------------------------- 1 | package com.dagger.practice.FieldInjection 2 | 3 | class Student(studentDetails: StudentDetails) { 4 | var studentDetails = studentDetails 5 | 6 | fun studentInfo(){ 7 | println("In Student.......") 8 | } 9 | } -------------------------------------------------------------------------------- /DaggerPractice/src/main/java/com/dagger/practice/FieldInjection/StudentComponent.kt: -------------------------------------------------------------------------------- 1 | package com.dagger.practice.FieldInjection 2 | 3 | import com.dagger.practice.FieldInjectionActivity 4 | import dagger.Component 5 | import dagger.Module 6 | 7 | @Component(modules = [StudentModule::class]) 8 | interface StudentComponent { 9 | fun inject(fieldInjectionActivity: FieldInjectionActivity) 10 | } -------------------------------------------------------------------------------- /DaggerPractice/src/main/java/com/dagger/practice/FieldInjection/StudentDetails.kt: -------------------------------------------------------------------------------- 1 | package com.dagger.practice.FieldInjection 2 | 3 | import javax.inject.Inject 4 | 5 | class StudentDetails (){ 6 | 7 | fun studentInfo(){ 8 | println("In Student Details......") 9 | 10 | 11 | } 12 | } -------------------------------------------------------------------------------- /DaggerPractice/src/main/java/com/dagger/practice/FieldInjection/StudentModule.kt: -------------------------------------------------------------------------------- 1 | package com.dagger.practice.FieldInjection 2 | 3 | import dagger.Module 4 | import dagger.Provides 5 | 6 | @Module 7 | class StudentModule { 8 | 9 | 10 | @Provides 11 | fun provideStudentDetails() : StudentDetails{ 12 | var studentDetails = StudentDetails() 13 | studentDetails.studentInfo() 14 | return studentDetails 15 | } 16 | 17 | 18 | @Provides 19 | fun provideStudent(studentDetails: StudentDetails) : Student{ 20 | return Student(studentDetails) 21 | } 22 | 23 | 24 | 25 | } -------------------------------------------------------------------------------- /DaggerPractice/src/main/java/com/dagger/practice/FieldInjectionActivity.kt: -------------------------------------------------------------------------------- 1 | package com.dagger.practice 2 | 3 | import androidx.appcompat.app.AppCompatActivity 4 | import android.os.Bundle 5 | import com.dagger.practice.FieldInjection.DaggerStudentComponent 6 | import com.dagger.practice.FieldInjection.Student 7 | import javax.inject.Inject 8 | 9 | class FieldInjectionActivity : AppCompatActivity() { 10 | @Inject 11 | lateinit var student: Student 12 | override fun onCreate(savedInstanceState: Bundle?) { 13 | super.onCreate(savedInstanceState) 14 | setContentView(R.layout.activity_field_injection) 15 | 16 | var studentComponent = DaggerStudentComponent.builder().build() 17 | 18 | studentComponent.inject(this) 19 | student.studentInfo() 20 | } 21 | } -------------------------------------------------------------------------------- /DaggerPractice/src/main/java/com/dagger/practice/InterfaceInjectionActivity.kt: -------------------------------------------------------------------------------- 1 | package com.dagger.practice 2 | 3 | import androidx.appcompat.app.AppCompatActivity 4 | import android.os.Bundle 5 | import androidx.annotation.IntegerRes 6 | import com.dagger.practice.interfaceInjection.DaggerDoctorComponent 7 | import com.dagger.practice.interfaceInjection.Doctor 8 | import com.dagger.practice.interfaceInjection.DoctorType 9 | import com.dagger.practice.interfaceInjection.PrivateDoctorModule 10 | import javax.inject.Inject 11 | import javax.inject.Named 12 | 13 | class InterfaceInjectionActivity : AppCompatActivity() { 14 | @Inject 15 | lateinit var doctor: Doctor 16 | 17 | 18 | override fun onCreate(savedInstanceState: Bundle?) { 19 | super.onCreate(savedInstanceState) 20 | setContentView(R.layout.activity_interface_injection) 21 | var doctorComponent = DaggerDoctorComponent.builder().privateDoctorModule( 22 | PrivateDoctorModule(Integer(20),Integer(2000)) 23 | ) 24 | .build() 25 | doctorComponent.inject(this) 26 | doctor.displayDoctorInfo() 27 | 28 | 29 | } 30 | } -------------------------------------------------------------------------------- /DaggerPractice/src/main/java/com/dagger/practice/NamedInjectionActivity.kt: -------------------------------------------------------------------------------- 1 | package com.dagger.practice 2 | 3 | import androidx.appcompat.app.AppCompatActivity 4 | import android.os.Bundle 5 | import com.dagger.practice.namedInjection.DaggerMovieComponent 6 | import com.dagger.practice.namedInjection.Movie 7 | import com.dagger.practice.namedInjection.MovieDetails 8 | import com.dagger.practice.namedInjection.MovieModule 9 | import javax.inject.Inject 10 | import javax.inject.Named 11 | 12 | class NamedInjectionActivity : AppCompatActivity() { 13 | /* 14 | @Inject 15 | lateinit var movie: Movie*/ 16 | @Inject 17 | @field:Named("type") 18 | lateinit var type: String 19 | 20 | @Inject 21 | @field:Named("actor") 22 | lateinit var actor: String 23 | 24 | @Inject 25 | lateinit var movieDetails: MovieDetails 26 | 27 | @Inject 28 | lateinit var movie: Movie 29 | 30 | 31 | override fun onCreate(savedInstanceState: Bundle?) { 32 | super.onCreate(savedInstanceState) 33 | setContentView(R.layout.activity_named_injection) 34 | // DaggerMoviewComponent 35 | var component = 36 | DaggerMovieComponent.builder().movieModule(MovieModule("Action", "Jaq")).build() 37 | component.inject(this) 38 | // movieDetails.displayMovieDetails() 39 | movie.displayMovie() 40 | 41 | } 42 | } -------------------------------------------------------------------------------- /DaggerPractice/src/main/java/com/dagger/practice/SingletonInjectionActivity.kt: -------------------------------------------------------------------------------- 1 | package com.dagger.practice 2 | 3 | import androidx.appcompat.app.AppCompatActivity 4 | import android.os.Bundle 5 | import com.dagger.practice.singletonInjection.DaggerStudentComponent 6 | import com.dagger.practice.singletonInjection.Driver 7 | import com.dagger.practice.singletonInjection.Student 8 | import com.dagger.practice.singletonInjection.StudentModule 9 | import javax.inject.Inject 10 | import javax.inject.Named 11 | 12 | class SingletonInjectionActivity : AppCompatActivity() { 13 | 14 | @Inject 15 | @field:Named("driver") 16 | lateinit var driverName : String 17 | 18 | @Inject 19 | @field:Named("student Name") 20 | lateinit var studentName : String 21 | 22 | @Inject 23 | lateinit var driver: Driver 24 | 25 | @Inject 26 | lateinit var student: Student 27 | 28 | @Inject 29 | lateinit var student1: Student 30 | 31 | 32 | 33 | 34 | 35 | override fun onCreate(savedInstanceState: Bundle?) { 36 | super.onCreate(savedInstanceState) 37 | setContentView(R.layout.activity_singleton_injection) 38 | 39 | var component = DaggerStudentComponent.builder() 40 | .studentModule(StudentModule("John","Pollock")) 41 | .build() 42 | 43 | component.inject(this) 44 | student.displayStudentInfo() 45 | student1.displayStudentInfo() 46 | } 47 | } -------------------------------------------------------------------------------- /DaggerPractice/src/main/java/com/dagger/practice/TennisActivity.kt: -------------------------------------------------------------------------------- 1 | package com.dagger.practice 2 | 3 | import androidx.appcompat.app.AppCompatActivity 4 | import android.os.Bundle 5 | import com.dagger.practice.subComponentInjection.* 6 | import javax.inject.Inject 7 | 8 | class TennisActivity : AppCompatActivity() { 9 | @Inject 10 | lateinit var sports : Sports 11 | @Inject 12 | lateinit var tennis : Tennis 13 | 14 | override fun onCreate(savedInstanceState: Bundle?) { 15 | super.onCreate(savedInstanceState) 16 | setContentView(R.layout.activity_tennis) 17 | 18 | var sportsComponent : SportsComponent = AppApplication.sportsComponent 19 | var tennisComponent = sportsComponent.getTennisComponent(TennisModule("Roger")) 20 | tennisComponent.inject(this) 21 | sports.displaySportsCenterInfo() 22 | tennis.displayTennisInfo() 23 | 24 | 25 | 26 | } 27 | } -------------------------------------------------------------------------------- /DaggerPractice/src/main/java/com/dagger/practice/applevelsingletoInjection/AppComponent.kt: -------------------------------------------------------------------------------- 1 | package com.dagger.practice.applevelsingletoInjection 2 | 3 | import dagger.Component 4 | import javax.inject.Singleton 5 | 6 | @Singleton 7 | @Component (modules = [ApplicationModule::class]) 8 | 9 | interface AppComponent { 10 | // fun inject(appLevelSingletonActivity: AppLevelSingletonActivity) 11 | fun getActivityComponent(passengerModule: PassengerModule): PerActivityComponent 12 | } -------------------------------------------------------------------------------- /DaggerPractice/src/main/java/com/dagger/practice/applevelsingletoInjection/ApplicationModule.kt: -------------------------------------------------------------------------------- 1 | package com.dagger.practice.applevelsingletoInjection 2 | 3 | import dagger.Module 4 | import dagger.Provides 5 | import javax.inject.Named 6 | import javax.inject.Singleton 7 | 8 | @Module 9 | class ApplicationModule(name:String) { 10 | var name:String = name 11 | 12 | 13 | @Singleton 14 | @Named("driver name") 15 | @Provides 16 | fun provideDriverName():String = name 17 | 18 | @Singleton 19 | @Provides 20 | fun provideDriver():Driver = Driver(name) 21 | } -------------------------------------------------------------------------------- /DaggerPractice/src/main/java/com/dagger/practice/applevelsingletoInjection/Driver.kt: -------------------------------------------------------------------------------- 1 | package com.dagger.practice.applevelsingletoInjection 2 | 3 | import android.util.Log 4 | 5 | private const val TAG = "Driver" 6 | 7 | class Driver constructor(driverName :String) 8 | { 9 | var driverName : String = driverName 10 | fun printDriverInfo() 11 | { 12 | 13 | Log.d(TAG,"Driver Info is $this and corresponding Driver Name is ::::$driverName") 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /DaggerPractice/src/main/java/com/dagger/practice/applevelsingletoInjection/Passenger.kt: -------------------------------------------------------------------------------- 1 | package com.dagger.practice.applevelsingletoInjection 2 | 3 | import android.util.Log 4 | 5 | 6 | private const val TAG = "Passenger" 7 | @PerActivity 8 | class Passenger constructor( driver:Driver , passengerName:String) { 9 | var passengerName:String = passengerName 10 | var driver : Driver = driver 11 | 12 | fun displayPassengerInfo(){ 13 | Log.d(TAG,"Passenger instance $this with name $passengerName and driver instance is :::$driver ::: and driver Name is ${driver.driverName}") 14 | } 15 | 16 | } -------------------------------------------------------------------------------- /DaggerPractice/src/main/java/com/dagger/practice/applevelsingletoInjection/PassengerModule.kt: -------------------------------------------------------------------------------- 1 | package com.dagger.practice.applevelsingletoInjection 2 | 3 | import dagger.Module 4 | import dagger.Provides 5 | import javax.inject.Named 6 | import javax.inject.Singleton 7 | 8 | @Module 9 | class PassengerModule constructor( passengerName:String){ 10 | 11 | var passengerName : String = passengerName 12 | 13 | 14 | @Provides 15 | fun providePassengerName():String = passengerName 16 | 17 | @Provides 18 | fun providesPassenger(driver: Driver,passengerName: String):Passenger = Passenger(driver, passengerName) 19 | 20 | 21 | 22 | 23 | 24 | /* @Named("driver name") 25 | @Provides 26 | fun provideDriverName():String = driverName 27 | */ 28 | 29 | /*@Singleton 30 | @Provides 31 | fun providesDriver(): Driver = Driver(driverName)*/ 32 | 33 | 34 | } 35 | -------------------------------------------------------------------------------- /DaggerPractice/src/main/java/com/dagger/practice/applevelsingletoInjection/PerActivity.kt: -------------------------------------------------------------------------------- 1 | package com.dagger.practice.applevelsingletoInjection 2 | 3 | import java.lang.annotation.Documented 4 | import java.lang.annotation.Retention 5 | import java.lang.annotation.RetentionPolicy 6 | import javax.inject.Scope 7 | 8 | @Scope 9 | @Documented 10 | @Retention(RetentionPolicy.RUNTIME) 11 | annotation class PerActivity{ 12 | 13 | } -------------------------------------------------------------------------------- /DaggerPractice/src/main/java/com/dagger/practice/applevelsingletoInjection/PerActivityComponent.kt: -------------------------------------------------------------------------------- 1 | package com.dagger.practice.applevelsingletoInjection 2 | 3 | import com.dagger.practice.AppLevelSingletonActivity 4 | import dagger.Subcomponent 5 | 6 | @PerActivity 7 | @Subcomponent(modules = [PassengerModule::class]) 8 | interface PerActivityComponent { 9 | 10 | fun inject(appLevelSingletonActivity: AppLevelSingletonActivity) 11 | } -------------------------------------------------------------------------------- /DaggerPractice/src/main/java/com/dagger/practice/constructorDI/EmployeeInfoComponent.kt: -------------------------------------------------------------------------------- 1 | package com.dagger.practice.constructorDI 2 | 3 | import com.dagger.practice.constructorDI.emp.EmployeeInfo 4 | import dagger.Component 5 | 6 | @Component 7 | interface EmployeeInfoComponent { 8 | fun getEmpl(): EmployeeInfo 9 | } -------------------------------------------------------------------------------- /DaggerPractice/src/main/java/com/dagger/practice/constructorDI/emp/EmpDetails.kt: -------------------------------------------------------------------------------- 1 | package com.dagger.practice.constructorDI.emp 2 | 3 | import android.util.Log 4 | import javax.inject.Inject 5 | 6 | private const val TAG = "EmpDetails" 7 | 8 | class EmpDetails @Inject constructor() { 9 | 10 | fun displayEmpName(){ 11 | Log.d(TAG,"In EmpDetails Constructor Injection") 12 | } 13 | 14 | } -------------------------------------------------------------------------------- /DaggerPractice/src/main/java/com/dagger/practice/constructorDI/emp/EmployeeInfo.kt: -------------------------------------------------------------------------------- 1 | package com.dagger.practice.constructorDI.emp 2 | 3 | import javax.inject.Inject 4 | 5 | class EmployeeInfo @Inject constructor(empDetails: EmpDetails){ 6 | var empDetails: EmpDetails = empDetails 7 | 8 | fun empDetailsInfo(){ 9 | empDetails.displayEmpName() 10 | 11 | } 12 | } -------------------------------------------------------------------------------- /DaggerPractice/src/main/java/com/dagger/practice/interfaceInjection/Doctor.kt: -------------------------------------------------------------------------------- 1 | package com.dagger.practice.interfaceInjection 2 | 3 | import android.util.Log 4 | import javax.inject.Inject 5 | 6 | private const val TAG = "Doctor" 7 | class Doctor @Inject constructor(doctorType: DoctorType,doctorAge: DoctorAge) { 8 | var doctorType: DoctorType = doctorType 9 | var doctorAge:DoctorAge = doctorAge 10 | fun displayDoctorInfo(){ 11 | doctorType.displayDoctorType() 12 | doctorAge.displayDoctorAge() 13 | Log.d(TAG,"In DisplayDoctorInfo()") 14 | } 15 | } -------------------------------------------------------------------------------- /DaggerPractice/src/main/java/com/dagger/practice/interfaceInjection/DoctorAge.kt: -------------------------------------------------------------------------------- 1 | package com.dagger.practice.interfaceInjection 2 | 3 | import android.util.Log 4 | import javax.inject.Inject 5 | 6 | private const val TAG = "DoctorAge" 7 | class DoctorAge constructor(age:Integer, year:Integer) { 8 | var age:Integer = age 9 | var year:Integer = year 10 | fun displayDoctorAge(){ 11 | Log.d(TAG,"Doctor Age is $age and Year of Birth is $year") 12 | } 13 | } -------------------------------------------------------------------------------- /DaggerPractice/src/main/java/com/dagger/practice/interfaceInjection/DoctorComponent.kt: -------------------------------------------------------------------------------- 1 | package com.dagger.practice.interfaceInjection 2 | 3 | import com.dagger.practice.InterfaceInjectionActivity 4 | import dagger.Component 5 | 6 | @Component (modules = [PrivateDoctorModule::class]) 7 | 8 | interface DoctorComponent { 9 | 10 | fun inject(interfaceInjectionActivity: InterfaceInjectionActivity) 11 | } -------------------------------------------------------------------------------- /DaggerPractice/src/main/java/com/dagger/practice/interfaceInjection/DoctorType.kt: -------------------------------------------------------------------------------- 1 | package com.dagger.practice.interfaceInjection 2 | 3 | interface DoctorType { 4 | 5 | fun displayDoctorType() 6 | } -------------------------------------------------------------------------------- /DaggerPractice/src/main/java/com/dagger/practice/interfaceInjection/GovtDoctor.kt: -------------------------------------------------------------------------------- 1 | package com.dagger.practice.interfaceInjection 2 | 3 | import android.util.Log 4 | import javax.inject.Inject 5 | 6 | private const val TAG = "GovtDoctor" 7 | 8 | class GovtDoctor @Inject constructor(): DoctorType{ 9 | override fun displayDoctorType() { 10 | Log.d(TAG,"This is Govt Doctor") 11 | } 12 | 13 | } -------------------------------------------------------------------------------- /DaggerPractice/src/main/java/com/dagger/practice/interfaceInjection/GovtDoctorModule.kt: -------------------------------------------------------------------------------- 1 | package com.dagger.practice.interfaceInjection 2 | 3 | import dagger.Module 4 | import dagger.Provides 5 | 6 | @Module 7 | class GovtDoctorModule constructor(age:Integer,year : Integer) { 8 | 9 | var age:Integer = age 10 | var year : Integer = year 11 | 12 | @Provides 13 | fun provideDoctorAge() : DoctorAge{ 14 | return DoctorAge(age,year) 15 | } 16 | @Provides 17 | fun provideGovtDoctor() : DoctorType{ 18 | return GovtDoctor() 19 | } 20 | 21 | @Provides 22 | fun provideDoctor(doctorType: GovtDoctor,doctorAge: DoctorAge) : Doctor{ 23 | return Doctor(doctorType,doctorAge) 24 | } 25 | 26 | } -------------------------------------------------------------------------------- /DaggerPractice/src/main/java/com/dagger/practice/interfaceInjection/PrivateDoctor.kt: -------------------------------------------------------------------------------- 1 | package com.dagger.practice.interfaceInjection 2 | 3 | import android.util.Log 4 | import javax.inject.Inject 5 | 6 | private const val TAG = "GovtDoctor" 7 | 8 | class PrivateDoctor @Inject constructor(): DoctorType{ 9 | 10 | override fun displayDoctorType() { 11 | Log.d(TAG,"This is Pvt Doctor") 12 | } 13 | 14 | } -------------------------------------------------------------------------------- /DaggerPractice/src/main/java/com/dagger/practice/interfaceInjection/PrivateDoctorModule.kt: -------------------------------------------------------------------------------- 1 | package com.dagger.practice.interfaceInjection 2 | 3 | import dagger.Module 4 | import dagger.Provides 5 | import javax.inject.Named 6 | 7 | @Module 8 | class PrivateDoctorModule constructor(age:Integer,year:Integer) { 9 | 10 | var age:Integer = age 11 | var year:Integer = year 12 | 13 | 14 | @Provides 15 | fun provideDoctorAge(): DoctorAge { 16 | return DoctorAge(age,year) 17 | } 18 | @Provides 19 | fun providePrivateDoctor() : DoctorType{ 20 | return PrivateDoctor() 21 | } 22 | 23 | @Provides 24 | fun provideDoctor(doctorType: PrivateDoctor,doctorAge: DoctorAge) : Doctor{ 25 | return Doctor(doctorType,doctorAge) 26 | } 27 | 28 | } -------------------------------------------------------------------------------- /DaggerPractice/src/main/java/com/dagger/practice/namedInjection/Movie.kt: -------------------------------------------------------------------------------- 1 | package com.dagger.practice.namedInjection 2 | 3 | import javax.inject.Inject 4 | 5 | class Movie constructor(movieDetails: MovieDetails) { 6 | 7 | var movieDetails: MovieDetails = movieDetails 8 | 9 | fun displayMovie() { 10 | movieDetails.displayMovieDetails() 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /DaggerPractice/src/main/java/com/dagger/practice/namedInjection/MovieComponent.kt: -------------------------------------------------------------------------------- 1 | package com.dagger.practice.namedInjection 2 | 3 | import com.dagger.practice.NamedInjectionActivity 4 | import dagger.Component 5 | 6 | @Component(modules = [MovieModule::class]) 7 | interface MovieComponent { 8 | 9 | fun inject(namedInjectionActivity : NamedInjectionActivity) 10 | } -------------------------------------------------------------------------------- /DaggerPractice/src/main/java/com/dagger/practice/namedInjection/MovieDetails.kt: -------------------------------------------------------------------------------- 1 | package com.dagger.practice.namedInjection 2 | 3 | import android.util.Log 4 | import javax.inject.Inject 5 | import javax.inject.Named 6 | 7 | private const val TAG = "MovieDetails" 8 | class MovieDetails ( type:String, actor:String) { 9 | 10 | var type:String = type 11 | var actor:String = actor 12 | 13 | fun displayMovieDetails(){ 14 | Log.d(TAG,"Movie details: Movie Type is $type and actor in movie is $actor") 15 | } 16 | } -------------------------------------------------------------------------------- /DaggerPractice/src/main/java/com/dagger/practice/namedInjection/MovieModule.kt: -------------------------------------------------------------------------------- 1 | package com.dagger.practice.namedInjection 2 | 3 | import dagger.Module 4 | import dagger.Provides 5 | import javax.inject.Named 6 | 7 | @Module 8 | class MovieModule(movieType:String,movieActor:String){ 9 | var movieType:String = movieType 10 | var movieActor:String = movieActor 11 | 12 | @Provides 13 | @Named("type") 14 | fun provideMovieType():String = movieType 15 | 16 | @Provides 17 | @Named("actor") 18 | fun provideMovieActor():String = movieActor 19 | 20 | @Provides 21 | fun provideMovieDetails():MovieDetails = MovieDetails(movieType,movieActor) 22 | 23 | 24 | @Provides 25 | fun provideMovie(movieDetails: MovieDetails):Movie = Movie(movieDetails) 26 | 27 | 28 | } -------------------------------------------------------------------------------- /DaggerPractice/src/main/java/com/dagger/practice/singletonInjection/Driver.kt: -------------------------------------------------------------------------------- 1 | package com.dagger.practice.singletonInjection 2 | 3 | import android.util.Log 4 | 5 | private const val TAG = "Driver" 6 | class Driver constructor(driverName: String){ 7 | 8 | 9 | var driverName:String = driverName 10 | 11 | fun displayDriverInfo(){ 12 | Log.d(TAG,"Driver information is $this and name is $driverName") 13 | } 14 | } -------------------------------------------------------------------------------- /DaggerPractice/src/main/java/com/dagger/practice/singletonInjection/Student.kt: -------------------------------------------------------------------------------- 1 | package com.dagger.practice.singletonInjection 2 | 3 | import android.util.Log 4 | 5 | private const val TAG = "Student" 6 | class Student constructor(driver:Driver,studentName:String){ 7 | var studentName:String = studentName 8 | var driver:Driver = driver 9 | 10 | fun displayStudentInfo(){ 11 | Log.d(TAG,"Student Info is :: Student $studentName drives with $driver and driver Name is ${driver.driverName}") 12 | } 13 | } -------------------------------------------------------------------------------- /DaggerPractice/src/main/java/com/dagger/practice/singletonInjection/StudentComponent.kt: -------------------------------------------------------------------------------- 1 | package com.dagger.practice.singletonInjection 2 | 3 | import com.dagger.practice.SingletonInjectionActivity 4 | import dagger.Component 5 | import javax.inject.Singleton 6 | 7 | @Singleton 8 | @Component(modules = [StudentModule::class]) 9 | interface StudentComponent { 10 | 11 | fun inject(singletonInjectionActivity: SingletonInjectionActivity) 12 | } -------------------------------------------------------------------------------- /DaggerPractice/src/main/java/com/dagger/practice/singletonInjection/StudentModule.kt: -------------------------------------------------------------------------------- 1 | package com.dagger.practice.singletonInjection 2 | 3 | import dagger.Module 4 | import dagger.Provides 5 | import javax.inject.Named 6 | import javax.inject.Singleton 7 | 8 | @Module 9 | class StudentModule constructor(driverName:String,studentName : String){ 10 | 11 | var driverName:String = driverName 12 | var studentName:String = studentName 13 | 14 | @Named("driver") 15 | @Singleton 16 | @Provides 17 | fun provideDriverName() : String = driverName 18 | 19 | @Named("student Name") 20 | @Provides 21 | fun provideStudentName() : String = studentName 22 | 23 | 24 | @Singleton 25 | @Provides 26 | fun provideDriver():Driver = Driver(driverName) 27 | 28 | 29 | @Provides 30 | fun provideStudent(driver:Driver):Student = Student(driver,studentName) 31 | 32 | 33 | } -------------------------------------------------------------------------------- /DaggerPractice/src/main/java/com/dagger/practice/subComponentInjection/Cricket.kt: -------------------------------------------------------------------------------- 1 | package com.dagger.practice.subComponentInjection 2 | 3 | import android.util.Log 4 | 5 | private const val TAG = "Cricket" 6 | class Cricket constructor(player : String , sports: Sports) { 7 | var player : String = player 8 | var sports : Sports = sports 9 | fun displayCricketInfo(){ 10 | Log.d(TAG,"Name of Cricket Player is :: $player and its corresponding instance is $this Corresponding sports instance is $sports") 11 | } 12 | } -------------------------------------------------------------------------------- /DaggerPractice/src/main/java/com/dagger/practice/subComponentInjection/CricketComponent.kt: -------------------------------------------------------------------------------- 1 | package com.dagger.practice.subComponentInjection 2 | 3 | import com.dagger.practice.CricketActivity 4 | import dagger.Subcomponent 5 | 6 | @PerCricketActivity 7 | @Subcomponent (modules = [CricketModule::class]) 8 | 9 | interface CricketComponent { 10 | fun inject(cricketActivity: CricketActivity) 11 | } -------------------------------------------------------------------------------- /DaggerPractice/src/main/java/com/dagger/practice/subComponentInjection/CricketModule.kt: -------------------------------------------------------------------------------- 1 | package com.dagger.practice.subComponentInjection 2 | 3 | import dagger.Module 4 | import dagger.Provides 5 | 6 | @Module 7 | class CricketModule(playerName : String) { 8 | 9 | var playerName : String = playerName 10 | 11 | @PerCricketActivity 12 | @Provides 13 | fun provideCricketPlayerName():String = playerName 14 | 15 | 16 | @PerCricketActivity 17 | @Provides 18 | fun provideCricket(player:String , sports: Sports) : Cricket = Cricket(player,sports) 19 | 20 | } -------------------------------------------------------------------------------- /DaggerPractice/src/main/java/com/dagger/practice/subComponentInjection/PerCricketActivity.kt: -------------------------------------------------------------------------------- 1 | package com.dagger.practice.subComponentInjection 2 | 3 | import java.lang.annotation.Documented 4 | import java.lang.annotation.Retention 5 | import java.lang.annotation.RetentionPolicy 6 | import javax.inject.Scope 7 | 8 | @Scope 9 | @Documented 10 | @Retention(RetentionPolicy.RUNTIME) 11 | annotation class PerCricketActivity{ 12 | 13 | } -------------------------------------------------------------------------------- /DaggerPractice/src/main/java/com/dagger/practice/subComponentInjection/PerTennisActivity.kt: -------------------------------------------------------------------------------- 1 | package com.dagger.practice.subComponentInjection 2 | 3 | import java.lang.annotation.Documented 4 | import java.lang.annotation.Retention 5 | import java.lang.annotation.RetentionPolicy 6 | import javax.inject.Scope 7 | 8 | @Scope 9 | @Documented 10 | @Retention(RetentionPolicy.RUNTIME) 11 | annotation class PerTennisActivity{ 12 | 13 | } -------------------------------------------------------------------------------- /DaggerPractice/src/main/java/com/dagger/practice/subComponentInjection/Sports.kt: -------------------------------------------------------------------------------- 1 | package com.dagger.practice.subComponentInjection 2 | 3 | import android.util.Log 4 | 5 | private const val TAG = "Sports" 6 | class Sports constructor(sportsCenter : String) { 7 | var sportsCenter : String = sportsCenter 8 | fun displaySportsCenterInfo(){ 9 | Log.d(TAG, "Sports Center Info is $sportsCenter") 10 | 11 | } 12 | } -------------------------------------------------------------------------------- /DaggerPractice/src/main/java/com/dagger/practice/subComponentInjection/SportsComponent.kt: -------------------------------------------------------------------------------- 1 | package com.dagger.practice.subComponentInjection 2 | 3 | 4 | import dagger.Component 5 | import javax.inject.Singleton 6 | 7 | @Singleton 8 | @Component(modules = [SportsModule::class]) 9 | interface SportsComponent { 10 | fun getCricketComponent(cricketModule: CricketModule): CricketComponent 11 | fun getTennisComponent(tennisModule: TennisModule) : TennisComponent 12 | } -------------------------------------------------------------------------------- /DaggerPractice/src/main/java/com/dagger/practice/subComponentInjection/SportsModule.kt: -------------------------------------------------------------------------------- 1 | package com.dagger.practice.subComponentInjection 2 | 3 | import dagger.Module 4 | import dagger.Provides 5 | import javax.inject.Named 6 | import javax.inject.Singleton 7 | 8 | @Module 9 | class SportsModule(sportsCenter : String){ 10 | var sportsCenter : String = sportsCenter 11 | 12 | @Singleton 13 | @Named("sport center") 14 | @Provides 15 | fun provideSportCenter(): String = sportsCenter 16 | 17 | 18 | @Singleton 19 | @Provides 20 | fun provideSports(): Sports = Sports(sportsCenter) 21 | 22 | } -------------------------------------------------------------------------------- /DaggerPractice/src/main/java/com/dagger/practice/subComponentInjection/Tennis.kt: -------------------------------------------------------------------------------- 1 | package com.dagger.practice.subComponentInjection 2 | 3 | import android.util.Log 4 | 5 | private const val TAG = "Tennis" 6 | class Tennis constructor(playerName : String , sports : Sports) { 7 | var playerName : String = playerName 8 | var sports : Sports = sports 9 | fun displayTennisInfo(){ 10 | Log.d(TAG,"Tennis Player name is $playerName and its corresponding instance is $this and its corresponding sports instance is $sports") 11 | } 12 | } -------------------------------------------------------------------------------- /DaggerPractice/src/main/java/com/dagger/practice/subComponentInjection/TennisComponent.kt: -------------------------------------------------------------------------------- 1 | package com.dagger.practice.subComponentInjection 2 | 3 | import com.dagger.practice.TennisActivity 4 | import dagger.Subcomponent 5 | 6 | @PerTennisActivity 7 | @Subcomponent(modules = [TennisModule::class]) 8 | interface TennisComponent { 9 | fun inject(tennisActivity: TennisActivity) 10 | } -------------------------------------------------------------------------------- /DaggerPractice/src/main/java/com/dagger/practice/subComponentInjection/TennisModule.kt: -------------------------------------------------------------------------------- 1 | package com.dagger.practice.subComponentInjection 2 | 3 | import dagger.Module 4 | import dagger.Provides 5 | 6 | @Module 7 | class TennisModule constructor(playerName : String) { 8 | 9 | var playerName : String = playerName 10 | 11 | 12 | @PerTennisActivity 13 | @Provides 14 | fun providePlayerName():String = playerName 15 | 16 | 17 | @PerTennisActivity 18 | @Provides 19 | fun provideTennis(name : String, sports: Sports) : Tennis = Tennis(name,sports) 20 | 21 | } -------------------------------------------------------------------------------- /DaggerPractice/src/main/res/layout/activity_app_level_singleton.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | -------------------------------------------------------------------------------- /DaggerPractice/src/main/res/layout/activity_constructor_injection.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | -------------------------------------------------------------------------------- /DaggerPractice/src/main/res/layout/activity_cricket.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 |