├── .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 |
4 |
5 |
--------------------------------------------------------------------------------
/.idea/jarRepositories.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
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 |
18 |
--------------------------------------------------------------------------------
/DaggerPractice/src/main/res/layout/activity_dagger_practice.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
--------------------------------------------------------------------------------
/DaggerPractice/src/main/res/layout/activity_field_injection.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
--------------------------------------------------------------------------------
/DaggerPractice/src/main/res/layout/activity_interface_injection.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
--------------------------------------------------------------------------------
/DaggerPractice/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
--------------------------------------------------------------------------------
/DaggerPractice/src/main/res/layout/activity_named_injection.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
--------------------------------------------------------------------------------
/DaggerPractice/src/main/res/layout/activity_singleton_injection.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
--------------------------------------------------------------------------------
/DaggerPractice/src/main/res/layout/activity_sub_component_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
--------------------------------------------------------------------------------
/DaggerPractice/src/main/res/layout/activity_sub_component_sub.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
--------------------------------------------------------------------------------
/DaggerPractice/src/main/res/layout/activity_tennis.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
--------------------------------------------------------------------------------
/DaggerPractice/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/DaggerPractice/src/test/java/com/dagger/practice/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.dagger.practice
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 | }
--------------------------------------------------------------------------------
/KotlinPractice/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/KotlinPractice/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: ':AppNavigator')
38 | implementation project(path: ':Common')
39 | implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
40 | implementation 'androidx.core:core-ktx:1.2.0'
41 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
42 | implementation 'androidx.appcompat:appcompat:1.1.0'
43 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
44 | testImplementation 'junit:junit:4.12'
45 | androidTestImplementation 'androidx.test.ext:junit:1.1.1'
46 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
47 | }
--------------------------------------------------------------------------------
/KotlinPractice/consumer-rules.pro:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chandragithub2014/MVVM_Kotlin/29dead56325654276055caa9e0e2cb62240a99f2/KotlinPractice/consumer-rules.pro
--------------------------------------------------------------------------------
/KotlinPractice/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
--------------------------------------------------------------------------------
/KotlinPractice/src/androidTest/java/com/kotlinpractice/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.kotlinpractice
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.kotlinpractice.test", appContext.packageName)
23 | }
24 | }
--------------------------------------------------------------------------------
/KotlinPractice/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/KotlinPractice/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/KotlinPractice/src/test/java/com/kotlinpractice/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.kotlinpractice
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 | }
--------------------------------------------------------------------------------
/MVVMCleanArchitecture/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/MVVMCleanArchitecture/consumer-rules.pro:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chandragithub2014/MVVM_Kotlin/29dead56325654276055caa9e0e2cb62240a99f2/MVVMCleanArchitecture/consumer-rules.pro
--------------------------------------------------------------------------------
/MVVMCleanArchitecture/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
--------------------------------------------------------------------------------
/MVVMCleanArchitecture/src/androidTest/java/com/mvvm/cleanarchitecture/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.mvvm.cleanarchitecture
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.cleanarchitecture.test", appContext.packageName)
23 | }
24 | }
--------------------------------------------------------------------------------
/MVVMCleanArchitecture/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/MVVMCleanArchitecture/src/main/java/com/mvvm/cleanarchitecture/framework/RoomPostDataSource.kt:
--------------------------------------------------------------------------------
1 | package com.mvvm.cleanarchitecture.framework
2 |
3 | import android.content.Context
4 | import com.mvvm.cleanarchitecture.framework.db.DataBaseService
5 | import com.mvvm.cleanarchitecture.framework.db.PostEntity
6 | import com.mvvmcore.data.PostModel
7 | import com.mvvmcore.repository.PostDataSource
8 |
9 | class RoomPostDataSource(context: Context) : PostDataSource {
10 |
11 | val postDao = DataBaseService.getInstance(context).postDao()
12 |
13 | override suspend fun add(postModel: PostModel) = postDao.addPostEntity(PostEntity.fromPost(postModel))
14 |
15 |
16 | override suspend fun get(id: Long) = postDao.getPostEntity(id)?.toPost()
17 |
18 | override suspend fun getAll() = postDao.getAllPostEntities().map { it.toPost() }
19 |
20 | override suspend fun remove(postModel: PostModel) = postDao.removePost(PostEntity.fromPost(postModel))
21 | }
--------------------------------------------------------------------------------
/MVVMCleanArchitecture/src/main/java/com/mvvm/cleanarchitecture/framework/UseCases.kt:
--------------------------------------------------------------------------------
1 | package com.mvvm.cleanarchitecture.framework
2 |
3 | import com.mvvmcore.usecases.*
4 |
5 | data class UseCases(
6 | val addPost: AddPost,
7 | val getPost: GetPost,
8 | val getPosts: GetPosts,
9 | val removePost: RemovePost,
10 | val getPostCount: GetPostCount
11 |
12 |
13 | )
--------------------------------------------------------------------------------
/MVVMCleanArchitecture/src/main/java/com/mvvm/cleanarchitecture/framework/db/DataBaseService.kt:
--------------------------------------------------------------------------------
1 | package com.mvvm.cleanarchitecture.framework.db
2 |
3 | import android.content.Context
4 | import androidx.room.Database
5 | import androidx.room.Room
6 | import androidx.room.RoomDatabase
7 |
8 | @Database(entities = [PostEntity::class], version = 1)
9 | abstract class DataBaseService : RoomDatabase() {
10 |
11 | companion object {
12 |
13 | private const val DATABASE_NAME = "post.db"
14 |
15 | private var instance: DataBaseService? = null
16 |
17 | private fun create(context: Context): DataBaseService =
18 | Room.databaseBuilder(context, DataBaseService::class.java, DATABASE_NAME)
19 | .fallbackToDestructiveMigration()
20 | .build()
21 |
22 |
23 | fun getInstance(context: Context): DataBaseService =
24 | (instance ?: create(context)).also { instance = it }
25 | }
26 |
27 | abstract fun postDao() : PostDao
28 |
29 |
30 | }
--------------------------------------------------------------------------------
/MVVMCleanArchitecture/src/main/java/com/mvvm/cleanarchitecture/framework/db/PostDao.kt:
--------------------------------------------------------------------------------
1 | package com.mvvm.cleanarchitecture.framework.db
2 |
3 | import androidx.room.Dao
4 | import androidx.room.Delete
5 | import androidx.room.Insert
6 | import androidx.room.OnConflictStrategy.REPLACE
7 | import androidx.room.Query
8 | import com.mvvmcore.data.PostModel
9 |
10 |
11 |
12 | @Dao
13 | interface PostDao {
14 |
15 | @Insert(onConflict = REPLACE)
16 | suspend fun addPostEntity(postEntity: PostEntity)
17 |
18 | @Query("SELECT * FROM post where id = :id")
19 | suspend fun getPostEntity(id:Long) : PostEntity?
20 |
21 | @Query("SELECT * FROM post")
22 | suspend fun getAllPostEntities():List
23 |
24 | @Delete
25 | suspend fun removePost(postEntity: PostEntity)
26 | }
--------------------------------------------------------------------------------
/MVVMCleanArchitecture/src/main/java/com/mvvm/cleanarchitecture/framework/db/PostEntity.kt:
--------------------------------------------------------------------------------
1 | package com.mvvm.cleanarchitecture.framework.db
2 |
3 | import androidx.room.ColumnInfo
4 | import androidx.room.Entity
5 | import androidx.room.PrimaryKey
6 | import com.mvvmcore.data.PostModel
7 |
8 | @Entity(tableName = "post")
9 | data class PostEntity(
10 | val title: String,
11 | val body: String,
12 |
13 | @ColumnInfo(name = "creation_date")
14 | val creationTime: Long = 0,
15 | @ColumnInfo(name = "update_time")
16 | val updateTime: Long = 0,
17 | @PrimaryKey(autoGenerate = true)
18 | val id: Long = 0L
19 | ) {
20 | companion object {
21 | fun fromPost(postModel: PostModel) = PostEntity(
22 | postModel.title,
23 | postModel.body,
24 | postModel.creationTime,
25 | postModel.updateTime,
26 | postModel.id
27 | )
28 | }
29 |
30 | fun toPost() = PostModel(title,body,id,creationTime,updateTime)
31 | }
--------------------------------------------------------------------------------
/MVVMCleanArchitecture/src/main/java/com/mvvm/cleanarchitecture/framework/di/ApplicationModule.kt:
--------------------------------------------------------------------------------
1 | package com.mvvm.cleanarchitecture.framework.di
2 |
3 | import android.app.Application
4 | import dagger.Module
5 | import dagger.Provides
6 |
7 | @Module
8 | class ApplicationModule(val app : Application) {
9 | @Provides
10 | fun provideApp() = app
11 |
12 |
13 | }
--------------------------------------------------------------------------------
/MVVMCleanArchitecture/src/main/java/com/mvvm/cleanarchitecture/framework/di/RepositoryModule.kt:
--------------------------------------------------------------------------------
1 | package com.mvvm.cleanarchitecture.framework.di
2 |
3 | import android.app.Application
4 | import com.mvvm.cleanarchitecture.framework.RoomPostDataSource
5 | import com.mvvmcore.repository.PostDataRepository
6 | import com.mvvmcore.repository.PostDataSource
7 | import dagger.Module
8 | import dagger.Provides
9 |
10 | @Module
11 | class RepositoryModule {
12 |
13 | @Provides
14 | fun provideRepository(app : Application) = PostDataRepository(RoomPostDataSource(app))
15 | }
--------------------------------------------------------------------------------
/MVVMCleanArchitecture/src/main/java/com/mvvm/cleanarchitecture/framework/di/UseCasesModule.kt:
--------------------------------------------------------------------------------
1 | package com.mvvm.cleanarchitecture.framework.di
2 |
3 | import com.mvvm.cleanarchitecture.framework.UseCases
4 | import com.mvvmcore.repository.PostDataRepository
5 | import com.mvvmcore.usecases.*
6 | import dagger.Module
7 | import dagger.Provides
8 |
9 | @Module
10 | class UseCasesModule {
11 |
12 |
13 | @Provides
14 | fun getUseCases(repository: PostDataRepository) = UseCases(
15 | AddPost(repository),
16 | GetPost(repository),
17 | GetPosts(repository),
18 | RemovePost(repository),
19 | GetPostCount()
20 | )
21 | }
--------------------------------------------------------------------------------
/MVVMCleanArchitecture/src/main/java/com/mvvm/cleanarchitecture/framework/di/ViewModelComponent.kt:
--------------------------------------------------------------------------------
1 | package com.mvvm.cleanarchitecture.framework.di
2 |
3 | import com.mvvm.cleanarchitecture.framework.PostListViewModel
4 | import com.mvvm.cleanarchitecture.framework.PostViewModel
5 | import dagger.Component
6 |
7 | @Component(modules = [ApplicationModule::class,RepositoryModule::class,UseCasesModule::class])
8 | interface ViewModelComponent {
9 |
10 | fun inject(postViewModel: PostViewModel)
11 | fun inject(postListViewModel: PostListViewModel)
12 |
13 | }
--------------------------------------------------------------------------------
/MVVMCleanArchitecture/src/main/java/com/mvvm/cleanarchitecture/presentation/CleanArchitectureActivity.kt:
--------------------------------------------------------------------------------
1 | package com.mvvm.cleanarchitecture.presentation
2 |
3 | import androidx.appcompat.app.AppCompatActivity
4 | import android.os.Bundle
5 | import com.mvvm.cleanarchitecture.R
6 |
7 | class CleanArchitectureActivity : AppCompatActivity() {
8 | override fun onCreate(savedInstanceState: Bundle?) {
9 | super.onCreate(savedInstanceState)
10 | setContentView(R.layout.activity_clean_architecture)
11 | }
12 | }
--------------------------------------------------------------------------------
/MVVMCleanArchitecture/src/main/java/com/mvvm/cleanarchitecture/presentation/ListClickListener.kt:
--------------------------------------------------------------------------------
1 | package com.mvvm.cleanarchitecture.presentation
2 |
3 | interface ListClickListener {
4 | fun onClick(id: Long)
5 | }
--------------------------------------------------------------------------------
/MVVMCleanArchitecture/src/main/res/drawable/ic_check.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/MVVMCleanArchitecture/src/main/res/drawable/ic_create.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/MVVMCleanArchitecture/src/main/res/drawable/ic_delete.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/MVVMCleanArchitecture/src/main/res/layout/activity_clean_architecture.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
17 |
18 |
--------------------------------------------------------------------------------
/MVVMCleanArchitecture/src/main/res/menu/menu_delete.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/MVVMCleanArchitecture/src/main/res/navigation/navigation.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
14 |
20 |
21 |
26 |
27 |
31 |
32 |
--------------------------------------------------------------------------------
/MVVMCleanArchitecture/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 10dp
4 | 100dp
5 |
--------------------------------------------------------------------------------
/MVVMCleanArchitecture/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Hello blank fragment
4 |
--------------------------------------------------------------------------------
/MVVMCleanArchitecture/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
8 |
9 |
12 |
13 |
16 |
--------------------------------------------------------------------------------
/MVVMCleanArchitecture/src/test/java/com/mvvm/cleanarchitecture/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.mvvm.cleanarchitecture
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 | }
--------------------------------------------------------------------------------
/MVVMCore/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/MVVMCore/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 | }
--------------------------------------------------------------------------------
/MVVMCore/src/main/java/com/mvvmcore/data/PostModel.kt:
--------------------------------------------------------------------------------
1 | package com.mvvmcore.data
2 |
3 | data class PostModel(
4 | var title: String,
5 | var body: String,
6 | var id: Long = 0,
7 | var creationTime: Long = 0,
8 | var updateTime: Long = 0,
9 | var postCount : Int = 0
10 | )
--------------------------------------------------------------------------------
/MVVMCore/src/main/java/com/mvvmcore/repository/PostDataRepository.kt:
--------------------------------------------------------------------------------
1 | package com.mvvmcore.repository
2 |
3 | import com.mvvmcore.data.PostModel
4 |
5 | class PostDataRepository(private val postDataSource: PostDataSource) {
6 | suspend fun addPost(postModel: PostModel) = postDataSource.add(postModel)
7 | suspend fun getPost(id:Long) = postDataSource.get(id)
8 | suspend fun getPosts() = postDataSource.getAll()
9 | suspend fun removePost(postModel: PostModel) = postDataSource.remove(postModel)
10 |
11 | }
--------------------------------------------------------------------------------
/MVVMCore/src/main/java/com/mvvmcore/repository/PostDataSource.kt:
--------------------------------------------------------------------------------
1 | package com.mvvmcore.repository
2 |
3 | import com.mvvmcore.data.PostModel
4 |
5 | interface PostDataSource {
6 |
7 | suspend fun add(postModel: PostModel)
8 | suspend fun get(id:Long) : PostModel?
9 | suspend fun getAll(): List?
10 | suspend fun remove(postModel: PostModel)
11 |
12 | }
--------------------------------------------------------------------------------
/MVVMCore/src/main/java/com/mvvmcore/repository/PostRemoteDataRepository.kt:
--------------------------------------------------------------------------------
1 | package com.mvvmcore.repository
2 |
3 | class PostRemoteDataRepository(private val postRemoteDataSource: PostRemoteDataSource) {
4 | suspend fun fetchRemoteData() = postRemoteDataSource.getAllRemote()
5 | }
--------------------------------------------------------------------------------
/MVVMCore/src/main/java/com/mvvmcore/repository/PostRemoteDataSource.kt:
--------------------------------------------------------------------------------
1 | package com.mvvmcore.repository
2 |
3 | import com.mvvmcore.data.PostModel
4 |
5 | interface PostRemoteDataSource {
6 | suspend fun getAllRemote():List?
7 | }
--------------------------------------------------------------------------------
/MVVMCore/src/main/java/com/mvvmcore/usecases/AddPost.kt:
--------------------------------------------------------------------------------
1 | package com.mvvmcore.usecases
2 |
3 | import com.mvvmcore.data.PostModel
4 | import com.mvvmcore.repository.PostDataRepository
5 |
6 | class AddPost(private val postDataRepository: PostDataRepository){
7 | suspend operator fun invoke(postModel: PostModel) = postDataRepository.addPost(postModel)
8 | }
--------------------------------------------------------------------------------
/MVVMCore/src/main/java/com/mvvmcore/usecases/FetchRemotePosts.kt:
--------------------------------------------------------------------------------
1 | package com.mvvmcore.usecases
2 |
3 | import com.mvvmcore.repository.PostDataRepository
4 | import com.mvvmcore.repository.PostRemoteDataRepository
5 |
6 | class FetchRemotePosts(private val postRemoteDataRepository: PostRemoteDataRepository) {
7 | suspend operator fun invoke() = postRemoteDataRepository.fetchRemoteData()
8 | }
--------------------------------------------------------------------------------
/MVVMCore/src/main/java/com/mvvmcore/usecases/GetPost.kt:
--------------------------------------------------------------------------------
1 | package com.mvvmcore.usecases
2 |
3 | import com.mvvmcore.repository.PostDataRepository
4 |
5 | class GetPost(private val postDataRepository: PostDataRepository) {
6 | suspend operator fun invoke(id:Long) = postDataRepository.getPost(id)
7 | }
--------------------------------------------------------------------------------
/MVVMCore/src/main/java/com/mvvmcore/usecases/GetPostCount.kt:
--------------------------------------------------------------------------------
1 | package com.mvvmcore.usecases
2 |
3 | import com.mvvmcore.data.PostModel
4 |
5 | class GetPostCount {
6 |
7 | operator fun invoke(postModel: PostModel) = getCount(postModel.title) + getCount(postModel.body)
8 |
9 | private fun getCount(str : String) =
10 | str.split(" ","\n")
11 | .filter {
12 | it.contains(Regex(".*[a-zA-Z].*"))
13 | }.count()
14 |
15 | }
--------------------------------------------------------------------------------
/MVVMCore/src/main/java/com/mvvmcore/usecases/GetPosts.kt:
--------------------------------------------------------------------------------
1 | package com.mvvmcore.usecases
2 |
3 | import com.mvvmcore.repository.PostDataRepository
4 |
5 | class GetPosts(private val postDataRepository: PostDataRepository) {
6 | suspend operator fun invoke()=postDataRepository.getPosts()
7 | }
--------------------------------------------------------------------------------
/MVVMCore/src/main/java/com/mvvmcore/usecases/RemovePost.kt:
--------------------------------------------------------------------------------
1 | package com.mvvmcore.usecases
2 |
3 | import com.mvvmcore.data.PostModel
4 | import com.mvvmcore.repository.PostDataRepository
5 |
6 | class RemovePost(private val postDataRepository: PostDataRepository) {
7 | suspend operator fun invoke(postModel: PostModel) = postDataRepository.removePost(postModel)
8 | }
--------------------------------------------------------------------------------
/MVVMCoroutineRetrofit/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/MVVMCoroutineRetrofit/consumer-rules.pro:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chandragithub2014/MVVM_Kotlin/29dead56325654276055caa9e0e2cb62240a99f2/MVVMCoroutineRetrofit/consumer-rules.pro
--------------------------------------------------------------------------------
/MVVMCoroutineRetrofit/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
--------------------------------------------------------------------------------
/MVVMCoroutineRetrofit/src/androidTest/java/com/mvvmcoroutine/retrofit/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.mvvmcoroutine.retrofit
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.mvvmcoroutine.retrofit.test", appContext.packageName)
23 | }
24 | }
--------------------------------------------------------------------------------
/MVVMCoroutineRetrofit/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/MVVMCoroutineRetrofit/src/main/java/com/mvvmcoroutine/retrofit/di/NetworkComponent.kt:
--------------------------------------------------------------------------------
1 | package com.mvvmcoroutine.retrofit.di
2 |
3 | import com.mvvm.common.di.RetroRxModule
4 | import com.mvvmcoroutine.retrofit.login.viewmodel.LoginViewModelFactory
5 | import com.mvvmcoroutine.retrofit.userlist.viewmodel.UserListViewModelFactory
6 | import dagger.Component
7 | import javax.inject.Singleton
8 |
9 | @Singleton
10 | @Component(modules = [NetworkModule::class])
11 | interface NetworkComponent {
12 | fun inject(loginViewModelFactory: LoginViewModelFactory)
13 | fun inject(userListViewModelFactory: UserListViewModelFactory)
14 | }
--------------------------------------------------------------------------------
/MVVMCoroutineRetrofit/src/main/java/com/mvvmcoroutine/retrofit/login/model/LoginModel.kt:
--------------------------------------------------------------------------------
1 | package com.mvvmcoroutine.retrofit.login.model
2 |
3 | data class LoginModel(val email:String,val password : String) {
4 | }
--------------------------------------------------------------------------------
/MVVMCoroutineRetrofit/src/main/java/com/mvvmcoroutine/retrofit/login/model/TokenModel.kt:
--------------------------------------------------------------------------------
1 | package com.mvvmcoroutine.retrofit.login.model
2 |
3 | data class TokenModel(val token : String,val error : String)
4 |
--------------------------------------------------------------------------------
/MVVMCoroutineRetrofit/src/main/java/com/mvvmcoroutine/retrofit/login/view/RetrofitLoginActivity.kt:
--------------------------------------------------------------------------------
1 | package com.mvvmcoroutine.retrofit.login.view
2 |
3 | import androidx.appcompat.app.AppCompatActivity
4 | import android.os.Bundle
5 | import com.mvvm.appnavigator.replaceFragmentWithNoHistory
6 | import com.mvvmcoroutine.retrofit.R
7 |
8 | class RetrofitLoginActivity : AppCompatActivity() {
9 | override fun onCreate(savedInstanceState: Bundle?) {
10 | super.onCreate(savedInstanceState)
11 | setContentView(R.layout.activity_retrofit_login)
12 | replaceFragmentWithNoHistory(RetrofitLoginFragment(), R.id.container_fragment)
13 | }
14 | }
--------------------------------------------------------------------------------
/MVVMCoroutineRetrofit/src/main/java/com/mvvmcoroutine/retrofit/login/viewmodel/LoginViewModelFactory.kt:
--------------------------------------------------------------------------------
1 | package com.mvvmcoroutine.retrofit.login.viewmodel
2 |
3 | import androidx.lifecycle.ViewModel
4 | import androidx.lifecycle.ViewModelProvider
5 | import com.mvvmcoroutine.retrofit.di.DaggerNetworkComponent
6 | import com.mvvmcoroutine.retrofit.network.NetworkAPIService
7 | import kotlinx.coroutines.Dispatchers
8 | import retrofit2.Retrofit
9 | import javax.inject.Inject
10 |
11 | class LoginViewModelFactory : ViewModelProvider.Factory {
12 | @Inject
13 | lateinit var retrofit: Retrofit
14 | lateinit var networkAPIService: NetworkAPIService
15 | override fun create(modelClass: Class): T {
16 | DaggerNetworkComponent.create().inject(this)
17 | networkAPIService = retrofit.create(NetworkAPIService::class.java)
18 | if (modelClass.isAssignableFrom(LoginViewModel::class.java)) {
19 | return LoginViewModel(Dispatchers.Main,networkAPIService) as T
20 | }
21 | throw IllegalArgumentException("Unknown ViewModel class")
22 | }
23 | }
--------------------------------------------------------------------------------
/MVVMCoroutineRetrofit/src/main/java/com/mvvmcoroutine/retrofit/network/NetworkAPIService.kt:
--------------------------------------------------------------------------------
1 | package com.mvvmcoroutine.retrofit.network
2 |
3 | import com.mvvmcoroutine.retrofit.login.model.LoginModel
4 | import com.mvvmcoroutine.retrofit.login.model.TokenModel
5 | import com.mvvmcoroutine.retrofit.userlist.model.RetroResult
6 | import com.mvvmcoroutine.retrofit.userlist.model.RetroResultUser
7 | import com.mvvmcoroutine.retrofit.userlist.model.User
8 | import retrofit2.Response
9 | import retrofit2.http.*
10 |
11 | interface NetworkAPIService {
12 |
13 | @POST("/api/login")
14 | suspend fun validateLogin(@Body loginModel: LoginModel) : Response
15 |
16 | @GET("/api/users")
17 | suspend fun fetchUsers(@Query("page") page :Int): Response
18 |
19 | @GET("/api/users/{id}")
20 | suspend fun fetchSelectedUsers(@Path("id") id : Int): Response
21 | }
--------------------------------------------------------------------------------
/MVVMCoroutineRetrofit/src/main/java/com/mvvmcoroutine/retrofit/network/NetworkURL.kt:
--------------------------------------------------------------------------------
1 | package com.mvvmcoroutine.retrofit.network
2 |
3 | class NetworkURL {
4 | companion object {
5 | const val NETWORK_BASE_URL = "https://reqres.in"
6 | const val REQUEST_TIMEOUT = 60L
7 | }
8 | }
--------------------------------------------------------------------------------
/MVVMCoroutineRetrofit/src/main/java/com/mvvmcoroutine/retrofit/userlist/ItemClickListener.kt:
--------------------------------------------------------------------------------
1 | package com.mvvmcoroutine.retrofit.userlist
2 |
3 | import com.mvvmcoroutine.retrofit.userlist.model.Data
4 |
5 | interface ItemClickListener {
6 | fun setClickedInfo(data: Data)
7 | }
--------------------------------------------------------------------------------
/MVVMCoroutineRetrofit/src/main/java/com/mvvmcoroutine/retrofit/userlist/model/RetroResult.kt:
--------------------------------------------------------------------------------
1 | package com.mvvmcoroutine.retrofit.userlist.model
2 |
3 | data class RetroResult(val page : Int, val per_page:Int,val total:Int,val total_pages :Int,val data : List,val ad : Ad)
4 |
5 | data class Data(val id : Int,val email:String,val first_name:String,val last_name:String,val avatar:String)
6 |
7 | data class Ad(val url : String , val company : String , val text : String)
8 |
9 |
10 | //https://www.freecodeformat.com/json2pojo.php
--------------------------------------------------------------------------------
/MVVMCoroutineRetrofit/src/main/java/com/mvvmcoroutine/retrofit/userlist/model/RetroResultUser.kt:
--------------------------------------------------------------------------------
1 | package com.mvvmcoroutine.retrofit.userlist.model
2 |
3 | data class RetroResultUser(val data : Data , val ad: Ad)
4 |
5 |
--------------------------------------------------------------------------------
/MVVMCoroutineRetrofit/src/main/java/com/mvvmcoroutine/retrofit/userlist/model/User.kt:
--------------------------------------------------------------------------------
1 | package com.mvvmcoroutine.retrofit.userlist.model
2 |
3 | data class User(val id:Int,val email:String,val first_name:String,val last_name:String,val avatar:String)
--------------------------------------------------------------------------------
/MVVMCoroutineRetrofit/src/main/java/com/mvvmcoroutine/retrofit/userlist/view/UserListActivity.kt:
--------------------------------------------------------------------------------
1 | package com.mvvmcoroutine.retrofit.userlist.view
2 |
3 | import androidx.appcompat.app.AppCompatActivity
4 | import android.os.Bundle
5 | import com.mvvm.appnavigator.replaceFragmentWithNoHistory
6 | import com.mvvmcoroutine.retrofit.R
7 | import com.mvvmcoroutine.retrofit.login.view.RetrofitLoginFragment
8 |
9 | class UserListActivity : AppCompatActivity() {
10 | override fun onCreate(savedInstanceState: Bundle?) {
11 | super.onCreate(savedInstanceState)
12 | setContentView(R.layout.activity_user_list)
13 | replaceFragmentWithNoHistory(UserListFragment(), R.id.container_fragment)
14 | }
15 | }
--------------------------------------------------------------------------------
/MVVMCoroutineRetrofit/src/main/java/com/mvvmcoroutine/retrofit/userlist/viewmodel/UserListViewModelFactory.kt:
--------------------------------------------------------------------------------
1 | package com.mvvmcoroutine.retrofit.userlist.viewmodel
2 |
3 | import androidx.lifecycle.ViewModel
4 | import androidx.lifecycle.ViewModelProvider
5 | import com.mvvmcoroutine.retrofit.di.DaggerNetworkComponent
6 | import com.mvvmcoroutine.retrofit.login.viewmodel.LoginViewModel
7 | import com.mvvmcoroutine.retrofit.network.NetworkAPIService
8 | import kotlinx.coroutines.Dispatchers
9 | import retrofit2.Retrofit
10 | import javax.inject.Inject
11 |
12 | class UserListViewModelFactory : ViewModelProvider.Factory {
13 | @Inject
14 | lateinit var retrofit: Retrofit
15 | lateinit var networkAPIService: NetworkAPIService
16 | override fun create(modelClass: Class): T {
17 | DaggerNetworkComponent.create().inject(this)
18 | networkAPIService = retrofit.create(NetworkAPIService::class.java)
19 | if (modelClass.isAssignableFrom(UserListViewModel::class.java)) {
20 | return UserListViewModel(Dispatchers.Main,networkAPIService) as T
21 | }
22 | throw IllegalArgumentException("Unknown ViewModel class")
23 | }
24 | }
--------------------------------------------------------------------------------
/MVVMCoroutineRetrofit/src/main/res/drawable/ic_sync.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/MVVMCoroutineRetrofit/src/main/res/layout/activity_retrofit_login.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
13 |
14 |
--------------------------------------------------------------------------------
/MVVMCoroutineRetrofit/src/main/res/layout/activity_user_list.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
13 |
14 |
--------------------------------------------------------------------------------
/MVVMCoroutineRetrofit/src/main/res/layout/fragment_user_list.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
20 |
21 |
31 |
--------------------------------------------------------------------------------
/MVVMCoroutineRetrofit/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Hello blank fragment
4 |
--------------------------------------------------------------------------------
/MVVMCoroutineRetrofit/src/test/java/com/mvvmcoroutine/retrofit/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.mvvmcoroutine.retrofit
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 | }
--------------------------------------------------------------------------------
/MVVMCoroutineRetrofit/src/test/java/com/mvvmcoroutine/retrofit/TestCoroutineRule.kt:
--------------------------------------------------------------------------------
1 | package com.mvvmcoroutine.retrofit
2 |
3 | import kotlinx.coroutines.Dispatchers
4 | import kotlinx.coroutines.ExperimentalCoroutinesApi
5 | import kotlinx.coroutines.test.*
6 | import org.junit.rules.TestRule
7 | import org.junit.runner.Description
8 | import org.junit.runners.model.Statement
9 |
10 | /*
11 | During the unit-test, it enables the main dispatcher to use TestCoroutineDispatcher.
12 | After the test, it resets and cleasnup.
13 | */
14 | @ExperimentalCoroutinesApi
15 | class TestCoroutineRule : TestRule {
16 | private val testCoroutineDispatcher = TestCoroutineDispatcher()
17 |
18 | private val testCoroutineScope = TestCoroutineScope(testCoroutineDispatcher)
19 | override fun apply(base: Statement?, description: Description?) = object : Statement() {
20 | @Throws(Throwable::class)
21 | override fun evaluate() {
22 | Dispatchers.setMain(testCoroutineDispatcher)
23 |
24 | base?.evaluate()
25 |
26 | Dispatchers.resetMain()
27 | testCoroutineScope.cleanupTestCoroutines()
28 | }
29 | }
30 |
31 | fun runBlockingTest(block: suspend TestCoroutineScope.() -> Unit) =
32 | testCoroutineScope.runBlockingTest { block() }
33 | }
--------------------------------------------------------------------------------
/MVVMDataBinding/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/MVVMDataBinding/consumer-rules.pro:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chandragithub2014/MVVM_Kotlin/29dead56325654276055caa9e0e2cb62240a99f2/MVVMDataBinding/consumer-rules.pro
--------------------------------------------------------------------------------
/MVVMDataBinding/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
--------------------------------------------------------------------------------
/MVVMDataBinding/src/androidTest/java/com/mvvm/databinding/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.mvvm.databinding
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.databinding.test", appContext.packageName)
23 | }
24 | }
--------------------------------------------------------------------------------
/MVVMDataBinding/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
8 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/MVVMDataBinding/src/main/java/com/mvvm/databinding/model/BindingAdapters.kt:
--------------------------------------------------------------------------------
1 | package com.mvvm.databinding.model
2 |
3 | import android.widget.ImageView
4 | import androidx.databinding.BindingAdapter
5 | import com.squareup.picasso.Picasso
6 |
7 | @BindingAdapter("imageUrl")
8 | fun ImageView.loadImage(url: String) {
9 | if (url != "") {
10 | // Picasso.with(imageView.getContext()).load(url).resize(200, 200).into(imageView).
11 | Picasso.get().load(url).into(this)
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/MVVMDataBinding/src/main/java/com/mvvm/databinding/view/BasicDataBindingActivity.kt:
--------------------------------------------------------------------------------
1 | package com.mvvm.databinding.view
2 |
3 | import androidx.appcompat.app.AppCompatActivity
4 | import android.os.Bundle
5 | import com.mvvm.appnavigator.replaceFragmentWithNoHistory
6 | import com.mvvm.databinding.R
7 |
8 | class BasicDataBindingActivity : AppCompatActivity() {
9 | override fun onCreate(savedInstanceState: Bundle?) {
10 | super.onCreate(savedInstanceState)
11 | setContentView(R.layout.activity_basic_data_binding)
12 | replaceFragmentWithNoHistory(BasicDataBidingFragment(), R.id.container_fragment)
13 | }
14 | }
--------------------------------------------------------------------------------
/MVVMDataBinding/src/main/java/com/mvvm/databinding/view/DataBindingListActivity.kt:
--------------------------------------------------------------------------------
1 | package com.mvvm.databinding.view
2 |
3 | import androidx.appcompat.app.AppCompatActivity
4 | import android.os.Bundle
5 | import com.mvvm.appnavigator.replaceFragmentWithNoHistory
6 | import com.mvvm.databinding.R
7 |
8 | class DataBindingListActivity : AppCompatActivity() {
9 | override fun onCreate(savedInstanceState: Bundle?) {
10 | super.onCreate(savedInstanceState)
11 | setContentView(R.layout.activity_data_binding_list)
12 | replaceFragmentWithNoHistory(DataBindingListFragment(), R.id.container_fragment)
13 | }
14 | }
--------------------------------------------------------------------------------
/MVVMDataBinding/src/main/java/com/mvvm/databinding/view/DataBindingViewHolder.kt:
--------------------------------------------------------------------------------
1 | package com.mvvm.databinding.view
2 |
3 | import androidx.databinding.ViewDataBinding
4 | import androidx.recyclerview.widget.RecyclerView
5 | import com.mvvm.databinding.viewmodel.DataBidingViewModel
6 | import com.mvvm.databinding.BR
7 |
8 | class DataBindingViewHolder(binding:ViewDataBinding) : RecyclerView.ViewHolder(binding.root) {
9 | private var binding:ViewDataBinding = binding
10 | fun bind(viewModel: DataBidingViewModel, position: Integer) {
11 | viewModel.fetchEmpList(position)
12 | binding.setVariable(BR.viewmodel, viewModel)
13 | binding.setVariable(BR.position, position)
14 | binding.executePendingBindings()
15 | }
16 |
17 | }
--------------------------------------------------------------------------------
/MVVMDataBinding/src/main/res/layout/activity_basic_data_binding.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
14 |
15 |
--------------------------------------------------------------------------------
/MVVMDataBinding/src/main/res/layout/activity_data_binding_list.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
14 |
15 |
--------------------------------------------------------------------------------
/MVVMDataBinding/src/main/res/layout/fragment_data_binding_list.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
10 |
11 |
12 |
13 |
18 |
19 |
27 |
28 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/MVVMDataBinding/src/main/res/layout/fragment_data_binding_list_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
9 |
12 |
13 |
14 |
18 |
19 |
28 |
29 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/MVVMDataBinding/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #6200EE
4 | #3700B3
5 | #03DAC5
6 |
--------------------------------------------------------------------------------
/MVVMDataBinding/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Hello blank fragment
4 | EmpId
5 |
--------------------------------------------------------------------------------
/MVVMDataBinding/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
10 |
--------------------------------------------------------------------------------
/MVVMDataBinding/src/test/java/com/mvvm/databinding/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.mvvm.databinding
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 | }
--------------------------------------------------------------------------------
/MVVMLauncher/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/MVVMLauncher/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
--------------------------------------------------------------------------------
/MVVMLauncher/src/androidTest/java/com/logs/launcher/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.logs.launcher
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.logs.retrofitrx", appContext.packageName)
23 | }
24 | }
--------------------------------------------------------------------------------
/MVVMLauncher/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/MVVMLauncher/src/main/java/com/logs/launcher/LauncherActivity.kt:
--------------------------------------------------------------------------------
1 | package com.logs.launcher
2 |
3 |
4 | import android.os.Bundle
5 | import android.widget.Toast
6 | import androidx.appcompat.app.AppCompatActivity
7 | import com.logs.launcher.view.LauncherFragment
8 | import com.mvvm.appnavigator.replaceFragmentWithNoHistory
9 |
10 |
11 | class LauncherActivity : AppCompatActivity() {
12 | override fun onCreate(savedInstanceState: Bundle?) {
13 | super.onCreate(savedInstanceState)
14 | setContentView(R.layout.activity_launcher)
15 | //Toast.makeText(this,"In onCreate() method of Activity", Toast.LENGTH_LONG).show()
16 | // supportFragmentManager.beginTransaction().replace(R.id.container_fragment,LauncherFragment()).commit()
17 | replaceFragmentWithNoHistory(LauncherFragment(), R.id.container_fragment)
18 |
19 | }
20 |
21 |
22 | }
--------------------------------------------------------------------------------
/MVVMLauncher/src/main/java/com/logs/launcher/model/Launcher.kt:
--------------------------------------------------------------------------------
1 | package com.logs.launcher.model
2 |
3 |
--------------------------------------------------------------------------------
/MVVMLauncher/src/main/java/com/logs/launcher/view/AdapterClickListener.kt:
--------------------------------------------------------------------------------
1 | package com.logs.launcher.view
2 |
3 | interface AdapterClickListener {
4 | fun adapterClicked(position: Int, clickedItem: String?)
5 | }
6 |
--------------------------------------------------------------------------------
/MVVMLauncher/src/main/java/com/logs/launcher/view/LauncherAdapter.kt:
--------------------------------------------------------------------------------
1 | package com.logs.launcher.view
2 |
3 | import android.view.ViewGroup
4 | import androidx.recyclerview.widget.RecyclerView
5 |
6 | class LauncherAdapter(adapterClickListener: AdapterClickListener) : RecyclerView.Adapter() {
7 | var launcherList: MutableList = mutableListOf()
8 | var adapterClickListener: AdapterClickListener? = null
9 |
10 | init {
11 | this.adapterClickListener = adapterClickListener
12 | }
13 |
14 | override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): LauncherViewHolder =
15 | LauncherViewHolder(parent,adapterClickListener)
16 |
17 |
18 | override fun getItemCount(): Int = launcherList.size
19 |
20 |
21 |
22 | override fun onBindViewHolder(holder: LauncherViewHolder, position: Int) {
23 | holder.bindTo(launcherList[position])
24 | }
25 |
26 | fun setList(launcherList: MutableList) {
27 | this.launcherList = launcherList
28 | notifyDataSetChanged()
29 | }
30 |
31 |
32 | }
--------------------------------------------------------------------------------
/MVVMLauncher/src/main/java/com/logs/launcher/view/LauncherViewHolder.kt:
--------------------------------------------------------------------------------
1 | package com.logs.launcher.view
2 |
3 | import android.util.Log
4 | import android.view.LayoutInflater
5 | import android.view.ViewGroup
6 | import android.widget.TextView
7 | import androidx.recyclerview.widget.RecyclerView
8 | import com.logs.launcher.R
9 |
10 | class LauncherViewHolder(parent: ViewGroup,adapterClickListener: AdapterClickListener?) : RecyclerView.ViewHolder(LayoutInflater.from(parent.context).inflate(
11 | R.layout.launcher_list_item, parent, false)){
12 | private val nameView = itemView.findViewById(R.id.postId)
13 | var adapterClickListener: AdapterClickListener? = null
14 |
15 | init {
16 | this.adapterClickListener = adapterClickListener
17 | }
18 | fun bindTo(launcher: String?) {
19 | Log.d("Adapter", "Rebind.....")
20 | nameView.text = launcher
21 | itemView.setOnClickListener {
22 | adapterClickListener?.adapterClicked(adapterPosition, launcher)
23 | }
24 | }
25 | }
--------------------------------------------------------------------------------
/MVVMLauncher/src/main/res/layout/activity_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
14 |
15 |
--------------------------------------------------------------------------------
/MVVMLauncher/src/main/res/layout/fragment_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
18 |
--------------------------------------------------------------------------------
/MVVMLauncher/src/main/res/layout/launcher_list_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
15 |
--------------------------------------------------------------------------------
/MVVMLauncher/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/MVVMLauncher/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/MVVMLauncher/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chandragithub2014/MVVM_Kotlin/29dead56325654276055caa9e0e2cb62240a99f2/MVVMLauncher/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/MVVMLauncher/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chandragithub2014/MVVM_Kotlin/29dead56325654276055caa9e0e2cb62240a99f2/MVVMLauncher/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/MVVMLauncher/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chandragithub2014/MVVM_Kotlin/29dead56325654276055caa9e0e2cb62240a99f2/MVVMLauncher/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/MVVMLauncher/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chandragithub2014/MVVM_Kotlin/29dead56325654276055caa9e0e2cb62240a99f2/MVVMLauncher/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/MVVMLauncher/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chandragithub2014/MVVM_Kotlin/29dead56325654276055caa9e0e2cb62240a99f2/MVVMLauncher/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/MVVMLauncher/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chandragithub2014/MVVM_Kotlin/29dead56325654276055caa9e0e2cb62240a99f2/MVVMLauncher/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/MVVMLauncher/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chandragithub2014/MVVM_Kotlin/29dead56325654276055caa9e0e2cb62240a99f2/MVVMLauncher/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/MVVMLauncher/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chandragithub2014/MVVM_Kotlin/29dead56325654276055caa9e0e2cb62240a99f2/MVVMLauncher/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/MVVMLauncher/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chandragithub2014/MVVM_Kotlin/29dead56325654276055caa9e0e2cb62240a99f2/MVVMLauncher/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/MVVMLauncher/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chandragithub2014/MVVM_Kotlin/29dead56325654276055caa9e0e2cb62240a99f2/MVVMLauncher/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/MVVMLauncher/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #6200EE
4 | #3700B3
5 | #03DAC5
6 |
--------------------------------------------------------------------------------
/MVVMLauncher/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Launcher
3 | DynamicFeature
4 |
--------------------------------------------------------------------------------
/MVVMLauncher/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
10 |
--------------------------------------------------------------------------------
/MVVMLauncher/src/test/java/com/logs/launcher/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.logs.launcher
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 | }
--------------------------------------------------------------------------------
/MVVMLogin/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/MVVMLogin/consumer-rules.pro:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chandragithub2014/MVVM_Kotlin/29dead56325654276055caa9e0e2cb62240a99f2/MVVMLogin/consumer-rules.pro
--------------------------------------------------------------------------------
/MVVMLogin/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
--------------------------------------------------------------------------------
/MVVMLogin/src/androidTest/java/com/mvvmlogin/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.mvvmlogin
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.mvvmlogin.test", appContext.packageName)
23 | }
24 | }
--------------------------------------------------------------------------------
/MVVMLogin/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/MVVMLogin/src/main/java/com/mvvmlogin/model/LoginModel.kt:
--------------------------------------------------------------------------------
1 | package com.mvvmlogin.model
2 |
3 | data class LoginModel(val userName:String, val password:String)
--------------------------------------------------------------------------------
/MVVMLogin/src/main/java/com/mvvmlogin/view/LoginActivity.kt:
--------------------------------------------------------------------------------
1 | package com.mvvmlogin.view
2 |
3 | import androidx.appcompat.app.AppCompatActivity
4 | import android.os.Bundle
5 | import com.mvvm.appnavigator.replaceFragmentWithNoHistory
6 | import com.mvvmlogin.R
7 |
8 | class LoginActivity : AppCompatActivity() {
9 | override fun onCreate(savedInstanceState: Bundle?) {
10 | super.onCreate(savedInstanceState)
11 | setContentView(R.layout.activity_login)
12 | replaceFragmentWithNoHistory(LoginFragment(), R.id.container_fragment)
13 | }
14 | }
--------------------------------------------------------------------------------
/MVVMLogin/src/main/java/com/mvvmlogin/viewmodel/LoginViewModel.kt:
--------------------------------------------------------------------------------
1 | package com.mvvmlogin.viewmodel
2 |
3 | import androidx.lifecycle.LifecycleObserver
4 | import androidx.lifecycle.MutableLiveData
5 | import androidx.lifecycle.ViewModel
6 | import com.mvvmlogin.model.LoginModel
7 |
8 | class LoginViewModel : ViewModel(),LifecycleObserver{
9 |
10 |
11 | val loginStatus = MutableLiveData()
12 |
13 |
14 | fun validateLogin(loginModel: LoginModel){
15 | if(loginModel.userName.isNullOrEmpty() || loginModel.password.isNullOrEmpty()){
16 | loginStatus.value = "User Name or Password cannot be Empty"
17 |
18 | }else if(loginModel.userName.equals("admin",ignoreCase = true) &&
19 | loginModel.password == "admin"
20 | ){
21 |
22 | loginStatus.value = "Login Successful"
23 | }else{
24 |
25 | loginStatus.value = "Login Failed"
26 | }
27 | }
28 | }
--------------------------------------------------------------------------------
/MVVMLogin/src/main/res/layout/activity_login.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
14 |
15 |
--------------------------------------------------------------------------------
/MVVMLogin/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
--------------------------------------------------------------------------------
/MVVMLogin/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Email
4 | Password
5 | Sign in or register
6 | Sign in
7 | "Welcome!"
8 | Not a valid username
9 | Password must be >5 characters
10 | "Login failed"
11 |
12 | Hello blank fragment
13 |
--------------------------------------------------------------------------------
/MVVMLogin/src/test/java/com/mvvmlogin/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.mvvmlogin
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 | }
--------------------------------------------------------------------------------
/MVVMNavigator/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/MVVMNavigator/consumer-rules.pro:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chandragithub2014/MVVM_Kotlin/29dead56325654276055caa9e0e2cb62240a99f2/MVVMNavigator/consumer-rules.pro
--------------------------------------------------------------------------------
/MVVMNavigator/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
--------------------------------------------------------------------------------
/MVVMNavigator/src/androidTest/java/com/mvvm/navigator/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.mvvm.navigator
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.navigator.test", appContext.packageName)
23 | }
24 | }
--------------------------------------------------------------------------------
/MVVMNavigator/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/MVVMNavigator/src/main/java/com/mvvm/navigator/NavigationMainActivity.kt:
--------------------------------------------------------------------------------
1 | package com.mvvm.navigator
2 |
3 | import androidx.appcompat.app.AppCompatActivity
4 | import android.os.Bundle
5 |
6 | class NavigationMainActivity : AppCompatActivity() {
7 | override fun onCreate(savedInstanceState: Bundle?) {
8 | super.onCreate(savedInstanceState)
9 | setContentView(R.layout.navigation_main)
10 | }
11 | }
--------------------------------------------------------------------------------
/MVVMNavigator/src/main/java/com/mvvm/navigator/model/LoginModel.kt:
--------------------------------------------------------------------------------
1 | package com.mvvm.navigator.model
2 |
3 | data class LoginModel(val userName:String, val password:String)
--------------------------------------------------------------------------------
/MVVMNavigator/src/main/java/com/mvvm/navigator/view/LoginSuccessFragment.kt:
--------------------------------------------------------------------------------
1 | package com.mvvm.navigator.view
2 |
3 | import android.os.Bundle
4 | import androidx.fragment.app.Fragment
5 | import android.view.LayoutInflater
6 | import android.view.View
7 | import android.view.ViewGroup
8 | import androidx.navigation.fragment.navArgs
9 | import com.mvvm.navigator.R
10 | import kotlinx.android.synthetic.main.fragment_login_success.*
11 |
12 |
13 | class LoginSuccessFragment : Fragment() {
14 |
15 | private val args: LoginSuccessFragmentArgs by navArgs()
16 |
17 | override fun onCreate(savedInstanceState: Bundle?) {
18 | super.onCreate(savedInstanceState)
19 |
20 | }
21 |
22 | override fun onCreateView(
23 | inflater: LayoutInflater, container: ViewGroup?,
24 | savedInstanceState: Bundle?
25 | ): View? {
26 | // Inflate the layout for this fragment
27 | return inflater.inflate(R.layout.fragment_login_success, container, false)
28 | }
29 |
30 |
31 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
32 | super.onViewCreated(view, savedInstanceState)
33 | args?.let{
34 | val loginSuccessMessage = args.successMessage
35 | success_tv.text = loginSuccessMessage
36 | }
37 |
38 | }
39 |
40 |
41 | }
--------------------------------------------------------------------------------
/MVVMNavigator/src/main/java/com/mvvm/navigator/viewmodel/LoginViewModel.kt:
--------------------------------------------------------------------------------
1 | package com.mvvm.navigator.viewmodel
2 |
3 | import androidx.lifecycle.LifecycleObserver
4 | import androidx.lifecycle.LiveData
5 | import androidx.lifecycle.MutableLiveData
6 | import androidx.lifecycle.ViewModel
7 | import com.mvvm.navigator.model.LoginModel
8 |
9 |
10 | class LoginViewModel : ViewModel(),LifecycleObserver{
11 |
12 |
13 | var loginStatus = MutableLiveData()
14 | var loginButtonClicked = MutableLiveData()
15 |
16 |
17 | fun validateLogin(loginModel: LoginModel){
18 | if(loginModel.userName.isNullOrEmpty() || loginModel.password.isNullOrEmpty()){
19 | loginStatus.value = "User Name or Password cannot be Empty"
20 |
21 | }else if(loginModel.userName.equals("admin",ignoreCase = true) &&
22 | loginModel.password == "admin"
23 | ){
24 |
25 | loginStatus.value = "Login Successful"
26 | }else{
27 |
28 | loginStatus.value = "Login Failed"
29 | }
30 | }
31 |
32 | fun setLoginButtonClickedStatus(isClicked : Boolean){
33 | loginButtonClicked.value = isClicked
34 | }
35 |
36 | fun fetchLoginStatus():LiveData = loginStatus
37 |
38 | fun fetchLoginButtonClickedStatus():LiveData = loginButtonClicked
39 |
40 | override fun onCleared() {
41 | super.onCleared()
42 | loginStatus = MutableLiveData()
43 | }
44 | }
--------------------------------------------------------------------------------
/MVVMNavigator/src/main/res/layout/fragment_login_success.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
14 |
15 |
--------------------------------------------------------------------------------
/MVVMNavigator/src/main/res/layout/navigation_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
16 |
--------------------------------------------------------------------------------
/MVVMNavigator/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Login Success
4 |
--------------------------------------------------------------------------------
/MVVMNavigator/src/test/java/com/mvvm/navigator/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.mvvm.navigator
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 | }
--------------------------------------------------------------------------------
/MVVMRoom/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/MVVMRoom/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
--------------------------------------------------------------------------------
/MVVMRoom/src/androidTest/java/com/mvvm_kotlin/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.mvvm_kotlin
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_kotlin", appContext.packageName)
23 | }
24 | }
--------------------------------------------------------------------------------
/MVVMRoom/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/MVVMRoom/src/main/java/com/mvvm_kotlin/OnBottomSheetItemSelected.kt:
--------------------------------------------------------------------------------
1 | package com.mvvm_kotlin
2 |
3 | interface OnBottomSheetItemSelected {
4 |
5 | fun onItemSelected(item:String)
6 | }
--------------------------------------------------------------------------------
/MVVMRoom/src/main/java/com/mvvm_kotlin/view/RoomDataBaseAdapter.kt:
--------------------------------------------------------------------------------
1 | package com.mvvm_kotlin.view
2 |
3 | import android.view.ViewGroup
4 | import androidx.recyclerview.widget.RecyclerView
5 | import com.room.db.userRepo.UserInfo
6 |
7 | class RoomDataBaseAdapter : RecyclerView.Adapter(){
8 |
9 | var userList: MutableList = mutableListOf()
10 |
11 | override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RoomViewHolder = RoomViewHolder(parent)
12 |
13 |
14 | override fun getItemCount(): Int = userList.size
15 |
16 |
17 |
18 | override fun onBindViewHolder(holder: RoomViewHolder, position: Int) {
19 | holder.bindTo(userList[position])
20 | }
21 |
22 | fun setList(userList: MutableList) {
23 | this.userList = userList
24 | notifyDataSetChanged()
25 | }
26 |
27 |
28 |
29 | }
--------------------------------------------------------------------------------
/MVVMRoom/src/main/java/com/mvvm_kotlin/view/RoomViewHolder.kt:
--------------------------------------------------------------------------------
1 | package com.mvvm_kotlin.view
2 |
3 | import android.util.Log
4 | import android.view.LayoutInflater
5 | import android.view.ViewGroup
6 | import android.widget.TextView
7 | import androidx.recyclerview.widget.RecyclerView
8 | import com.mvvm_kotlin.R
9 | import com.room.db.userRepo.UserInfo
10 |
11 |
12 | class RoomViewHolder(parent: ViewGroup) : RecyclerView.ViewHolder(
13 | LayoutInflater.from(parent.context).inflate(
14 | R.layout.room_list_item, parent, false)){
15 | private val nameView = itemView.findViewById(R.id.name)
16 | private val cityView = itemView.findViewById(R.id.city)
17 | private val ageView = itemView.findViewById(R.id.age)
18 | private val mobileView = itemView.findViewById(R.id.mobile)
19 |
20 |
21 |
22 | fun bindTo(launcher: UserInfo?) {
23 | Log.d("Adapter", "Rebind.....")
24 | nameView.text = launcher?.username
25 | cityView.text = launcher?.city
26 | ageView.text = (launcher?.age.toString())
27 | mobileView.text = launcher?.phone
28 |
29 | }
30 | }
--------------------------------------------------------------------------------
/MVVMRoom/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
14 |
15 |
--------------------------------------------------------------------------------
/MVVMRoom/src/main/res/layout/fragment_add_user.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
13 |
14 |
--------------------------------------------------------------------------------
/MVVMRoom/src/main/res/menu/menu.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/MVVMRoom/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/MVVMRoom/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/MVVMRoom/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chandragithub2014/MVVM_Kotlin/29dead56325654276055caa9e0e2cb62240a99f2/MVVMRoom/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/MVVMRoom/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chandragithub2014/MVVM_Kotlin/29dead56325654276055caa9e0e2cb62240a99f2/MVVMRoom/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/MVVMRoom/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chandragithub2014/MVVM_Kotlin/29dead56325654276055caa9e0e2cb62240a99f2/MVVMRoom/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/MVVMRoom/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chandragithub2014/MVVM_Kotlin/29dead56325654276055caa9e0e2cb62240a99f2/MVVMRoom/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/MVVMRoom/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chandragithub2014/MVVM_Kotlin/29dead56325654276055caa9e0e2cb62240a99f2/MVVMRoom/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/MVVMRoom/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chandragithub2014/MVVM_Kotlin/29dead56325654276055caa9e0e2cb62240a99f2/MVVMRoom/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/MVVMRoom/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chandragithub2014/MVVM_Kotlin/29dead56325654276055caa9e0e2cb62240a99f2/MVVMRoom/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/MVVMRoom/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chandragithub2014/MVVM_Kotlin/29dead56325654276055caa9e0e2cb62240a99f2/MVVMRoom/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/MVVMRoom/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chandragithub2014/MVVM_Kotlin/29dead56325654276055caa9e0e2cb62240a99f2/MVVMRoom/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/MVVMRoom/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chandragithub2014/MVVM_Kotlin/29dead56325654276055caa9e0e2cb62240a99f2/MVVMRoom/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/MVVMRoom/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #6200EE
4 | #3700B3
5 | #03DAC5
6 |
--------------------------------------------------------------------------------
/MVVMRoom/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | MVVM_Kotlin
3 |
4 | Hello blank fragment
5 |
--------------------------------------------------------------------------------
/MVVMRoom/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
10 |
--------------------------------------------------------------------------------
/MVVMRoom/src/test/java/com/mvvm_kotlin/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.mvvm_kotlin
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 | }
--------------------------------------------------------------------------------
/MVVMRxRetrofit/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/MVVMRxRetrofit/consumer-rules.pro:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chandragithub2014/MVVM_Kotlin/29dead56325654276055caa9e0e2cb62240a99f2/MVVMRxRetrofit/consumer-rules.pro
--------------------------------------------------------------------------------
/MVVMRxRetrofit/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
--------------------------------------------------------------------------------
/MVVMRxRetrofit/src/androidTest/java/com/rxretrofit/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.rxretrofit
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.rxretrofit.test", appContext.packageName)
23 | }
24 | }
--------------------------------------------------------------------------------
/MVVMRxRetrofit/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
10 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/MVVMRxRetrofit/src/main/java/com/rxretrofit/DI/RetroRxComponent.kt:
--------------------------------------------------------------------------------
1 | package com.rxretrofit.DI
2 |
3 | import com.mvvm.common.di.RetroRxModule
4 | import com.rxretrofit.viewmodel.RetroCoroutineViewModel
5 | import com.rxretrofit.viewmodel.RetroCoroutineViewModelFactory
6 | import com.rxretrofit.viewmodel.RetroRXViewModel
7 | import com.rxretrofit.viewmodel.RetroViewModelFactory
8 | import dagger.Component
9 | import javax.inject.Singleton
10 |
11 | @Singleton
12 | @Component(modules = [RetroRxModule::class])
13 | interface RetroRxComponent {
14 | fun inject(retroRXViewModel: RetroRXViewModel)
15 | fun inject(retroCoroutineViewModel: RetroCoroutineViewModel)
16 | fun inject(retroCoroutineViewModelFactory: RetroCoroutineViewModelFactory)
17 | fun inject(retroViewModelFactory: RetroViewModelFactory)
18 | }
--------------------------------------------------------------------------------
/MVVMRxRetrofit/src/main/java/com/rxretrofit/model/RetroRxModel.kt:
--------------------------------------------------------------------------------
1 | package com.rxretrofit.model
2 |
3 | data class RetroRxModel(val title: String, val body: String, val id: String)
--------------------------------------------------------------------------------
/MVVMRxRetrofit/src/main/java/com/rxretrofit/view/RetroRxActivity.kt:
--------------------------------------------------------------------------------
1 | package com.rxretrofit.view
2 |
3 | import androidx.appcompat.app.AppCompatActivity
4 | import android.os.Bundle
5 | import com.mvvm.appnavigator.replaceFragmentWithNoHistory
6 | import com.rxretrofit.R
7 |
8 | class RetroRxActivity : AppCompatActivity() {
9 | override fun onCreate(savedInstanceState: Bundle?) {
10 | super.onCreate(savedInstanceState)
11 | setContentView(R.layout.activity_retro_rx)
12 | replaceFragmentWithNoHistory(RetroRXFragment(), R.id.container_fragment)
13 | }
14 | }
--------------------------------------------------------------------------------
/MVVMRxRetrofit/src/main/java/com/rxretrofit/view/RetroRxCoroutineActivity.kt:
--------------------------------------------------------------------------------
1 | package com.rxretrofit.view
2 |
3 | import androidx.appcompat.app.AppCompatActivity
4 | import android.os.Bundle
5 | import com.mvvm.appnavigator.replaceFragmentWithNoHistory
6 | import com.rxretrofit.R
7 |
8 | class RetroRxCoroutineActivity : AppCompatActivity() {
9 | override fun onCreate(savedInstanceState: Bundle?) {
10 | super.onCreate(savedInstanceState)
11 | setContentView(R.layout.activity_retro_rx)
12 | replaceFragmentWithNoHistory(RetroRxCoroutineFragment(), R.id.container_fragment)
13 | }
14 | }
--------------------------------------------------------------------------------
/MVVMRxRetrofit/src/main/java/com/rxretrofit/view/RetroViewHolder.kt:
--------------------------------------------------------------------------------
1 | package com.rxretrofit.view
2 |
3 | import android.util.Log
4 | import android.view.LayoutInflater
5 | import android.view.ViewGroup
6 | import android.widget.TextView
7 | import androidx.recyclerview.widget.RecyclerView
8 | import com.rxretrofit.R
9 | import com.rxretrofit.model.RetroRxModel
10 |
11 |
12 | class RetroViewHolder(parent: ViewGroup) : RecyclerView.ViewHolder(
13 | LayoutInflater.from(parent.context).inflate(
14 | R.layout.retro_list_item, parent, false)){
15 | private val postId = itemView.findViewById(R.id.postId)
16 | private val postTitle = itemView.findViewById(R.id.postTitle)
17 | private val postBody = itemView.findViewById(R.id.postBody)
18 |
19 |
20 |
21 | fun bindTo(retroRxModel: RetroRxModel?) {
22 | Log.d("Adapter", "Rebind.....")
23 | retroRxModel?.let {
24 | postId.text = retroRxModel.id
25 | postBody.text = retroRxModel.body
26 | postTitle.text = retroRxModel.title
27 |
28 | }
29 |
30 |
31 | }
32 | }
--------------------------------------------------------------------------------
/MVVMRxRetrofit/src/main/java/com/rxretrofit/view/RetrofitAdapter.kt:
--------------------------------------------------------------------------------
1 | package com.rxretrofit.view
2 |
3 | import android.view.ViewGroup
4 | import androidx.recyclerview.widget.RecyclerView
5 | import com.rxretrofit.model.RetroRxModel
6 |
7 | class RetrofitAdapter : RecyclerView.Adapter(){
8 |
9 | var postList: List = listOf()
10 | override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) = RetroViewHolder(parent)
11 |
12 |
13 | override fun getItemCount(): Int = postList.size
14 |
15 |
16 |
17 |
18 |
19 | override fun onBindViewHolder(holder: RetroViewHolder, position: Int) {
20 | holder.bindTo(postList[position])
21 | }
22 |
23 |
24 | fun setList(postList: List) {
25 | this.postList = postList
26 | notifyDataSetChanged()
27 | }
28 | }
--------------------------------------------------------------------------------
/MVVMRxRetrofit/src/main/java/com/rxretrofit/viewmodel/APIService.kt:
--------------------------------------------------------------------------------
1 | package com.rxretrofit.viewmodel
2 |
3 | import com.rxretrofit.model.RetroRxModel
4 | import io.reactivex.Single
5 | import retrofit2.Response
6 | import retrofit2.http.GET
7 |
8 | interface APIService {
9 | // https://jsonplaceholder.typicode.com/posts
10 | @GET("/posts")
11 | fun makeRequest(): Single>
12 |
13 | @GET("/posts")
14 | suspend fun fetchPosts(): Response>
15 |
16 |
17 | @GET("/posts")
18 | suspend fun fetchUserPosts(): Response>
19 | }
--------------------------------------------------------------------------------
/MVVMRxRetrofit/src/main/java/com/rxretrofit/viewmodel/RetroCoroutineViewModelFactory.kt:
--------------------------------------------------------------------------------
1 | package com.rxretrofit.viewmodel
2 |
3 | import androidx.lifecycle.ViewModel
4 | import androidx.lifecycle.ViewModelProvider
5 | import com.rxretrofit.DI.DaggerRetroRxComponent
6 | import kotlinx.coroutines.CoroutineDispatcher
7 | import kotlinx.coroutines.Dispatchers
8 | import retrofit2.Retrofit
9 | import javax.inject.Inject
10 |
11 | class RetroCoroutineViewModelFactory : ViewModelProvider.Factory {
12 | @Inject
13 | lateinit var retrofit: Retrofit
14 | lateinit var apiService: APIService
15 |
16 | @ExperimentalStdlibApi
17 | override fun create(modelClass: Class): T {
18 | DaggerRetroRxComponent.create().inject(this)
19 | apiService = retrofit.create(APIService::class.java)
20 |
21 | if (modelClass.isAssignableFrom(RetroCoroutineViewModel::class.java)) {
22 | return RetroCoroutineViewModel(Dispatchers.Main,apiService) as T
23 | }
24 | throw IllegalArgumentException("Unknown ViewModel class")
25 | }
26 |
27 |
28 | }
--------------------------------------------------------------------------------
/MVVMRxRetrofit/src/main/java/com/rxretrofit/viewmodel/RetroViewModelFactory.kt:
--------------------------------------------------------------------------------
1 | package com.rxretrofit.viewmodel
2 |
3 | import androidx.lifecycle.ViewModel
4 | import androidx.lifecycle.ViewModelProvider
5 | import com.rxretrofit.DI.DaggerRetroRxComponent
6 | import kotlinx.coroutines.CoroutineDispatcher
7 | import kotlinx.coroutines.Dispatchers
8 | import retrofit2.Retrofit
9 | import javax.inject.Inject
10 |
11 | class RetroViewModelFactory : ViewModelProvider.Factory {
12 | @Inject
13 | lateinit var retrofit: Retrofit
14 | lateinit var apiService: APIService
15 |
16 | @ExperimentalStdlibApi
17 | override fun create(modelClass: Class): T {
18 | DaggerRetroRxComponent.create().inject(this)
19 | apiService = retrofit.create(APIService::class.java)
20 |
21 | if (modelClass.isAssignableFrom(RetroRXViewModel::class.java)) {
22 | return RetroRXViewModel(apiService) as T
23 | }
24 | throw IllegalArgumentException("Unknown ViewModel class")
25 | }
26 |
27 |
28 | }
--------------------------------------------------------------------------------
/MVVMRxRetrofit/src/main/res/layout/activity_retro_rx.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
14 |
15 |
--------------------------------------------------------------------------------
/MVVMRxRetrofit/src/main/res/layout/activity_retro_rx_coroutine.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
--------------------------------------------------------------------------------
/MVVMRxRetrofit/src/main/res/layout/fragment_retro_rx_coroutine.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
13 |
14 |
--------------------------------------------------------------------------------
/MVVMRxRetrofit/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #6200EE
4 | #3700B3
5 | #03DAC5
6 |
--------------------------------------------------------------------------------
/MVVMRxRetrofit/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Hello blank fragment
4 |
--------------------------------------------------------------------------------
/MVVMRxRetrofit/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
10 |
--------------------------------------------------------------------------------
/MVVMRxRetrofit/src/test/java/com/rxretrofit/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.rxretrofit
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 | }
--------------------------------------------------------------------------------
/MVVMRxRetrofit/src/test/java/com/rxretrofit/RetroRXViewModelPrivateMethodTest.kt:
--------------------------------------------------------------------------------
1 | package com.rxretrofit
2 |
3 | import com.rxretrofit.viewmodel.RetroRXViewModel
4 | import org.junit.Before
5 | import org.junit.Test
6 | import org.junit.runner.RunWith
7 | import org.powermock.api.easymock.PowerMock
8 | import org.powermock.api.easymock.PowerMock.createPartialMock
9 | import org.powermock.api.mockito.PowerMockito
10 | import org.powermock.core.classloader.annotations.PrepareForTest
11 | import org.powermock.modules.junit4.PowerMockRunner
12 |
13 |
14 | @RunWith(PowerMockRunner::class)
15 | @PrepareForTest(RetroRXViewModel::class)
16 | class RetroRXViewModelPrivateMethodTest {
17 |
18 | private var someInstance: RetroRXViewModel? = null
19 |
20 |
21 | @Test
22 | fun `test private method`(){
23 | val mock: RetroRXViewModel = createPartialMock(RetroRXViewModel::class.java, "onError")
24 | // PowerMock.expectPrivate(RetroRXViewModelclass,"onError","")
25 | }
26 | }
--------------------------------------------------------------------------------
/MVVMRxRetrofit/src/test/java/com/rxretrofit/TestCoroutineRule.kt:
--------------------------------------------------------------------------------
1 | package com.rxretrofit
2 |
3 | import kotlinx.coroutines.Dispatchers
4 | import kotlinx.coroutines.ExperimentalCoroutinesApi
5 | import kotlinx.coroutines.test.*
6 | import org.junit.rules.TestRule
7 | import org.junit.runner.Description
8 | import org.junit.runners.model.Statement
9 |
10 | /*
11 | During the unit-test, it enables the main dispatcher to use TestCoroutineDispatcher.
12 | After the test, it resets and cleasnup.
13 | */
14 | @ExperimentalCoroutinesApi
15 | class TestCoroutineRule : TestRule {
16 | private val testCoroutineDispatcher = TestCoroutineDispatcher()
17 |
18 | private val testCoroutineScope = TestCoroutineScope(testCoroutineDispatcher)
19 | override fun apply(base: Statement?, description: Description?) = object : Statement() {
20 | @Throws(Throwable::class)
21 | override fun evaluate() {
22 | Dispatchers.setMain(testCoroutineDispatcher)
23 |
24 | base?.evaluate()
25 |
26 | Dispatchers.resetMain()
27 | testCoroutineScope.cleanupTestCoroutines()
28 | }
29 | }
30 |
31 | fun runBlockingTest(block: suspend TestCoroutineScope.() -> Unit) =
32 | testCoroutineScope.runBlockingTest { block() }
33 | }
--------------------------------------------------------------------------------
/MVVMRxRetrofit/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker:
--------------------------------------------------------------------------------
1 | mock-maker-inline
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # MVVM_Kotlin
2 | MVVM Kotlin Modular Project
3 | This project demonstrates all the JEt PAck Components with Kotlin and MVVM with Modular Approach
4 |
--------------------------------------------------------------------------------
/RoomRepository/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/RoomRepository/consumer-rules.pro:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chandragithub2014/MVVM_Kotlin/29dead56325654276055caa9e0e2cb62240a99f2/RoomRepository/consumer-rules.pro
--------------------------------------------------------------------------------
/RoomRepository/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
--------------------------------------------------------------------------------
/RoomRepository/src/androidTest/java/com/room/db/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.room.db
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.room.db.test", appContext.packageName)
23 | }
24 | }
--------------------------------------------------------------------------------
/RoomRepository/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
--------------------------------------------------------------------------------
/RoomRepository/src/main/java/com/room/db/database/RepositoryDB.kt:
--------------------------------------------------------------------------------
1 | package com.room.db.database
2 |
3 | import android.content.Context
4 | import androidx.room.Database
5 | import androidx.room.Room
6 | import androidx.room.RoomDatabase
7 | import com.room.db.userRepo.UserInfo
8 | import com.room.db.userRepo.UserInfoDao
9 |
10 | @Database(entities = [UserInfo::class], version = 1)
11 | abstract class RepositoryDB : RoomDatabase() {
12 |
13 | abstract fun userDao(): UserInfoDao
14 |
15 | companion object {
16 |
17 | @Volatile private var INSTANCE: RepositoryDB? = null
18 |
19 | fun getInstance(context: Context): RepositoryDB =
20 | INSTANCE ?: synchronized(this) {
21 | INSTANCE ?: buildDatabase(context).also { INSTANCE = it }
22 | }
23 |
24 | private fun buildDatabase(context: Context) =
25 | Room.databaseBuilder(context.applicationContext,
26 | RepositoryDB::class.java, "Users.db")
27 | .build()
28 | }
29 | }
--------------------------------------------------------------------------------
/RoomRepository/src/main/java/com/room/db/userRepo/UserInfo.kt:
--------------------------------------------------------------------------------
1 | package com.room.db.userRepo
2 |
3 | import androidx.room.ColumnInfo
4 | import androidx.room.Entity
5 | import androidx.room.PrimaryKey
6 |
7 | @Entity(tableName = "user_info")
8 | data class UserInfo(
9 | val username:String,
10 | @ColumnInfo(name = "password_hash")
11 | val passwordHash:Int,
12 | val age:Int,
13 | val city:String,
14 | val phone:String){
15 | @PrimaryKey(autoGenerate = true) var id: Long = 0
16 | }
--------------------------------------------------------------------------------
/RoomRepository/src/main/java/com/room/db/userRepo/UserInfoDao.kt:
--------------------------------------------------------------------------------
1 | package com.room.db.userRepo
2 |
3 | import androidx.lifecycle.LiveData
4 | import androidx.room.Dao
5 | import androidx.room.Insert
6 | import androidx.room.OnConflictStrategy
7 | import androidx.room.Query
8 | @Dao
9 | interface UserInfoDao {
10 |
11 | @Insert(onConflict = OnConflictStrategy.REPLACE)
12 | suspend fun insertAll(userInfoList: MutableList)
13 |
14 | /* @Query("DELETE FROM data_info")
15 | fun deleteAll()*/
16 |
17 | @Query("SELECT * from user_info ORDER BY id ASC")
18 | fun getAllPosts(): LiveData>
19 |
20 | @Query("SELECT * from user_info where username = :userName")
21 | suspend fun getUserInfo(userName:String):UserInfo
22 |
23 | @Query("DELETE from user_info where id = :id")
24 | suspend fun deleteUser(id:Long)
25 |
26 | @Insert(onConflict = OnConflictStrategy.REPLACE)
27 | suspend fun insertRow(userInfo: UserInfo): Long
28 | }
--------------------------------------------------------------------------------
/RoomRepository/src/test/java/com/room/db/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.room.db
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 | }
--------------------------------------------------------------------------------
/RxJavaPractice/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/RxJavaPractice/consumer-rules.pro:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chandragithub2014/MVVM_Kotlin/29dead56325654276055caa9e0e2cb62240a99f2/RxJavaPractice/consumer-rules.pro
--------------------------------------------------------------------------------
/RxJavaPractice/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
--------------------------------------------------------------------------------
/RxJavaPractice/src/androidTest/java/com/rxjava/practice/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.rxjava.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.rxjava.practice.test", appContext.packageName)
23 | }
24 | }
--------------------------------------------------------------------------------
/RxJavaPractice/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/RxJavaPractice/src/main/java/com/rxjava/practice/Address.kt:
--------------------------------------------------------------------------------
1 | package com.rxjava.practice
2 |
3 | data class Address(val addressName : String)
--------------------------------------------------------------------------------
/RxJavaPractice/src/main/java/com/rxjava/practice/DataSource.kt:
--------------------------------------------------------------------------------
1 | package com.rxjava.practice
2 |
3 | class DataSource {
4 | companion object{
5 | fun createEmployeeList() : MutableList {
6 | var list = mutableListOf()
7 | list.add(Employee("John","He is Android Developer",false))
8 | list.add(Employee("Sham","He is Android Developer",true))
9 | list.add(Employee("Pollock","He is iOS Developer",false))
10 | list.add(Employee("Ram","He is iOS Developer",true))
11 | list.add(Employee("Krish","He is Hybrid Developer",true))
12 | return list
13 | }
14 |
15 | fun createMaleUserList():MutableList{
16 | var list = mutableListOf()
17 | list.add(User("Chandra","Male"))
18 | list.add(User("Sai","Male"))
19 | list.add(User("Mohan","Male"))
20 | return list
21 |
22 | }
23 |
24 |
25 | fun createFeMaleUserList():MutableList{
26 | var list = mutableListOf()
27 | list.add(User("Rita","Female"))
28 | list.add(User("Geetha","Female"))
29 | list.add(User("Sitha","Female"))
30 | return list
31 |
32 | }
33 | }
34 | }
--------------------------------------------------------------------------------
/RxJavaPractice/src/main/java/com/rxjava/practice/Employee.kt:
--------------------------------------------------------------------------------
1 | package com.rxjava.practice
2 |
3 | data class Employee (val name : String, val description : String, val isFromIndia : Boolean)
--------------------------------------------------------------------------------
/RxJavaPractice/src/main/java/com/rxjava/practice/User.kt:
--------------------------------------------------------------------------------
1 | package com.rxjava.practice
2 |
3 | data class User(val name : String, val gender:String, var email:String = "",var address: Address?=null)
--------------------------------------------------------------------------------
/RxJavaPractice/src/main/res/layout/activity_rx_java_practice.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
20 |
21 |
30 |
--------------------------------------------------------------------------------
/RxJavaPractice/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/RxJavaPractice/src/test/java/com/rxjava/practice/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.rxjava.practice
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.3.61"
4 | ext.dagger2_version = '2.24'
5 | ext.rxJava_version = "2.2.19"
6 | ext.rxAndroid_version = "2.1.1"
7 | ext.retrofit_version = "2.6.1"
8 | ext.coroutine_version = "1.3.4"
9 | ext.roomVersion = '2.2.3'
10 | ext.nav_version = '2.3.0-alpha06'
11 | ext.okhttp_version = '4.7.2'
12 | ext.rxJava_binding_version = '4.0.0'
13 | repositories {
14 | google()
15 | jcenter()
16 | }
17 | dependencies {
18 | classpath "com.android.tools.build:gradle:4.1.0-alpha04"
19 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
20 | def nav_version = "2.3.0-alpha06"
21 | classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version"
22 |
23 |
24 |
25 | // NOTE: Do not place your application dependencies here; they belong
26 | // in the individual module build.gradle files
27 | }
28 | }
29 |
30 | allprojects {
31 | repositories {
32 | google()
33 | jcenter()
34 | /* flatDir {
35 | dirs 'libs/aars'
36 | }*/
37 | }
38 | }
39 |
40 | task clean(type: Delete) {
41 | delete rootProject.buildDir
42 | }
--------------------------------------------------------------------------------
/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
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
22 | manifestmerger.enabled=true
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chandragithub2014/MVVM_Kotlin/29dead56325654276055caa9e0e2cb62240a99f2/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sun Apr 19 01:52:06 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.3-rc-1-all.zip
7 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':RxJavaPractice'
2 | include ':MVVMCoroutineRetrofit'
3 | include ':utilslibrary-release'
4 | include ':MVVMCore'
5 | include ':MVVMCleanArchitecture'
6 | include ':utilslibrary-release'
7 | include ':utilslibrary-release'
8 | include ':utilslibrary-release'
9 | include ':KotlinPractice'
10 | include ':BottomSheet'
11 | include ':DaggerPractice'
12 | include ':MVVMNavigator'
13 | include ':MVVMDataBinding'
14 | include ':MVVMRxRetrofit'
15 | include ':RoomRepository'
16 | include ':MVVMLogin'
17 | include ':AppNavigator'
18 | include ':Common'
19 | include ':MVVMLauncher'
20 | include ':MVVMRoom'
21 | rootProject.name = "MVVM_Kotlin"
--------------------------------------------------------------------------------
/utilslibrary-release/build.gradle:
--------------------------------------------------------------------------------
1 | configurations.maybeCreate("default")
2 | artifacts.add("default", file('utilslibrary-release.aar'))
--------------------------------------------------------------------------------
/utilslibrary-release/utilslibrary-release.aar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chandragithub2014/MVVM_Kotlin/29dead56325654276055caa9e0e2cb62240a99f2/utilslibrary-release/utilslibrary-release.aar
--------------------------------------------------------------------------------