├── .idea ├── .name ├── .gitignore ├── compiler.xml ├── jarRepositories.xml └── misc.xml ├── app ├── .gitignore ├── extensions │ ├── .gitignore │ ├── consumer-rules.pro │ ├── .DS_Store │ ├── src │ │ ├── .DS_Store │ │ ├── main │ │ │ ├── .DS_Store │ │ │ ├── java │ │ │ │ ├── .DS_Store │ │ │ │ └── com │ │ │ │ │ ├── .DS_Store │ │ │ │ │ └── demo │ │ │ │ │ ├── .DS_Store │ │ │ │ │ └── extensions │ │ │ │ │ ├── activity │ │ │ │ │ └── ActivityExt.kt │ │ │ │ │ ├── fragment │ │ │ │ │ └── FragmentManagerExt.kt │ │ │ │ │ ├── toast │ │ │ │ │ └── ToastExt.kt │ │ │ │ │ ├── snackbar │ │ │ │ │ └── SnackbarExtensions.kt │ │ │ │ │ └── string │ │ │ │ │ └── StringExt.kt │ │ │ └── AndroidManifest.xml │ │ ├── test │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── demo │ │ │ │ └── extensions │ │ │ │ └── ExampleUnitTest.kt │ │ └── androidTest │ │ │ └── java │ │ │ └── com │ │ │ └── demo │ │ │ └── extensions │ │ │ └── ExampleInstrumentedTest.kt │ ├── proguard-rules.pro │ └── build.gradle ├── src │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── demo │ │ │ │ └── code │ │ │ │ ├── camerax │ │ │ │ ├── placeholder │ │ │ │ └── activities │ │ │ │ │ └── CameraxActivity.kt │ │ │ │ ├── paging │ │ │ │ ├── usingRemoteSource │ │ │ │ │ ├── placeholder │ │ │ │ │ ├── models │ │ │ │ │ │ ├── PostContainer.kt │ │ │ │ │ │ ├── PostsListing.kt │ │ │ │ │ │ ├── PostsApiResponse.kt │ │ │ │ │ │ ├── PostsKeys.kt │ │ │ │ │ │ └── FeedPost.kt │ │ │ │ │ ├── database │ │ │ │ │ │ ├── dao │ │ │ │ │ │ │ ├── KeysDao.kt │ │ │ │ │ │ │ └── PostsDao.kt │ │ │ │ │ │ └── LocalDatabase.kt │ │ │ │ │ ├── networking │ │ │ │ │ │ ├── RemoteService.kt │ │ │ │ │ │ └── ApiClient.kt │ │ │ │ │ ├── utils │ │ │ │ │ │ └── DiffUtilCallBack.kt │ │ │ │ │ ├── ui │ │ │ │ │ │ ├── RemoteApiViewModel.kt │ │ │ │ │ │ ├── RemoteApiAdapter.kt │ │ │ │ │ │ ├── PagingFromRemoteApiActivity.kt │ │ │ │ │ │ └── RemoteApiLoadingAdapter.kt │ │ │ │ │ └── repositories │ │ │ │ │ │ ├── Repository.kt │ │ │ │ │ │ ├── DataSource.kt │ │ │ │ │ │ └── DataMediator.kt │ │ │ │ ├── .DS_Store │ │ │ │ ├── usingLocalSource │ │ │ │ │ ├── model │ │ │ │ │ │ ├── MovieData.kt │ │ │ │ │ │ └── Movie.kt │ │ │ │ │ ├── Executors.kt │ │ │ │ │ ├── Extensions.kt │ │ │ │ │ ├── db │ │ │ │ │ │ ├── MovieDao.kt │ │ │ │ │ │ └── MovieDatabase.kt │ │ │ │ │ └── ui │ │ │ │ │ │ ├── MovieListViewModel.kt │ │ │ │ │ │ └── MovieListAdapter.kt │ │ │ │ ├── usingRemoteAndLocalSource │ │ │ │ │ ├── models │ │ │ │ │ │ ├── PostContainer.kt │ │ │ │ │ │ ├── PostsApiResponse.kt │ │ │ │ │ │ ├── PostsListing.kt │ │ │ │ │ │ ├── PostsKeys.kt │ │ │ │ │ │ └── FeedPost.kt │ │ │ │ │ ├── database │ │ │ │ │ │ ├── dao │ │ │ │ │ │ │ ├── KeysDao.kt │ │ │ │ │ │ │ └── PostsDao.kt │ │ │ │ │ │ └── LocalDatabase.kt │ │ │ │ │ ├── utils │ │ │ │ │ │ └── DiffUtilCallBack.kt │ │ │ │ │ ├── networking │ │ │ │ │ │ ├── RemoteService.kt │ │ │ │ │ │ └── ApiClient.kt │ │ │ │ │ ├── ui │ │ │ │ │ │ ├── LocalRemoteApiViewModel.kt │ │ │ │ │ │ ├── RemoteApiAdapter.kt │ │ │ │ │ │ ├── LocalRemoteApiLoadingAdapter.kt │ │ │ │ │ │ └── PagingFromLocalRemoteApiActivity.kt │ │ │ │ │ └── repositories │ │ │ │ │ │ ├── Repository.kt │ │ │ │ │ │ └── DataMediator.kt │ │ │ │ └── Paging3Activity.kt │ │ │ │ ├── utils │ │ │ │ ├── placeholder.kt │ │ │ │ └── Constants.kt │ │ │ │ ├── .DS_Store │ │ │ │ ├── base │ │ │ │ ├── BaseFragment.kt │ │ │ │ └── BaseActivity.kt │ │ │ │ ├── liveData │ │ │ │ ├── selection │ │ │ │ │ ├── vm │ │ │ │ │ │ └── SelectionLiveDataViewModel.kt │ │ │ │ │ └── fragments │ │ │ │ │ │ └── SelectionLiveDataFragment.kt │ │ │ │ ├── activity │ │ │ │ │ └── LiveDataActivity.kt │ │ │ │ ├── mutableLiveData │ │ │ │ │ ├── vm │ │ │ │ │ │ └── MutableLiveDataViewModel.kt │ │ │ │ │ └── fragments │ │ │ │ │ │ └── MutableLiveDataFragment.kt │ │ │ │ └── mediatorLiveData │ │ │ │ │ ├── vm │ │ │ │ │ └── MediatorLiveDataViewModel.kt │ │ │ │ │ └── fragments │ │ │ │ │ └── MediatorLiveDataFragment.kt │ │ │ │ ├── lifecycle │ │ │ │ ├── actions │ │ │ │ │ └── ExoplayerAction.kt │ │ │ │ └── activities │ │ │ │ │ └── ExoplayerActivity.kt │ │ │ │ ├── navigation │ │ │ │ ├── activities │ │ │ │ │ ├── TwoFragmentContainerActivity.kt │ │ │ │ │ ├── BottomNavigationActivity.kt │ │ │ │ │ └── SelectionScreenActivity.kt │ │ │ │ └── fragments │ │ │ │ │ ├── FragmentA.kt │ │ │ │ │ ├── FragmentB.kt │ │ │ │ │ ├── FragmentD.kt │ │ │ │ │ ├── FragmentE.kt │ │ │ │ │ ├── FragmentC.kt │ │ │ │ │ └── FragmentF.kt │ │ │ │ ├── dataStore │ │ │ │ ├── activities │ │ │ │ │ └── DataStoreActivity.kt │ │ │ │ ├── fragments │ │ │ │ │ ├── protoDataStore │ │ │ │ │ │ └── ProtoDataStoreFragment.kt │ │ │ │ │ ├── SelectionDataStoreFragment.kt │ │ │ │ │ └── preferenceDataStore │ │ │ │ │ │ └── PreferenceDataStoreFragment.kt │ │ │ │ └── util │ │ │ │ │ └── DataManager.kt │ │ │ │ ├── workmanager │ │ │ │ ├── exampleone │ │ │ │ │ └── workers │ │ │ │ │ │ ├── CleanFilesWorker.kt │ │ │ │ │ │ ├── UploadWorker.kt │ │ │ │ │ │ ├── CompressWorker.kt │ │ │ │ │ │ └── FilterWorker.kt │ │ │ │ ├── chainingworker │ │ │ │ │ └── workers │ │ │ │ │ │ ├── FileClearWorker.kt │ │ │ │ │ │ └── DownloadWorker.kt │ │ │ │ ├── WorkManagerActivity.kt │ │ │ │ └── simpleworker │ │ │ │ │ ├── workers │ │ │ │ │ └── SimpleDownloadWorker.kt │ │ │ │ │ └── SimpleWorkerActivity.kt │ │ │ │ └── JetPackFeatureSelectionActivity.kt │ │ ├── .DS_Store │ │ └── res │ │ │ ├── .DS_Store │ │ │ ├── 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 │ │ │ ├── mipmap-anydpi-v26 │ │ │ ├── ic_launcher.xml │ │ │ └── ic_launcher_round.xml │ │ │ ├── drawable │ │ │ ├── side_nav_bar.xml │ │ │ ├── ic_flash_on_black_48dp.xml │ │ │ ├── ic_vertical_align_top_white_24px.xml │ │ │ ├── ic_vertical_align_bottom_white_24px.xml │ │ │ ├── ic_home.xml │ │ │ ├── ic_comment.xml │ │ │ ├── ic_menu_slideshow.xml │ │ │ ├── ic_menu_gallery.xml │ │ │ ├── ic_star.xml │ │ │ ├── ic_menu_camera.xml │ │ │ └── ic_launcher_foreground.xml │ │ │ ├── menu │ │ │ ├── main.xml │ │ │ ├── menu.xml │ │ │ ├── activity_main_drawer.xml │ │ │ └── bottom_menu_nav.xml │ │ │ ├── drawable-v24 │ │ │ ├── ic_flash_off_black_48dp.xml │ │ │ ├── ic_camera_rear_black_48dp.xml │ │ │ ├── ic_camera_front_black_24dp.xml │ │ │ ├── ic_camera_black_48dp.xml │ │ │ └── ic_launcher_foreground.xml │ │ │ ├── values │ │ │ ├── colors.xml │ │ │ ├── styles.xml │ │ │ ├── dimens.xml │ │ │ └── themes.xml │ │ │ ├── layout │ │ │ ├── activity_chain_worker.xml │ │ │ ├── activity_simple_worker.xml │ │ │ ├── horizontal_paging_fragment.xml │ │ │ ├── fragment_proto_data_store.xml │ │ │ ├── selection_paging_fragment.xml │ │ │ ├── activity_paging_from_remote_api.xml │ │ │ ├── activity_paging_from_local_remote_api.xml │ │ │ ├── activity_paging_from_local_db.xml │ │ │ ├── fragment_selection_data_store.xml │ │ │ ├── selection_live_data_fragment.xml │ │ │ ├── content_main.xml │ │ │ ├── activity_navigation_drawer.xml │ │ │ ├── activity_data_store.xml │ │ │ ├── activity_live_data_layout.xml │ │ │ ├── activity_paging.xml │ │ │ ├── fragment_layout_a.xml │ │ │ ├── fragment_layout_b.xml │ │ │ ├── fragment_layout_c.xml │ │ │ ├── fragment_layout_d.xml │ │ │ ├── activity_selection.xml │ │ │ ├── fragment_layout_e.xml │ │ │ ├── fragment_layout_f.xml │ │ │ ├── activity_bottom_navigation.xml │ │ │ ├── activity_player.xml │ │ │ ├── activity_work_manager.xml │ │ │ ├── app_bar_main.xml │ │ │ ├── mutable_live_data_fragment.xml │ │ │ ├── nav_header_main.xml │ │ │ ├── list_item_movie.xml │ │ │ ├── activity_jetpack_selection.xml │ │ │ ├── list_item.xml │ │ │ ├── item_loading_state.xml │ │ │ ├── activity_two_frag_containers.xml │ │ │ ├── adapter_row.xml │ │ │ ├── activity_camera_x.xml │ │ │ ├── mediator_live_data_fragment.xml │ │ │ └── activity_work_manager_example_one.xml │ │ │ ├── values-night │ │ │ └── themes.xml │ │ │ └── navigation │ │ │ ├── nav_graph_a.xml │ │ │ ├── paging_nav.xml │ │ │ ├── live_data_nav.xml │ │ │ ├── data_store_nav.xml │ │ │ ├── nav_graph_b.xml │ │ │ ├── nav_graph_drawer.xml │ │ │ └── nav_graph_bottom_navigation.xml │ ├── .DS_Store │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── demo │ │ │ └── code │ │ │ └── ExampleUnitTest.kt │ └── androidTest │ │ └── java │ │ └── com │ │ └── demo │ │ └── code │ │ └── ExampleInstrumentedTest.kt ├── .DS_Store └── proguard-rules.pro ├── .DS_Store ├── .gitattributes ├── settings.gradle ├── images ├── .DS_Store ├── paging.png ├── Logo-new.png ├── alltools.png ├── assistant.png ├── camerax.png ├── liveData.jpeg ├── datastore.jpeg ├── page_struct.png ├── mobile_server.png ├── pagingBanner.jpeg ├── prefdatastore.jpeg ├── proposed_arch.png ├── recyclerview.jpeg ├── android-jetpack.png ├── mediator_paging.png ├── navigationgraph.png ├── paging_elements.png ├── protodatastore.jpeg ├── data_source_types.png ├── jetpacknavigation.png ├── local_remote_paging.png ├── supporting_caching.png ├── types_of_work_manager.png └── android_jetpack_lifecycle.jpeg ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradle.properties ├── .gitignore ├── README.md └── gradlew.bat /.idea/.name: -------------------------------------------------------------------------------- 1 | code -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /app/extensions/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /app/extensions/consumer-rules.pro: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/src/main/java/com/demo/code/camerax/placeholder: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/src/main/java/com/demo/code/paging/usingRemoteSource/placeholder: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devrath/DroidAndroidJetpack/HEAD/.DS_Store -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /app/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devrath/DroidAndroidJetpack/HEAD/app/.DS_Store -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app:extensions' 2 | include ':app' 3 | rootProject.name = "code" -------------------------------------------------------------------------------- /app/src/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devrath/DroidAndroidJetpack/HEAD/app/src/.DS_Store -------------------------------------------------------------------------------- /images/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devrath/DroidAndroidJetpack/HEAD/images/.DS_Store -------------------------------------------------------------------------------- /images/paging.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devrath/DroidAndroidJetpack/HEAD/images/paging.png -------------------------------------------------------------------------------- /images/Logo-new.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devrath/DroidAndroidJetpack/HEAD/images/Logo-new.png -------------------------------------------------------------------------------- /images/alltools.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devrath/DroidAndroidJetpack/HEAD/images/alltools.png -------------------------------------------------------------------------------- /images/assistant.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devrath/DroidAndroidJetpack/HEAD/images/assistant.png -------------------------------------------------------------------------------- /images/camerax.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devrath/DroidAndroidJetpack/HEAD/images/camerax.png -------------------------------------------------------------------------------- /images/liveData.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devrath/DroidAndroidJetpack/HEAD/images/liveData.jpeg -------------------------------------------------------------------------------- /app/src/main/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devrath/DroidAndroidJetpack/HEAD/app/src/main/.DS_Store -------------------------------------------------------------------------------- /images/datastore.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devrath/DroidAndroidJetpack/HEAD/images/datastore.jpeg -------------------------------------------------------------------------------- /images/page_struct.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devrath/DroidAndroidJetpack/HEAD/images/page_struct.png -------------------------------------------------------------------------------- /app/extensions/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devrath/DroidAndroidJetpack/HEAD/app/extensions/.DS_Store -------------------------------------------------------------------------------- /images/mobile_server.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devrath/DroidAndroidJetpack/HEAD/images/mobile_server.png -------------------------------------------------------------------------------- /images/pagingBanner.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devrath/DroidAndroidJetpack/HEAD/images/pagingBanner.jpeg -------------------------------------------------------------------------------- /images/prefdatastore.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devrath/DroidAndroidJetpack/HEAD/images/prefdatastore.jpeg -------------------------------------------------------------------------------- /images/proposed_arch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devrath/DroidAndroidJetpack/HEAD/images/proposed_arch.png -------------------------------------------------------------------------------- /images/recyclerview.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devrath/DroidAndroidJetpack/HEAD/images/recyclerview.jpeg -------------------------------------------------------------------------------- /app/src/main/java/com/demo/code/utils/placeholder.kt: -------------------------------------------------------------------------------- 1 | package com.demo.code.utils 2 | 3 | class placeholder { 4 | } -------------------------------------------------------------------------------- /app/src/main/res/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devrath/DroidAndroidJetpack/HEAD/app/src/main/res/.DS_Store -------------------------------------------------------------------------------- /images/android-jetpack.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devrath/DroidAndroidJetpack/HEAD/images/android-jetpack.png -------------------------------------------------------------------------------- /images/mediator_paging.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devrath/DroidAndroidJetpack/HEAD/images/mediator_paging.png -------------------------------------------------------------------------------- /images/navigationgraph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devrath/DroidAndroidJetpack/HEAD/images/navigationgraph.png -------------------------------------------------------------------------------- /images/paging_elements.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devrath/DroidAndroidJetpack/HEAD/images/paging_elements.png -------------------------------------------------------------------------------- /images/protodatastore.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devrath/DroidAndroidJetpack/HEAD/images/protodatastore.jpeg -------------------------------------------------------------------------------- /app/extensions/src/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devrath/DroidAndroidJetpack/HEAD/app/extensions/src/.DS_Store -------------------------------------------------------------------------------- /images/data_source_types.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devrath/DroidAndroidJetpack/HEAD/images/data_source_types.png -------------------------------------------------------------------------------- /images/jetpacknavigation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devrath/DroidAndroidJetpack/HEAD/images/jetpacknavigation.png -------------------------------------------------------------------------------- /images/local_remote_paging.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devrath/DroidAndroidJetpack/HEAD/images/local_remote_paging.png -------------------------------------------------------------------------------- /images/supporting_caching.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devrath/DroidAndroidJetpack/HEAD/images/supporting_caching.png -------------------------------------------------------------------------------- /images/types_of_work_manager.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devrath/DroidAndroidJetpack/HEAD/images/types_of_work_manager.png -------------------------------------------------------------------------------- /app/extensions/src/main/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devrath/DroidAndroidJetpack/HEAD/app/extensions/src/main/.DS_Store -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devrath/DroidAndroidJetpack/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /images/android_jetpack_lifecycle.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devrath/DroidAndroidJetpack/HEAD/images/android_jetpack_lifecycle.jpeg -------------------------------------------------------------------------------- /app/extensions/src/main/java/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devrath/DroidAndroidJetpack/HEAD/app/extensions/src/main/java/.DS_Store -------------------------------------------------------------------------------- /app/extensions/src/main/java/com/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devrath/DroidAndroidJetpack/HEAD/app/extensions/src/main/java/com/.DS_Store -------------------------------------------------------------------------------- /app/src/main/java/com/demo/code/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devrath/DroidAndroidJetpack/HEAD/app/src/main/java/com/demo/code/.DS_Store -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devrath/DroidAndroidJetpack/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devrath/DroidAndroidJetpack/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devrath/DroidAndroidJetpack/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/extensions/src/main/java/com/demo/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devrath/DroidAndroidJetpack/HEAD/app/extensions/src/main/java/com/demo/.DS_Store -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devrath/DroidAndroidJetpack/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devrath/DroidAndroidJetpack/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/java/com/demo/code/paging/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devrath/DroidAndroidJetpack/HEAD/app/src/main/java/com/demo/code/paging/.DS_Store -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devrath/DroidAndroidJetpack/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devrath/DroidAndroidJetpack/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devrath/DroidAndroidJetpack/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devrath/DroidAndroidJetpack/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devrath/DroidAndroidJetpack/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/java/com/demo/code/paging/usingRemoteSource/models/PostContainer.kt: -------------------------------------------------------------------------------- 1 | package com.demo.code.paging.usingRemoteSource.models 2 | 3 | class PostContainer(val data: FeedPost) -------------------------------------------------------------------------------- /app/src/main/java/com/demo/code/paging/usingLocalSource/model/MovieData.kt: -------------------------------------------------------------------------------- 1 | package com.demo.code.paging.usingLocalSource.model 2 | 3 | 4 | data class MovieData(var movies: List) -------------------------------------------------------------------------------- /app/src/main/java/com/demo/code/base/BaseFragment.kt: -------------------------------------------------------------------------------- 1 | package com.demo.code.base 2 | 3 | import androidx.fragment.app.Fragment 4 | 5 | open class BaseFragment : Fragment() { 6 | 7 | 8 | } -------------------------------------------------------------------------------- /app/src/main/java/com/demo/code/base/BaseActivity.kt: -------------------------------------------------------------------------------- 1 | package com.demo.code.base 2 | 3 | import androidx.appcompat.app.AppCompatActivity 4 | 5 | open class BaseActivity : AppCompatActivity() { 6 | } -------------------------------------------------------------------------------- /app/extensions/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/java/com/demo/code/paging/usingRemoteSource/models/PostsListing.kt: -------------------------------------------------------------------------------- 1 | package com.demo.code.paging.usingRemoteSource.models 2 | 3 | class PostsListing(val children: List, val after: String?, val before: String?) -------------------------------------------------------------------------------- /app/src/main/java/com/demo/code/utils/Constants.kt: -------------------------------------------------------------------------------- 1 | package com.demo.flow.utils 2 | 3 | object Constants { 4 | var APP_URL = "https://5e510330f2c0d300147c034c.mockapi.io/" 5 | var GENERIC_ERROR_MESSAGE = "Something went wrong" 6 | } -------------------------------------------------------------------------------- /app/src/main/java/com/demo/code/paging/usingRemoteAndLocalSource/models/PostContainer.kt: -------------------------------------------------------------------------------- 1 | package com.demo.code.paging.usingRemoteAndLocalSource.models 2 | 3 | import com.demo.code.paging.usingRemoteSource.models.FeedPost 4 | 5 | class PostContainer(val data: FeedPost) -------------------------------------------------------------------------------- /app/src/main/java/com/demo/code/paging/usingRemoteSource/models/PostsApiResponse.kt: -------------------------------------------------------------------------------- 1 | package com.demo.code.paging.usingRemoteSource.models 2 | 3 | import com.demo.code.paging.usingRemoteSource.models.PostsListing 4 | 5 | 6 | class PostsApiResponse(val data: PostsListing) -------------------------------------------------------------------------------- /app/src/main/java/com/demo/code/liveData/selection/vm/SelectionLiveDataViewModel.kt: -------------------------------------------------------------------------------- 1 | package com.demo.code.liveData.selection.vm 2 | 3 | import androidx.lifecycle.ViewModel 4 | 5 | class SelectionLiveDataViewModel : ViewModel() { 6 | // TODO: Implement the ViewModel 7 | } -------------------------------------------------------------------------------- /app/src/main/java/com/demo/code/paging/usingRemoteAndLocalSource/models/PostsApiResponse.kt: -------------------------------------------------------------------------------- 1 | package com.demo.code.paging.usingRemoteAndLocalSource.models 2 | 3 | import com.demo.code.paging.usingRemoteSource.models.PostsListing 4 | 5 | 6 | class PostsApiResponse(val data: PostsListing) -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Mar 12 19:31:49 IST 2021 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip 7 | -------------------------------------------------------------------------------- /app/src/main/java/com/demo/code/paging/usingLocalSource/Executors.kt: -------------------------------------------------------------------------------- 1 | package com.demo.code.paging.usingLocalSource 2 | 3 | import java.util.concurrent.Executors 4 | 5 | private val BG_EXECUTOR = Executors.newSingleThreadExecutor() 6 | 7 | fun bgThread(f : () -> Unit) { 8 | BG_EXECUTOR.execute(f) 9 | } -------------------------------------------------------------------------------- /app/src/main/java/com/demo/code/paging/usingRemoteAndLocalSource/models/PostsListing.kt: -------------------------------------------------------------------------------- 1 | package com.demo.code.paging.usingRemoteAndLocalSource.models 2 | 3 | import com.demo.code.paging.usingRemoteSource.models.PostContainer 4 | 5 | class PostsListing(val children: List, val after: String?, val before: String?) -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/side_nav_bar.xml: -------------------------------------------------------------------------------- 1 | 3 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_flash_on_black_48dp.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/menu/main.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 9 | -------------------------------------------------------------------------------- /app/src/main/java/com/demo/code/paging/usingRemoteSource/models/PostsKeys.kt: -------------------------------------------------------------------------------- 1 | package com.demo.code.paging.usingRemoteSource.models 2 | 3 | import androidx.room.Entity 4 | import androidx.room.PrimaryKey 5 | 6 | @Entity(tableName = "postKeys") 7 | data class PostsKeys( 8 | @PrimaryKey(autoGenerate = true) 9 | val id: Int, 10 | val after: String?, 11 | val before: String? 12 | ) 13 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_vertical_align_top_white_24px.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_vertical_align_bottom_white_24px.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/java/com/demo/code/paging/usingRemoteAndLocalSource/models/PostsKeys.kt: -------------------------------------------------------------------------------- 1 | package com.demo.code.paging.usingRemoteAndLocalSource.models 2 | 3 | import androidx.room.Entity 4 | import androidx.room.PrimaryKey 5 | 6 | @Entity(tableName = "postKeys") 7 | data class PostsKeys( 8 | @PrimaryKey(autoGenerate = true) 9 | val id: Int, 10 | val after: String?, 11 | val before: String? 12 | ) 13 | -------------------------------------------------------------------------------- /app/src/main/java/com/demo/code/lifecycle/actions/ExoplayerAction.kt: -------------------------------------------------------------------------------- 1 | package com.demo.code.lifecycle.actions 2 | 3 | import android.net.Uri 4 | import com.google.android.exoplayer2.SimpleExoPlayer 5 | 6 | sealed class ExoplayerAction { 7 | data class BindExoplayer(val simpleExoplayer: SimpleExoPlayer) : ExoplayerAction() 8 | data class ProgressBarVisibility(val isVisible: Boolean) : ExoplayerAction() 9 | } 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_home.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_flash_off_black_48dp.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/extensions/src/main/java/com/demo/extensions/activity/ActivityExt.kt: -------------------------------------------------------------------------------- 1 | package com.demo.extensions.activity 2 | 3 | import android.app.Activity 4 | import android.util.DisplayMetrics 5 | 6 | 7 | 8 | 9 | 10 | fun Activity.isInPortrait(): Boolean { 11 | val displayMetrics = DisplayMetrics() 12 | windowManager.defaultDisplay.getMetrics(displayMetrics) 13 | return displayMetrics.heightPixels > displayMetrics.widthPixels 14 | } -------------------------------------------------------------------------------- /app/src/main/java/com/demo/code/paging/usingLocalSource/Extensions.kt: -------------------------------------------------------------------------------- 1 | package com.demo.code.paging.usingLocalSource 2 | 3 | import android.view.LayoutInflater 4 | import android.view.View 5 | import android.view.ViewGroup 6 | import androidx.annotation.LayoutRes 7 | 8 | fun ViewGroup.inflate(@LayoutRes layoutRes: Int, attachToRoot: Boolean = false): View { 9 | return LayoutInflater.from(context).inflate(layoutRes, this, attachToRoot) 10 | } -------------------------------------------------------------------------------- /app/src/test/java/com/demo/code/ExampleUnitTest.kt: -------------------------------------------------------------------------------- 1 | package com.demo.code 2 | 3 | import org.junit.Test 4 | 5 | import org.junit.Assert.* 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * See [testing documentation](http://d.android.com/tools/testing). 11 | */ 12 | class ExampleUnitTest { 13 | @Test 14 | fun addition_isCorrect() { 15 | assertEquals(4, 2 + 2) 16 | } 17 | } -------------------------------------------------------------------------------- /app/extensions/src/test/java/com/demo/extensions/ExampleUnitTest.kt: -------------------------------------------------------------------------------- 1 | package com.demo.extensions 2 | 3 | import org.junit.Test 4 | 5 | import org.junit.Assert.* 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * See [testing documentation](http://d.android.com/tools/testing). 11 | */ 12 | class ExampleUnitTest { 13 | @Test 14 | fun addition_isCorrect() { 15 | assertEquals(4, 2 + 2) 16 | } 17 | } -------------------------------------------------------------------------------- /app/src/main/java/com/demo/code/navigation/activities/TwoFragmentContainerActivity.kt: -------------------------------------------------------------------------------- 1 | package com.demo.code.navigation.activities 2 | 3 | import android.os.Bundle 4 | import com.demo.code.R 5 | import com.demo.code.base.BaseActivity 6 | 7 | class TwoFragmentContainerActivity : BaseActivity() { 8 | override fun onCreate(savedInstanceState: Bundle?) { 9 | super.onCreate(savedInstanceState) 10 | setContentView(R.layout.activity_two_frag_containers) 11 | } 12 | } -------------------------------------------------------------------------------- /app/src/main/java/com/demo/code/paging/usingLocalSource/model/Movie.kt: -------------------------------------------------------------------------------- 1 | package com.demo.code.paging.usingLocalSource.model 2 | import androidx.room.Entity 3 | import androidx.room.PrimaryKey 4 | import com.google.gson.annotations.SerializedName 5 | 6 | @Entity 7 | data class Movie( 8 | @PrimaryKey(autoGenerate = true) val id: Int, 9 | val title: String, 10 | val rating: Double, 11 | @SerializedName("release_date") val releaseDate: String, 12 | val ranking: Int) -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_comment.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #FFBB86FC 4 | #FF6200EE 5 | #FF3700B3 6 | #FF03DAC5 7 | #FF018786 8 | #FF000000 9 | #FFFFFFFF 10 | #E3E2DF 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_menu_slideshow.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_menu_gallery.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_star.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_camera_rear_black_48dp.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_chain_worker.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_simple_worker.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_camera_front_black_24dp.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/java/com/demo/code/camerax/activities/CameraxActivity.kt: -------------------------------------------------------------------------------- 1 | package com.demo.code.camerax.activities 2 | 3 | import android.os.Bundle 4 | import com.demo.code.base.BaseActivity 5 | import com.demo.code.databinding.ActivityCameraXBinding 6 | 7 | class CameraxActivity: BaseActivity() { 8 | 9 | private lateinit var binding: ActivityCameraXBinding 10 | 11 | 12 | override fun onCreate(savedInstanceState: Bundle?) { 13 | super.onCreate(savedInstanceState) 14 | binding = ActivityCameraXBinding.inflate(layoutInflater) 15 | setContentView(binding.root) 16 | } 17 | 18 | 19 | } -------------------------------------------------------------------------------- /app/src/main/java/com/demo/code/paging/usingRemoteSource/database/dao/KeysDao.kt: -------------------------------------------------------------------------------- 1 | package com.demo.code.paging.usingRemoteSource.database.dao 2 | 3 | import androidx.room.Dao 4 | import androidx.room.Insert 5 | import androidx.room.OnConflictStrategy.REPLACE 6 | import androidx.room.Query 7 | import com.demo.code.paging.usingRemoteSource.models.PostsKeys 8 | 9 | @Dao 10 | interface KeysDao { 11 | 12 | @Insert(onConflict = REPLACE) 13 | suspend fun savePostsKeys(postsKey: PostsKeys) 14 | 15 | @Query("SELECT * FROM postKeys ORDER BY id DESC") 16 | suspend fun getPostsKeys(): List 17 | 18 | } -------------------------------------------------------------------------------- /app/src/main/java/com/demo/code/dataStore/activities/DataStoreActivity.kt: -------------------------------------------------------------------------------- 1 | package com.demo.code.dataStore.activities 2 | 3 | import android.os.Bundle 4 | import com.demo.code.base.BaseActivity 5 | import com.demo.code.databinding.ActivityDataStoreBinding 6 | 7 | class DataStoreActivity : BaseActivity() { 8 | 9 | private lateinit var binding: ActivityDataStoreBinding 10 | 11 | override fun onCreate(savedInstanceState: Bundle?) { 12 | super.onCreate(savedInstanceState) 13 | binding = ActivityDataStoreBinding.inflate(layoutInflater) 14 | setContentView(binding.root) 15 | } 16 | 17 | 18 | } -------------------------------------------------------------------------------- /app/src/main/res/layout/horizontal_paging_fragment.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /app/src/main/java/com/demo/code/liveData/activity/LiveDataActivity.kt: -------------------------------------------------------------------------------- 1 | package com.demo.code.liveData.activity 2 | 3 | import android.os.Bundle 4 | import com.demo.code.base.BaseActivity 5 | import com.demo.code.databinding.ActivityLiveDataLayoutBinding 6 | 7 | class LiveDataActivity : BaseActivity() { 8 | 9 | private lateinit var binding: ActivityLiveDataLayoutBinding 10 | 11 | override fun onCreate(savedInstanceState: Bundle?) { 12 | super.onCreate(savedInstanceState) 13 | binding = ActivityLiveDataLayoutBinding.inflate(layoutInflater) 14 | setContentView(binding.root) 15 | } 16 | 17 | } -------------------------------------------------------------------------------- /app/src/main/java/com/demo/code/paging/usingRemoteAndLocalSource/database/dao/KeysDao.kt: -------------------------------------------------------------------------------- 1 | package com.demo.code.paging.usingRemoteAndLocalSource.database.dao 2 | 3 | import androidx.room.Dao 4 | import androidx.room.Insert 5 | import androidx.room.OnConflictStrategy.REPLACE 6 | import androidx.room.Query 7 | import com.demo.code.paging.usingRemoteSource.models.PostsKeys 8 | 9 | @Dao 10 | interface KeysDao { 11 | 12 | @Insert(onConflict = REPLACE) 13 | suspend fun savePostsKeys(postsKey: PostsKeys) 14 | 15 | @Query("SELECT * FROM postKeys ORDER BY id DESC") 16 | suspend fun getPostsKeys(): List 17 | 18 | } -------------------------------------------------------------------------------- /app/src/main/java/com/demo/code/paging/usingRemoteSource/database/dao/PostsDao.kt: -------------------------------------------------------------------------------- 1 | package com.demo.code.paging.usingRemoteSource.database.dao 2 | 3 | import androidx.paging.PagingSource 4 | import androidx.room.Dao 5 | import androidx.room.Insert 6 | import androidx.room.OnConflictStrategy.REPLACE 7 | import androidx.room.Query 8 | import com.demo.code.paging.usingRemoteSource.models.FeedPost 9 | 10 | @Dao 11 | interface PostsDao { 12 | 13 | @Insert(onConflict = REPLACE) 14 | suspend fun savePosts(feedPosts: List) 15 | 16 | @Query("SELECT * FROM feedPosts") 17 | fun getPosts(): PagingSource 18 | 19 | } -------------------------------------------------------------------------------- /app/src/main/res/menu/menu.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 10 | 11 | 16 | 17 | -------------------------------------------------------------------------------- /app/src/main/java/com/demo/code/paging/usingRemoteAndLocalSource/database/dao/PostsDao.kt: -------------------------------------------------------------------------------- 1 | package com.demo.code.paging.usingRemoteAndLocalSource.database.dao 2 | 3 | import androidx.paging.PagingSource 4 | import androidx.room.Dao 5 | import androidx.room.Insert 6 | import androidx.room.OnConflictStrategy.REPLACE 7 | import androidx.room.Query 8 | import com.demo.code.paging.usingRemoteSource.models.FeedPost 9 | 10 | @Dao 11 | interface PostsDao { 12 | 13 | @Insert(onConflict = REPLACE) 14 | suspend fun savePosts(feedPosts: List) 15 | 16 | @Query("SELECT * FROM feedPosts") 17 | fun getPosts(): PagingSource 18 | 19 | } -------------------------------------------------------------------------------- /app/src/main/java/com/demo/code/paging/usingRemoteSource/models/FeedPost.kt: -------------------------------------------------------------------------------- 1 | package com.demo.code.paging.usingRemoteSource.models 2 | 3 | import androidx.room.Entity 4 | import androidx.room.PrimaryKey 5 | import com.google.gson.annotations.SerializedName 6 | 7 | @Entity(tableName = "feedPosts") 8 | data class FeedPost( 9 | @SerializedName("name") 10 | @PrimaryKey 11 | val key: String, 12 | @SerializedName("title") 13 | val title: String, 14 | @SerializedName("score") 15 | val score: Int, 16 | @SerializedName("author") 17 | val author: String, 18 | @SerializedName("num_comments") 19 | val commentCount: Int 20 | ) 21 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_menu_camera.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 12 | 13 | -------------------------------------------------------------------------------- /app/src/main/java/com/demo/code/paging/usingRemoteAndLocalSource/models/FeedPost.kt: -------------------------------------------------------------------------------- 1 | package com.demo.code.paging.usingRemoteAndLocalSource.models 2 | 3 | import androidx.room.Entity 4 | import androidx.room.PrimaryKey 5 | import com.google.gson.annotations.SerializedName 6 | 7 | @Entity(tableName = "feedPosts") 8 | data class FeedPost( 9 | @SerializedName("name") 10 | @PrimaryKey 11 | val key: String, 12 | @SerializedName("title") 13 | val title: String, 14 | @SerializedName("score") 15 | val score: Int, 16 | @SerializedName("author") 17 | val author: String, 18 | @SerializedName("num_comments") 19 | val commentCount: Int 20 | ) 21 | -------------------------------------------------------------------------------- /app/extensions/src/main/java/com/demo/extensions/fragment/FragmentManagerExt.kt: -------------------------------------------------------------------------------- 1 | package com.demo.extensions.fragment 2 | 3 | import androidx.fragment.app.FragmentManager 4 | import androidx.fragment.app.FragmentTransaction 5 | 6 | inline fun FragmentManager.inTransactionCommit(func: FragmentTransaction.() -> Unit) { 7 | val fragmentTransaction = beginTransaction() 8 | fragmentTransaction.func() 9 | fragmentTransaction.commit() 10 | } 11 | 12 | inline fun FragmentManager.inTransactionCommitAllowingStateLoss(func: FragmentTransaction.() -> Unit) { 13 | val fragmentTransaction = beginTransaction() 14 | fragmentTransaction.func() 15 | fragmentTransaction.commitAllowingStateLoss() 16 | } -------------------------------------------------------------------------------- /app/extensions/src/main/java/com/demo/extensions/toast/ToastExt.kt: -------------------------------------------------------------------------------- 1 | package com.demo.extensions.toast 2 | 3 | import android.annotation.SuppressLint 4 | import android.content.Context 5 | import android.widget.Toast 6 | 7 | private var toast: Toast? = null 8 | 9 | @SuppressLint("ShowToast") 10 | fun toast(msg: Any?, isShort: Boolean = true, context : Context) { 11 | msg?.let { 12 | if (toast == null) { 13 | toast = Toast.makeText(context, msg.toString(), Toast.LENGTH_SHORT) 14 | } else { 15 | toast!!.setText(msg.toString()) 16 | } 17 | toast!!.duration = if (isShort) Toast.LENGTH_SHORT else Toast.LENGTH_LONG 18 | toast!!.show() 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /app/src/main/java/com/demo/code/paging/usingRemoteSource/networking/RemoteService.kt: -------------------------------------------------------------------------------- 1 | package com.demo.code.paging.usingRemoteSource.networking 2 | 3 | import com.demo.code.paging.usingRemoteSource.models.PostsApiResponse 4 | import retrofit2.Response 5 | import retrofit2.http.GET 6 | import retrofit2.http.Query 7 | 8 | interface RemoteService { 9 | 10 | companion object { 11 | val service = RemoteService::class.java 12 | } 13 | 14 | @GET("/r/aww/hot.json") 15 | suspend fun fetchPosts( 16 | @Query("limit") loadSize: Int = 0, 17 | @Query("after") after: String? = null, 18 | @Query("before") before: String? = null 19 | ): Response 20 | 21 | 22 | } -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | 15 | -------------------------------------------------------------------------------- /app/src/main/java/com/demo/code/paging/usingRemoteSource/utils/DiffUtilCallBack.kt: -------------------------------------------------------------------------------- 1 | package com.demo.code.paging.usingRemoteSource.utils 2 | 3 | import androidx.recyclerview.widget.DiffUtil 4 | import com.demo.code.paging.usingRemoteSource.models.FeedPost 5 | 6 | class DiffUtilCallBack : DiffUtil.ItemCallback() { 7 | override fun areItemsTheSame(oldItem: FeedPost, newItem: FeedPost): Boolean { 8 | return oldItem.key == newItem.key 9 | } 10 | 11 | override fun areContentsTheSame(oldItem: FeedPost, newItem: FeedPost): Boolean { 12 | return oldItem.key == newItem.key 13 | && oldItem.score == newItem.score 14 | && oldItem.commentCount == newItem.commentCount 15 | } 16 | } -------------------------------------------------------------------------------- /app/src/main/java/com/demo/code/paging/usingRemoteAndLocalSource/utils/DiffUtilCallBack.kt: -------------------------------------------------------------------------------- 1 | package com.demo.code.paging.usingRemoteAndLocalSource.utils 2 | 3 | import androidx.recyclerview.widget.DiffUtil 4 | import com.demo.code.paging.usingRemoteSource.models.FeedPost 5 | 6 | class DiffUtilCallBack : DiffUtil.ItemCallback() { 7 | override fun areItemsTheSame(oldItem: FeedPost, newItem: FeedPost): Boolean { 8 | return oldItem.key == newItem.key 9 | } 10 | 11 | override fun areContentsTheSame(oldItem: FeedPost, newItem: FeedPost): Boolean { 12 | return oldItem.key == newItem.key 13 | && oldItem.score == newItem.score 14 | && oldItem.commentCount == newItem.commentCount 15 | } 16 | } -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_proto_data_store.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 14 | 15 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_camera_black_48dp.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/java/com/demo/code/paging/usingRemoteSource/networking/ApiClient.kt: -------------------------------------------------------------------------------- 1 | package com.demo.code.paging.usingRemoteSource.networking 2 | 3 | import retrofit2.Retrofit 4 | import retrofit2.converter.gson.GsonConverterFactory 5 | 6 | class ApiClient { 7 | 8 | companion object { 9 | 10 | private const val BASE_URL = "https://www.reddit.com/" 11 | private var retrofit: Retrofit? = null 12 | 13 | fun getClient(): Retrofit { 14 | when (retrofit) { 15 | null -> retrofit = Retrofit.Builder() 16 | .baseUrl(BASE_URL) 17 | .addConverterFactory(GsonConverterFactory.create()) 18 | .build() 19 | } 20 | return retrofit as Retrofit 21 | } 22 | 23 | } 24 | } -------------------------------------------------------------------------------- /app/src/main/java/com/demo/code/paging/usingRemoteAndLocalSource/networking/RemoteService.kt: -------------------------------------------------------------------------------- 1 | package com.demo.code.paging.usingRemoteAndLocalSource.networking 2 | 3 | import com.demo.code.paging.usingRemoteSource.models.PostsApiResponse 4 | import com.demo.code.paging.usingRemoteSource.networking.RemoteService 5 | import retrofit2.Response 6 | import retrofit2.http.GET 7 | import retrofit2.http.Query 8 | 9 | interface RemoteService { 10 | 11 | companion object { 12 | val service = RemoteService::class.java 13 | } 14 | 15 | @GET("/r/aww/hot.json") 16 | suspend fun fetchPosts( 17 | @Query("limit") loadSize: Int = 0, 18 | @Query("after") after: String? = null, 19 | @Query("before") before: String? = null 20 | ): Response 21 | 22 | 23 | } -------------------------------------------------------------------------------- /app/src/androidTest/java/com/demo/code/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package com.demo.code 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.demo.code", appContext.packageName) 23 | } 24 | } -------------------------------------------------------------------------------- /app/src/main/java/com/demo/code/paging/usingRemoteAndLocalSource/networking/ApiClient.kt: -------------------------------------------------------------------------------- 1 | package com.demo.code.paging.usingRemoteAndLocalSource.networking 2 | 3 | import retrofit2.Retrofit 4 | import retrofit2.converter.gson.GsonConverterFactory 5 | 6 | class ApiClient { 7 | 8 | companion object { 9 | 10 | private const val BASE_URL = "https://www.reddit.com/" 11 | private var retrofit: Retrofit? = null 12 | 13 | fun getClient(): Retrofit { 14 | when (retrofit) { 15 | null -> retrofit = Retrofit.Builder() 16 | .baseUrl(BASE_URL) 17 | .addConverterFactory(GsonConverterFactory.create()) 18 | .build() 19 | } 20 | return retrofit as Retrofit 21 | } 22 | 23 | } 24 | } -------------------------------------------------------------------------------- /app/extensions/src/androidTest/java/com/demo/extensions/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package com.demo.extensions 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.demo.extensions.test", appContext.packageName) 23 | } 24 | } -------------------------------------------------------------------------------- /app/src/main/res/layout/selection_paging_fragment.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 15 | 16 |