├── HiltSimple
├── app
│ ├── .gitignore
│ ├── src
│ │ ├── main
│ │ │ ├── res
│ │ │ │ ├── values
│ │ │ │ │ ├── strings.xml
│ │ │ │ │ ├── colors.xml
│ │ │ │ │ └── styles.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
│ │ │ │ ├── mipmap-anydpi-v26
│ │ │ │ │ ├── ic_launcher.xml
│ │ │ │ │ └── ic_launcher_round.xml
│ │ │ │ └── layout
│ │ │ │ │ ├── fragment_hilt.xml
│ │ │ │ │ └── activity_hilt.xml
│ │ │ ├── java
│ │ │ │ └── com
│ │ │ │ │ └── hi
│ │ │ │ │ └── dhl
│ │ │ │ │ └── hilt
│ │ │ │ │ ├── remote
│ │ │ │ │ ├── GitHubService.kt
│ │ │ │ │ └── GithubAccountModel.kt
│ │ │ │ │ ├── di
│ │ │ │ │ ├── HiltSimple.kt
│ │ │ │ │ ├── RoomModule.kt
│ │ │ │ │ └── NetworkModule.kt
│ │ │ │ │ ├── local
│ │ │ │ │ ├── PersonEntity.kt
│ │ │ │ │ ├── PersonDao.kt
│ │ │ │ │ └── AppDataBase.kt
│ │ │ │ │ ├── ui
│ │ │ │ │ ├── Utils.kt
│ │ │ │ │ ├── AppExecutors.kt
│ │ │ │ │ ├── HitAppCompatActivity.kt
│ │ │ │ │ ├── HiltViewModel.kt
│ │ │ │ │ └── HiltFragment.kt
│ │ │ │ │ └── HiltApplication.kt
│ │ │ └── AndroidManifest.xml
│ │ ├── test
│ │ │ └── java
│ │ │ │ └── com
│ │ │ │ └── hi
│ │ │ │ └── dhl
│ │ │ │ └── hilt
│ │ │ │ └── ExampleUnitTest.kt
│ │ └── androidTest
│ │ │ └── java
│ │ │ └── com
│ │ │ └── hi
│ │ │ └── dhl
│ │ │ └── hilt
│ │ │ └── ExampleInstrumentedTest.kt
│ └── proguard-rules.pro
├── settings.gradle
├── .gitignore
├── gradle
│ └── wrapper
│ │ └── gradle-wrapper.properties
├── build.gradle
└── gradle.properties
├── Splashscreen
├── app
│ ├── .gitignore
│ ├── src
│ │ └── main
│ │ │ ├── res
│ │ │ ├── values
│ │ │ │ ├── strings.xml
│ │ │ │ ├── dimens.xml
│ │ │ │ ├── colors.xml
│ │ │ │ └── themes.xml
│ │ │ ├── mipmap-hdpi
│ │ │ │ ├── ic_launcher.webp
│ │ │ │ └── ic_launcher_round.webp
│ │ │ ├── mipmap-mdpi
│ │ │ │ ├── ic_launcher.webp
│ │ │ │ └── ic_launcher_round.webp
│ │ │ ├── mipmap-xhdpi
│ │ │ │ ├── ic_launcher.webp
│ │ │ │ └── ic_launcher_round.webp
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ ├── ic_launcher.webp
│ │ │ │ └── ic_launcher_round.webp
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ ├── ic_launcher.webp
│ │ │ │ └── ic_launcher_round.webp
│ │ │ ├── mipmap-anydpi-v26
│ │ │ │ ├── ic_launcher.xml
│ │ │ │ └── ic_launcher_round.xml
│ │ │ ├── values-night
│ │ │ │ └── themes.xml
│ │ │ └── layout
│ │ │ │ └── activity_main.xml
│ │ │ └── AndroidManifest.xml
│ ├── proguard-rules.pro
│ └── build.gradle
├── settings.gradle
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── .gitignore
├── build.gradle
└── gradle.properties
├── AppStartupSimple
├── app
│ ├── .gitignore
│ ├── src
│ │ └── main
│ │ │ ├── res
│ │ │ ├── values
│ │ │ │ ├── strings.xml
│ │ │ │ ├── colors.xml
│ │ │ │ └── styles.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
│ │ │ ├── mipmap-anydpi-v26
│ │ │ │ ├── ic_launcher.xml
│ │ │ │ └── ic_launcher_round.xml
│ │ │ └── layout
│ │ │ │ └── activity_main.xml
│ │ │ ├── AndroidManifest.xml
│ │ │ └── java
│ │ │ └── com
│ │ │ └── hi
│ │ │ └── dhl
│ │ │ └── startup
│ │ │ └── simple
│ │ │ └── MainActivity.kt
│ └── proguard-rules.pro
├── ContentProvider
│ ├── .gitignore
│ ├── consumer-rules.pro
│ ├── src
│ │ ├── main
│ │ │ ├── AndroidManifest.xml
│ │ │ └── java
│ │ │ │ └── com
│ │ │ │ └── hi
│ │ │ │ └── dhl
│ │ │ │ └── startup
│ │ │ │ └── contentprovider
│ │ │ │ └── WorkContentProvider.kt
│ │ ├── test
│ │ │ └── java
│ │ │ │ └── com
│ │ │ │ └── hi
│ │ │ │ └── dhl
│ │ │ │ └── startup
│ │ │ │ └── contentprovider
│ │ │ │ └── ExampleUnitTest.kt
│ │ └── androidTest
│ │ │ └── java
│ │ │ └── com
│ │ │ └── hi
│ │ │ └── dhl
│ │ │ └── startup
│ │ │ └── contentprovider
│ │ │ └── ExampleInstrumentedTest.kt
│ ├── proguard-rules.pro
│ └── build.gradle
├── Startup-Library
│ ├── .gitignore
│ ├── consumer-rules.pro
│ ├── src
│ │ ├── test
│ │ │ └── java
│ │ │ │ └── com
│ │ │ │ └── hi
│ │ │ │ └── dhl
│ │ │ │ └── startup
│ │ │ │ └── library
│ │ │ │ └── ExampleUnitTest.kt
│ │ ├── main
│ │ │ ├── java
│ │ │ │ └── com
│ │ │ │ │ └── hi
│ │ │ │ │ └── dhl
│ │ │ │ │ └── startup
│ │ │ │ │ └── library
│ │ │ │ │ ├── LibaryA.kt
│ │ │ │ │ ├── LibaryB.kt
│ │ │ │ │ ├── LibaryC.kt
│ │ │ │ │ └── LibaryD.kt
│ │ │ └── AndroidManifest.xml
│ │ └── androidTest
│ │ │ └── java
│ │ │ └── com
│ │ │ └── hi
│ │ │ └── dhl
│ │ │ └── startup
│ │ │ └── library
│ │ │ └── ExampleInstrumentedTest.kt
│ ├── proguard-rules.pro
│ └── build.gradle
├── settings.gradle
├── gradle
│ └── wrapper
│ │ └── gradle-wrapper.properties
├── build.gradle
└── gradle.properties
├── DataStoreSimple
├── app
│ ├── .gitignore
│ ├── src
│ │ ├── main
│ │ │ ├── res
│ │ │ │ ├── values
│ │ │ │ │ ├── strings.xml
│ │ │ │ │ ├── colors.xml
│ │ │ │ │ └── styles.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
│ │ │ │ └── mipmap-anydpi-v26
│ │ │ │ │ ├── ic_launcher.xml
│ │ │ │ │ └── ic_launcher_round.xml
│ │ │ ├── java
│ │ │ │ └── com
│ │ │ │ │ └── hi
│ │ │ │ │ └── dhl
│ │ │ │ │ └── datastore
│ │ │ │ │ ├── data
│ │ │ │ │ ├── IRepository.kt
│ │ │ │ │ ├── IDataStoreRepository.kt
│ │ │ │ │ └── SharedPreferencesRepository.kt
│ │ │ │ │ ├── App.kt
│ │ │ │ │ └── di
│ │ │ │ │ └── RepositoryModule.kt
│ │ │ └── AndroidManifest.xml
│ │ ├── test
│ │ │ └── java
│ │ │ │ └── com
│ │ │ │ └── hi
│ │ │ │ └── dhl
│ │ │ │ └── datastore
│ │ │ │ └── ExampleUnitTest.kt
│ │ └── androidTest
│ │ │ └── java
│ │ │ └── com
│ │ │ └── hi
│ │ │ └── dhl
│ │ │ └── datastore
│ │ │ └── ExampleInstrumentedTest.kt
│ └── proguard-rules.pro
├── settings.gradle
├── .gitignore
├── gradle
│ └── wrapper
│ │ └── gradle-wrapper.properties
├── build.gradle
└── gradle.properties
├── Paging3Simple
├── app
│ ├── .gitignore
│ ├── src
│ │ ├── main
│ │ │ ├── res
│ │ │ │ ├── values
│ │ │ │ │ ├── strings.xml
│ │ │ │ │ ├── dimens.xml
│ │ │ │ │ ├── colors.xml
│ │ │ │ │ └── styles.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
│ │ │ │ ├── mipmap-anydpi-v26
│ │ │ │ │ ├── ic_launcher.xml
│ │ │ │ │ └── ic_launcher_round.xml
│ │ │ │ └── layout
│ │ │ │ │ ├── activity_main.xml
│ │ │ │ │ └── recycie_item_person.xml
│ │ │ ├── java
│ │ │ │ └── com
│ │ │ │ │ └── hi
│ │ │ │ │ └── dhl
│ │ │ │ │ └── paging3
│ │ │ │ │ ├── data
│ │ │ │ │ ├── mapper
│ │ │ │ │ │ ├── Mapper.kt
│ │ │ │ │ │ ├── PersonEntity2PersonMapper.kt
│ │ │ │ │ │ └── Person2PersonEntityMapper.kt
│ │ │ │ │ ├── local
│ │ │ │ │ │ ├── PersonEntity.kt
│ │ │ │ │ │ └── PersonDao.kt
│ │ │ │ │ ├── repository
│ │ │ │ │ │ └── Repository.kt
│ │ │ │ │ └── AppExecutors.kt
│ │ │ │ │ ├── bean
│ │ │ │ │ └── Person.kt
│ │ │ │ │ ├── App.kt
│ │ │ │ │ ├── di
│ │ │ │ │ └── AppModule.kt
│ │ │ │ │ └── ui
│ │ │ │ │ ├── PersonViewHolder.kt
│ │ │ │ │ └── PersonAdapter.kt
│ │ │ └── AndroidManifest.xml
│ │ ├── test
│ │ │ └── java
│ │ │ │ └── com
│ │ │ │ └── hi
│ │ │ │ └── dhl
│ │ │ │ └── paging3
│ │ │ │ └── ExampleUnitTest.kt
│ │ └── androidTest
│ │ │ └── java
│ │ │ └── com
│ │ │ └── hi
│ │ │ └── dhl
│ │ │ └── paging3
│ │ │ └── ExampleInstrumentedTest.kt
│ └── proguard-rules.pro
├── settings.gradle
├── .gitignore
├── gradle
│ └── wrapper
│ │ └── gradle-wrapper.properties
├── build.gradle
└── gradle.properties
├── VersionPlugin
├── .gitignore
├── src
│ ├── test
│ │ └── kotlin
│ │ │ └── com
│ │ │ └── hi
│ │ │ └── dhl
│ │ │ └── plugin
│ │ │ └── DepsTest.java
│ └── main
│ │ └── java
│ │ └── com
│ │ └── hi
│ │ └── dhl
│ │ └── plugin
│ │ ├── BuildConfig.kt
│ │ └── VersionPlugin.kt
└── build.gradle
├── HiltWithAppStartupSimple
├── app
│ ├── .gitignore
│ ├── src
│ │ ├── main
│ │ │ ├── res
│ │ │ │ ├── values
│ │ │ │ │ ├── strings.xml
│ │ │ │ │ ├── colors.xml
│ │ │ │ │ └── styles.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
│ │ │ │ ├── mipmap-anydpi-v26
│ │ │ │ │ ├── ic_launcher.xml
│ │ │ │ │ └── ic_launcher_round.xml
│ │ │ │ └── layout
│ │ │ │ │ ├── fragment_hilt.xml
│ │ │ │ │ └── activity_hilt.xml
│ │ │ └── java
│ │ │ │ └── com
│ │ │ │ └── hi
│ │ │ │ └── dhl
│ │ │ │ └── hilt
│ │ │ │ └── appstartup
│ │ │ │ ├── data
│ │ │ │ ├── WorkService.kt
│ │ │ │ ├── DataSource.kt
│ │ │ │ ├── Repository.kt
│ │ │ │ ├── local
│ │ │ │ │ ├── LocalDataSource.kt
│ │ │ │ │ ├── PersonEntity.kt
│ │ │ │ │ ├── PersonDao.kt
│ │ │ │ │ └── AppDataBase.kt
│ │ │ │ ├── remote
│ │ │ │ │ ├── GitHubService.kt
│ │ │ │ │ ├── RemoteDataSource.kt
│ │ │ │ │ └── GithubAccountModel.kt
│ │ │ │ ├── WorkServiceImpl.kt
│ │ │ │ ├── TasksRepository.kt
│ │ │ │ └── AppExecutors.kt
│ │ │ │ ├── di
│ │ │ │ ├── HiltSimple.kt
│ │ │ │ ├── WorkServiceModule.kt
│ │ │ │ └── RoomModule.kt
│ │ │ │ ├── HiltApplication.kt
│ │ │ │ └── init
│ │ │ │ ├── AppInitializer.kt
│ │ │ │ ├── InitializerEntryPoint.kt
│ │ │ │ └── WorkContentProvider.kt
│ │ ├── test
│ │ │ └── java
│ │ │ │ └── com
│ │ │ │ └── hi
│ │ │ │ └── dhl
│ │ │ │ └── hilt
│ │ │ │ └── appstartup
│ │ │ │ └── ExampleUnitTest.kt
│ │ └── androidTest
│ │ │ └── java
│ │ │ └── com
│ │ │ └── hi
│ │ │ └── dhl
│ │ │ └── hilt
│ │ │ └── appstartup
│ │ │ └── ExampleInstrumentedTest.kt
│ └── proguard-rules.pro
├── settings.gradle
├── .gitignore
├── gradle
│ └── wrapper
│ │ └── gradle-wrapper.properties
├── build.gradle
└── gradle.properties
├── HiltWithMultiModuleSimple
├── app
│ ├── .gitignore
│ ├── src
│ │ ├── main
│ │ │ ├── res
│ │ │ │ ├── values
│ │ │ │ │ ├── strings.xml
│ │ │ │ │ ├── colors.xml
│ │ │ │ │ └── styles.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
│ │ │ │ ├── mipmap-anydpi-v26
│ │ │ │ │ ├── ic_launcher.xml
│ │ │ │ │ └── ic_launcher_round.xml
│ │ │ │ └── layout
│ │ │ │ │ └── activity_main.xml
│ │ │ ├── java
│ │ │ │ └── com
│ │ │ │ │ └── hi
│ │ │ │ │ └── dhl
│ │ │ │ │ └── hilt
│ │ │ │ │ └── hilt
│ │ │ │ │ └── module
│ │ │ │ │ ├── HiltApplication.kt
│ │ │ │ │ ├── HiltViewModel.kt
│ │ │ │ │ ├── MainActivity.kt
│ │ │ │ │ └── di
│ │ │ │ │ └── RoomModule.kt
│ │ │ └── AndroidManifest.xml
│ │ ├── test
│ │ │ └── java
│ │ │ │ └── com
│ │ │ │ └── hi
│ │ │ │ └── dhl
│ │ │ │ └── hilt
│ │ │ │ └── hilt
│ │ │ │ └── module
│ │ │ │ └── ExampleUnitTest.kt
│ │ └── androidTest
│ │ │ └── java
│ │ │ └── com
│ │ │ └── hi
│ │ │ └── dhl
│ │ │ └── hilt
│ │ │ └── hilt
│ │ │ └── module
│ │ │ └── ExampleInstrumentedTest.kt
│ └── proguard-rules.pro
├── common-core
│ ├── .gitignore
│ ├── consumer-rules.pro
│ ├── src
│ │ ├── main
│ │ │ ├── AndroidManifest.xml
│ │ │ └── java
│ │ │ │ └── com
│ │ │ │ └── hi
│ │ │ │ └── dhl
│ │ │ │ └── hilt
│ │ │ │ └── hilt
│ │ │ │ └── common
│ │ │ │ └── core
│ │ │ │ ├── DataSource.kt
│ │ │ │ ├── local
│ │ │ │ ├── LocalDataSource.kt
│ │ │ │ ├── PersonEntity.kt
│ │ │ │ ├── PersonDao.kt
│ │ │ │ └── AppDataBase.kt
│ │ │ │ └── remote
│ │ │ │ ├── GitHubService.kt
│ │ │ │ ├── RemoteDataSource.kt
│ │ │ │ └── GithubAccountModel.kt
│ │ ├── test
│ │ │ └── java
│ │ │ │ └── com
│ │ │ │ └── hi
│ │ │ │ └── dhl
│ │ │ │ └── hilt
│ │ │ │ └── hilt
│ │ │ │ └── common
│ │ │ │ └── core
│ │ │ │ └── ExampleUnitTest.kt
│ │ └── androidTest
│ │ │ └── java
│ │ │ └── com
│ │ │ └── hi
│ │ │ └── dhl
│ │ │ └── hilt
│ │ │ └── hilt
│ │ │ └── common
│ │ │ └── core
│ │ │ └── ExampleInstrumentedTest.kt
│ └── proguard-rules.pro
├── feature-task
│ ├── .gitignore
│ ├── consumer-rules.pro
│ ├── src
│ │ ├── main
│ │ │ ├── AndroidManifest.xml
│ │ │ └── java
│ │ │ │ └── com
│ │ │ │ └── hi
│ │ │ │ └── dhl
│ │ │ │ └── hilt
│ │ │ │ └── hilt
│ │ │ │ └── feature
│ │ │ │ └── task
│ │ │ │ ├── Repository.kt
│ │ │ │ ├── AppExecutors.kt
│ │ │ │ └── TasksRepository.kt
│ │ ├── test
│ │ │ └── java
│ │ │ │ └── com
│ │ │ │ └── hi
│ │ │ │ └── dhl
│ │ │ │ └── hilt
│ │ │ │ └── hilt
│ │ │ │ └── feature
│ │ │ │ └── task
│ │ │ │ └── ExampleUnitTest.kt
│ │ └── androidTest
│ │ │ └── java
│ │ │ └── com
│ │ │ └── hi
│ │ │ └── dhl
│ │ │ └── hilt
│ │ │ └── hilt
│ │ │ └── feature
│ │ │ └── task
│ │ │ └── ExampleInstrumentedTest.kt
│ └── proguard-rules.pro
├── settings.gradle
├── .gitignore
├── gradle
│ └── wrapper
│ │ └── gradle-wrapper.properties
├── build.gradle
└── gradle.properties
├── Paging3SimpleWithNetWork
├── app
│ ├── .gitignore
│ ├── src
│ │ ├── main
│ │ │ ├── res
│ │ │ │ ├── values
│ │ │ │ │ ├── dimens.xml
│ │ │ │ │ ├── strings.xml
│ │ │ │ │ ├── colors.xml
│ │ │ │ │ └── styles.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
│ │ │ │ ├── mipmap-anydpi-v26
│ │ │ │ │ ├── ic_launcher.xml
│ │ │ │ │ └── ic_launcher_round.xml
│ │ │ │ └── layout
│ │ │ │ │ └── recycie_item_network_state.xml
│ │ │ ├── java
│ │ │ │ └── com
│ │ │ │ │ └── hi
│ │ │ │ │ └── dhl
│ │ │ │ │ └── paging3
│ │ │ │ │ └── network
│ │ │ │ │ ├── data
│ │ │ │ │ ├── mapper
│ │ │ │ │ │ ├── Mapper.kt
│ │ │ │ │ │ ├── GitHub2ModelMapper.kt
│ │ │ │ │ │ └── Model2GitHubMapper.kt
│ │ │ │ │ ├── repository
│ │ │ │ │ │ ├── Repository.kt
│ │ │ │ │ │ └── GitHubItemPagingSource.kt
│ │ │ │ │ ├── AppExecutors.kt
│ │ │ │ │ ├── remote
│ │ │ │ │ │ ├── GithubAccountModel.kt
│ │ │ │ │ │ └── GitHubService.kt
│ │ │ │ │ └── RepositoryFactory.kt
│ │ │ │ │ ├── App.kt
│ │ │ │ │ ├── di
│ │ │ │ │ └── AppModule.kt
│ │ │ │ │ ├── ui
│ │ │ │ │ ├── MainViewModel.kt
│ │ │ │ │ ├── GitHubViewHolder.kt
│ │ │ │ │ ├── github
│ │ │ │ │ │ ├── FooterAdapter.kt
│ │ │ │ │ │ └── NetworkStateItemViewHolder.kt
│ │ │ │ │ └── GitHubAdapter.kt
│ │ │ │ │ └── bean
│ │ │ │ │ └── GitHubAccount.kt
│ │ │ └── AndroidManifest.xml
│ │ ├── test
│ │ │ └── java
│ │ │ │ └── com
│ │ │ │ └── hi
│ │ │ │ └── dhl
│ │ │ │ └── paging3
│ │ │ │ └── network
│ │ │ │ └── ExampleUnitTest.kt
│ │ └── androidTest
│ │ │ └── java
│ │ │ └── com
│ │ │ └── hi
│ │ │ └── dhl
│ │ │ └── paging3
│ │ │ └── network
│ │ │ └── ExampleInstrumentedTest.kt
│ └── proguard-rules.pro
├── settings.gradle
├── .gitignore
├── gradle
│ └── wrapper
│ │ └── gradle-wrapper.properties
├── build.gradle
└── gradle.properties
└── subproject.gradle
/HiltSimple/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/Splashscreen/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/AppStartupSimple/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/DataStoreSimple/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/Paging3Simple/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/VersionPlugin/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/HiltWithAppStartupSimple/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/HiltWithMultiModuleSimple/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/Paging3SimpleWithNetWork/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/AppStartupSimple/ContentProvider/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/AppStartupSimple/ContentProvider/consumer-rules.pro:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/AppStartupSimple/Startup-Library/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/AppStartupSimple/Startup-Library/consumer-rules.pro:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/HiltWithMultiModuleSimple/common-core/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/HiltWithMultiModuleSimple/common-core/consumer-rules.pro:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/HiltWithMultiModuleSimple/feature-task/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/HiltWithMultiModuleSimple/feature-task/consumer-rules.pro:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/HiltSimple/settings.gradle:
--------------------------------------------------------------------------------
1 | includeBuild("../VersionPlugin")
2 | include ':app'
3 | rootProject.name = "HiltSimple"
--------------------------------------------------------------------------------
/DataStoreSimple/settings.gradle:
--------------------------------------------------------------------------------
1 | includeBuild("../VersionPlugin")
2 | include ':app'
3 | rootProject.name = "DataStoreSimple"
--------------------------------------------------------------------------------
/Paging3Simple/settings.gradle:
--------------------------------------------------------------------------------
1 | includeBuild("../VersionPlugin")
2 | include ':app'
3 | rootProject.name = "Paging3Simple"
--------------------------------------------------------------------------------
/Splashscreen/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name = "Splashscreen"
2 | include ':app'
3 | includeBuild("../VersionPlugin")
4 |
--------------------------------------------------------------------------------
/HiltSimple/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
5 | * author: dhl 6 | * date : 2020/5/29 7 | * desc : 8 | *9 | */ 10 | public class DepsTest { 11 | 12 | } -------------------------------------------------------------------------------- /HiltSimple/app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 |
5 | * author: dhl 6 | * date : 2020/6/16 7 | * desc : 8 | * 9 | *10 | */ 11 | interface Mapper { 12 | fun map(input: I): O 13 | } -------------------------------------------------------------------------------- /Splashscreen/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Sun Aug 15 11:47:33 CST 2021 2 | distributionBase=GRADLE_USER_HOME 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip 4 | distributionPath=wrapper/dists 5 | zipStorePath=wrapper/dists 6 | zipStoreBase=GRADLE_USER_HOME 7 | -------------------------------------------------------------------------------- /HiltWithAppStartupSimple/.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 | -------------------------------------------------------------------------------- /HiltWithAppStartupSimple/app/src/main/java/com/hi/dhl/hilt/appstartup/data/WorkService.kt: -------------------------------------------------------------------------------- 1 | package com.hi.dhl.hilt.appstartup.data 2 | 3 | /** 4 | *
5 | * author: dhl 6 | * date : 2020/6/25 7 | * desc : 8 | *9 | */ 10 | 11 | interface WorkService { 12 | fun init() 13 | } -------------------------------------------------------------------------------- /HiltWithMultiModuleSimple/.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 | -------------------------------------------------------------------------------- /Paging3Simple/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Tue Jun 16 00:04:07 CST 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.7.1-all.zip 7 | 8 | -------------------------------------------------------------------------------- /Paging3SimpleWithNetWork/.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 | -------------------------------------------------------------------------------- /HiltWithAppStartupSimple/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Thu Jun 25 15:26:06 CST 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.7.1-all.zip 7 | -------------------------------------------------------------------------------- /HiltWithMultiModuleSimple/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Tue Jun 30 15:48:04 CST 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.7.1-all.zip 7 | -------------------------------------------------------------------------------- /Paging3SimpleWithNetWork/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Sat Jun 20 09:59:46 CST 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.7.1-all.zip 7 | 8 | -------------------------------------------------------------------------------- /Splashscreen/.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 | -------------------------------------------------------------------------------- /HiltWithMultiModuleSimple/feature-task/src/main/java/com/hi/dhl/hilt/hilt/feature/task/Repository.kt: -------------------------------------------------------------------------------- 1 | package com.hi.dhl.hilt.hilt.feature.task 2 | 3 | /** 4 | *
5 | * author: dhl 6 | * date : 2020/6/30 7 | * desc : 8 | *9 | */ 10 | interface Repository { 11 | fun updateData(name: String) 12 | } -------------------------------------------------------------------------------- /Paging3SimpleWithNetWork/app/src/main/java/com/hi/dhl/paging3/network/data/mapper/Mapper.kt: -------------------------------------------------------------------------------- 1 | package com.hi.dhl.paging3.network.data.mapper 2 | 3 | /** 4 | *
5 | * author: dhl 6 | * date : 2020/6/20 7 | * desc : 8 | * 9 | *10 | */ 11 | interface Mapper { 12 | fun map(input: I): O 13 | } -------------------------------------------------------------------------------- /HiltSimple/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 |
5 | * author: dhl 6 | * date : 2020/10/2 7 | * desc : 8 | *9 | */ 10 | interface IRepository { 11 | 12 | fun saveData(key: String) 13 | fun readData(key: String): Boolean 14 | } -------------------------------------------------------------------------------- /DataStoreSimple/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 |
9 | * author: dhl 10 | * date : 2020/10/2 11 | * desc : 12 | *13 | */ 14 | 15 | @HiltAndroidApp 16 | class App : Application() -------------------------------------------------------------------------------- /HiltWithAppStartupSimple/app/src/main/java/com/hi/dhl/hilt/appstartup/data/DataSource.kt: -------------------------------------------------------------------------------- 1 | package com.hi.dhl.hilt.appstartup.data 2 | 3 | import com.hi.dhl.hilt.appstartup.data.local.PersonEntity 4 | 5 | /** 6 | *
7 | * author: dhl 8 | * date : 2020/6/26 9 | * desc : 10 | *11 | */ 12 | interface DataSource { 13 | fun saveTask(person: PersonEntity) 14 | } -------------------------------------------------------------------------------- /HiltWithAppStartupSimple/app/src/main/java/com/hi/dhl/hilt/appstartup/data/Repository.kt: -------------------------------------------------------------------------------- 1 | package com.hi.dhl.hilt.appstartup.data 2 | 3 | import com.hi.dhl.hilt.appstartup.data.local.PersonEntity 4 | 5 | /** 6 | *
7 | * author: dhl 8 | * date : 2020/6/26 9 | * desc : 10 | *11 | */ 12 | interface Repository { 13 | fun updateData(person: PersonEntity) 14 | } -------------------------------------------------------------------------------- /HiltWithMultiModuleSimple/common-core/src/main/java/com/hi/dhl/hilt/hilt/common/core/DataSource.kt: -------------------------------------------------------------------------------- 1 | package com.hi.dhl.hilt.hilt.common.core 2 | 3 | import com.hi.dhl.hilt.hilt.common.core.local.PersonEntity 4 | 5 | /** 6 | *
7 | * author: dhl 8 | * date : 2020/6/30 9 | * desc : 10 | *11 | */ 12 | public interface DataSource { 13 | fun saveTask(person: PersonEntity) 14 | } -------------------------------------------------------------------------------- /AppStartupSimple/ContentProvider/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 |
5 | * author: dhl 6 | * date : 2020/6/15 7 | * desc : 配置和 Build 相关的 8 | *9 | */ 10 | object BuildConfig { 11 | val compileSdkVersion = 29 12 | val buildToolsVersion = "29.0.3" 13 | val minSdkVersion = 26 14 | val targetSdkVersion = 29 15 | val versionCode = 10000 16 | val versionName = "1.0.0" 17 | } -------------------------------------------------------------------------------- /AppStartupSimple/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 |
8 | * author: dhl 9 | * date : 2020/5/29 10 | * desc : 如果出现红色警告可以忽略,不会影响项目的编译和运行 11 | *12 | */ 13 | class VersionPlugin : Plugin
8 | * author: dhl 9 | * date : 2020/6/24 10 | * desc : 11 | *12 | */ 13 | 14 | interface GitHubService { 15 | @GET("users") 16 | suspend fun getGithubAccount(@Query("since") id: Int, @Query("per_page") perPage: Int): 17 | List
8 | * author: dhl 9 | * date : 2020/6/24 10 | * desc : 11 | *12 | */ 13 | class HiltSimple @Inject constructor() { 14 | fun doSomething() { 15 | Log.e(TAG, "----doSomething----") 16 | } 17 | 18 | companion object { 19 | private val TAG = "HiltSimple" 20 | } 21 | } -------------------------------------------------------------------------------- /HiltSimple/app/src/main/java/com/hi/dhl/hilt/local/PersonEntity.kt: -------------------------------------------------------------------------------- 1 | package com.hi.dhl.paging3.data.local 2 | 3 | import androidx.room.Entity 4 | import androidx.room.PrimaryKey 5 | 6 | /** 7 | *
8 | * author: dhl 9 | * date : 2020/6/24 10 | * desc : 11 | *12 | */ 13 | 14 | @Entity 15 | class PersonEntity( 16 | @PrimaryKey(autoGenerate = true) val id: Int = 0, 17 | val name: String, 18 | val updateTime: Long = System.currentTimeMillis() 19 | ) 20 | -------------------------------------------------------------------------------- /HiltSimple/app/src/main/java/com/hi/dhl/hilt/local/PersonDao.kt: -------------------------------------------------------------------------------- 1 | package com.hi.dhl.paging3.data.local 2 | 3 | import androidx.room.Dao 4 | import androidx.room.Insert 5 | import androidx.room.OnConflictStrategy 6 | 7 | /** 8 | *
9 | * author: dhl 10 | * date : 2020/6/24 11 | * desc : 12 | *13 | */ 14 | 15 | @Dao 16 | interface PersonDao { 17 | 18 | 19 | @Insert(onConflict = OnConflictStrategy.REPLACE) 20 | fun insert(personEntity: PersonEntity) 21 | 22 | } -------------------------------------------------------------------------------- /AppStartupSimple/Startup-Library/src/test/java/com/hi/dhl/startup/library/ExampleUnitTest.kt: -------------------------------------------------------------------------------- 1 | package com.hi.dhl.startup.library 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 | } -------------------------------------------------------------------------------- /HiltWithAppStartupSimple/app/src/test/java/com/hi/dhl/hilt/appstartup/ExampleUnitTest.kt: -------------------------------------------------------------------------------- 1 | package com.hi.dhl.hilt.appstartup 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 | } -------------------------------------------------------------------------------- /HiltWithMultiModuleSimple/app/src/test/java/com/hi/dhl/hilt/hilt/module/ExampleUnitTest.kt: -------------------------------------------------------------------------------- 1 | package com.hi.dhl.hilt.hilt.module 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 | } -------------------------------------------------------------------------------- /Paging3Simple/app/src/main/java/com/hi/dhl/paging3/data/local/PersonEntity.kt: -------------------------------------------------------------------------------- 1 | package com.hi.dhl.paging3.data.local 2 | 3 | import androidx.room.Entity 4 | import androidx.room.PrimaryKey 5 | 6 | /** 7 | *
8 | * author: dhl 9 | * date : 2020/6/16 10 | * desc : 11 | *12 | */ 13 | 14 | @Entity 15 | class PersonEntity( 16 | @PrimaryKey(autoGenerate = true) val id: Int = 0, 17 | val name: String, 18 | val updateTime: Long = System.currentTimeMillis() 19 | ) 20 | -------------------------------------------------------------------------------- /Paging3SimpleWithNetWork/app/src/test/java/com/hi/dhl/paging3/network/ExampleUnitTest.kt: -------------------------------------------------------------------------------- 1 | package com.hi.dhl.paging3.network 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 | } -------------------------------------------------------------------------------- /HiltWithAppStartupSimple/app/src/main/java/com/hi/dhl/hilt/appstartup/data/local/LocalDataSource.kt: -------------------------------------------------------------------------------- 1 | package com.hi.dhl.hilt.appstartup.data.local 2 | 3 | import com.hi.dhl.hilt.appstartup.data.DataSource 4 | 5 | /** 6 | *
7 | * author: dhl 8 | * date : 2020/6/26 9 | * desc : 10 | *11 | */ 12 | class LocalDataSource(private val personDao: PersonDao) : 13 | DataSource { 14 | override fun saveTask(person: PersonEntity) { 15 | personDao.insert(person) 16 | } 17 | } -------------------------------------------------------------------------------- /AppStartupSimple/ContentProvider/src/test/java/com/hi/dhl/startup/contentprovider/ExampleUnitTest.kt: -------------------------------------------------------------------------------- 1 | package com.hi.dhl.startup.contentprovider 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 | } -------------------------------------------------------------------------------- /HiltWithMultiModuleSimple/common-core/src/main/java/com/hi/dhl/hilt/hilt/common/core/local/LocalDataSource.kt: -------------------------------------------------------------------------------- 1 | package com.hi.dhl.hilt.hilt.common.core.local 2 | 3 | import com.hi.dhl.hilt.hilt.common.core.DataSource 4 | 5 | /** 6 | *
7 | * author: dhl 8 | * date : 2020/6/30 9 | * desc : 10 | *11 | */ 12 | class LocalDataSource(private val personDao: PersonDao) : 13 | DataSource { 14 | override fun saveTask(person: PersonEntity) { 15 | personDao.insert(person) 16 | } 17 | } -------------------------------------------------------------------------------- /HiltWithMultiModuleSimple/common-core/src/test/java/com/hi/dhl/hilt/hilt/common/core/ExampleUnitTest.kt: -------------------------------------------------------------------------------- 1 | package com.hi.dhl.hilt.hilt.common.core 2 | 3 | import org.junit.Test 4 | 5 | import org.junit.Assert.* 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * See [testing documentation](http://d.android.com/tools/testing). 11 | */ 12 | class ExampleUnitTest { 13 | @Test 14 | fun addition_isCorrect() { 15 | assertEquals(4, 2 + 2) 16 | } 17 | } -------------------------------------------------------------------------------- /HiltWithMultiModuleSimple/feature-task/src/test/java/com/hi/dhl/hilt/hilt/feature/task/ExampleUnitTest.kt: -------------------------------------------------------------------------------- 1 | package com.hi.dhl.hilt.hilt.feature.task 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 | } -------------------------------------------------------------------------------- /HiltSimple/app/src/main/java/com/hi/dhl/hilt/local/AppDataBase.kt: -------------------------------------------------------------------------------- 1 | package com.hi.dhl.paging3.data.local 2 | 3 | import androidx.room.Database 4 | import androidx.room.RoomDatabase 5 | 6 | /** 7 | *
8 | * author: dhl 9 | * date : 2020/6/24 10 | * desc : 11 | *12 | */ 13 | 14 | @Database( 15 | entities = arrayOf(PersonEntity::class), 16 | version = 1, exportSchema = false 17 | ) 18 | abstract class AppDataBase : RoomDatabase() { 19 | 20 | abstract fun personDao(): PersonDao 21 | } 22 | -------------------------------------------------------------------------------- /HiltWithAppStartupSimple/app/src/main/java/com/hi/dhl/hilt/appstartup/data/local/PersonEntity.kt: -------------------------------------------------------------------------------- 1 | package com.hi.dhl.hilt.appstartup.data.local 2 | 3 | import androidx.room.Entity 4 | import androidx.room.PrimaryKey 5 | 6 | /** 7 | *
8 | * author: dhl 9 | * date : 2020/6/24 10 | * desc : 11 | *12 | */ 13 | 14 | @Entity 15 | class PersonEntity( 16 | @PrimaryKey(autoGenerate = true) val id: Int = 0, 17 | val name: String, 18 | val updateTime: Long = System.currentTimeMillis() 19 | ) 20 | -------------------------------------------------------------------------------- /HiltWithAppStartupSimple/app/src/main/java/com/hi/dhl/hilt/appstartup/data/remote/GitHubService.kt: -------------------------------------------------------------------------------- 1 | package com.hi.dhl.hilt.appstartup.data.remote 2 | 3 | import retrofit2.http.GET 4 | import retrofit2.http.Query 5 | 6 | /** 7 | *
8 | * author: dhl 9 | * date : 2020/6/24 10 | * desc : 11 | *12 | */ 13 | 14 | interface GitHubService { 15 | @GET("users") 16 | suspend fun getGithubAccount(@Query("since") id: Int, @Query("per_page") perPage: Int): 17 | List
9 | * author: dhl 10 | * date : 2020/6/24 11 | * desc : 12 | *13 | */ 14 | 15 | @Dao 16 | interface PersonDao { 17 | 18 | 19 | @Insert(onConflict = OnConflictStrategy.REPLACE) 20 | fun insert(personEntity: PersonEntity) 21 | 22 | } -------------------------------------------------------------------------------- /HiltWithMultiModuleSimple/common-core/src/main/java/com/hi/dhl/hilt/hilt/common/core/local/PersonEntity.kt: -------------------------------------------------------------------------------- 1 | package com.hi.dhl.hilt.hilt.common.core.local 2 | 3 | import androidx.room.Entity 4 | import androidx.room.PrimaryKey 5 | 6 | /** 7 | *
8 | * author: dhl 9 | * date : 2020/6/30 10 | * desc : 11 | *12 | */ 13 | 14 | @Entity 15 | class PersonEntity( 16 | @PrimaryKey(autoGenerate = true) val id: Int = 0, 17 | val name: String, 18 | val updateTime: Long = System.currentTimeMillis() 19 | ) 20 | -------------------------------------------------------------------------------- /Paging3Simple/app/src/main/java/com/hi/dhl/paging3/data/repository/Repository.kt: -------------------------------------------------------------------------------- 1 | package com.hi.dhl.paging3.data.repository 2 | 3 | import androidx.paging.PagingData 4 | import com.hi.dhl.paging3.bean.Person 5 | import kotlinx.coroutines.flow.Flow 6 | 7 | /** 8 | *
9 | * author: dhl 10 | * date : 2020/6/16 11 | * desc : 12 | *13 | */ 14 | interface Repository { 15 | 16 | fun postOfData(): Flow
9 | * author: dhl 10 | * date : 2020/6/30 11 | * desc : 12 | *13 | */ 14 | 15 | @Dao 16 | interface PersonDao { 17 | 18 | 19 | @Insert(onConflict = OnConflictStrategy.REPLACE) 20 | fun insert(personEntity: PersonEntity) 21 | 22 | } -------------------------------------------------------------------------------- /DataStoreSimple/app/src/main/java/com/hi/dhl/datastore/data/IDataStoreRepository.kt: -------------------------------------------------------------------------------- 1 | package com.hi.dhl.datastore.data 2 | 3 | import androidx.datastore.preferences.Preferences 4 | import kotlinx.coroutines.flow.Flow 5 | 6 | 7 | /** 8 | *
9 | * author: dhl 10 | * date : 2020/10/2 11 | * desc : 12 | *13 | */ 14 | interface IDataStoreRepository { 15 | suspend fun saveData(key: Preferences.Key
8 | * author: dhl 9 | * date : 2020/6/24 10 | * desc : 11 | *12 | */ 13 | 14 | @Database( 15 | entities = arrayOf(PersonEntity::class), 16 | version = 1, exportSchema = false 17 | ) 18 | abstract class AppDataBase : RoomDatabase() { 19 | 20 | abstract fun personDao(): PersonDao 21 | } 22 | -------------------------------------------------------------------------------- /Paging3Simple/app/src/main/java/com/hi/dhl/paging3/data/mapper/PersonEntity2PersonMapper.kt: -------------------------------------------------------------------------------- 1 | package com.hi.dhl.paging3.data.mapper 2 | 3 | import com.hi.dhl.paging3.bean.Person 4 | import com.hi.dhl.paging3.data.local.PersonEntity 5 | 6 | /** 7 | *
8 | * author: dhl 9 | * date : 2020/6/16 10 | * desc : 数据映射, 数据库实体 PersonEntity ——> 上层用到的实体 Person 11 | *12 | */ 13 | class PersonEntity2PersonMapper : Mapper
10 | * author: dhl 11 | * date : 2020/6/20 12 | * desc : 13 | *14 | */ 15 | interface Repository : AnkoLogger { 16 | 17 | fun postOfData(id: Int): Flow
8 | * author: dhl 9 | * date : 2020/6/30 10 | * desc : 11 | *12 | */ 13 | 14 | @Database( 15 | entities = arrayOf(PersonEntity::class), 16 | version = 1, exportSchema = false 17 | ) 18 | abstract class AppDataBase : RoomDatabase() { 19 | 20 | abstract fun personDao(): PersonDao 21 | } 22 | -------------------------------------------------------------------------------- /HiltWithAppStartupSimple/app/src/main/java/com/hi/dhl/hilt/appstartup/di/HiltSimple.kt: -------------------------------------------------------------------------------- 1 | package com.hi.dhl.hilt.appstartup.di 2 | 3 | import android.util.Log 4 | import javax.inject.Inject 5 | import javax.inject.Singleton 6 | 7 | /** 8 | *
9 | * author: dhl 10 | * date : 2020/6/24 11 | * desc : 12 | *13 | */ 14 | 15 | @Singleton 16 | class HiltSimple @Inject constructor() { 17 | fun doSomething() { 18 | Log.e(TAG, "----doSomething----") 19 | } 20 | 21 | companion object { 22 | private val TAG = "HiltSimple" 23 | } 24 | } -------------------------------------------------------------------------------- /Paging3Simple/app/src/main/java/com/hi/dhl/paging3/data/mapper/Person2PersonEntityMapper.kt: -------------------------------------------------------------------------------- 1 | package com.hi.dhl.paging3.data.mapper 2 | 3 | import com.hi.dhl.paging3.bean.Person 4 | import com.hi.dhl.paging3.data.local.PersonEntity 5 | 6 | /** 7 | *
8 | * author: dhl 9 | * date : 2020/6/16 10 | * desc : 数据映射, 上层用到的实体 Person ——> 数据库实体 PersonEntity 11 | *12 | */ 13 | class Person2PersonEntityMapper : Mapper
9 | * author: dhl 10 | * date : 2020/6/30 11 | * desc : 12 | *13 | */ 14 | 15 | interface GitHubService { 16 | @GET("users") 17 | suspend fun getGithubAccount(@Query("since") id: Int, @Query("per_page") perPage: Int): 18 | List
9 | * author: dhl 10 | * date : 2020/6/26 11 | * desc : 12 | *13 | */ 14 | class RemoteDataSource : DataSource { 15 | val mData = ArrayMap
9 | * author: dhl 10 | * date : 2020/6/30 11 | * desc : 12 | *13 | */ 14 | class RemoteDataSource : DataSource { 15 | val mData = ArrayMap
10 | * author: dhl 11 | * date : 2020/8/6 12 | * desc : 13 | *14 | */ 15 | class Utils @Inject constructor(){ 16 | // 使用 @Inject 注解从组件中获取依赖 17 | @Inject 18 | lateinit var personDao: PersonDao 19 | fun println(){ 20 | personDao.insert(PersonEntity(name = "dhl", updateTime = System.currentTimeMillis())) 21 | } 22 | } -------------------------------------------------------------------------------- /HiltWithAppStartupSimple/app/src/main/java/com/hi/dhl/hilt/appstartup/data/WorkServiceImpl.kt: -------------------------------------------------------------------------------- 1 | package com.hi.dhl.hilt.appstartup.data 2 | 3 | import android.util.Log 4 | import javax.inject.Inject 5 | 6 | /** 7 | *
8 | * author: dhl 9 | * date : 2020/6/26 10 | * desc : 11 | *12 | */ 13 | 14 | /** 15 | * 注入构造函数,因为Hilt需要知道如何提供 WorkServiceImpl 的实例 16 | */ 17 | class WorkServiceImpl @Inject constructor() : 18 | WorkService { 19 | 20 | override fun init() { 21 | Log.e(TAG, " I am an WorkServiceImpl") 22 | } 23 | 24 | companion object { 25 | private val TAG = "WorkServiceImpl" 26 | } 27 | } -------------------------------------------------------------------------------- /Paging3Simple/app/src/main/java/com/hi/dhl/paging3/data/local/PersonDao.kt: -------------------------------------------------------------------------------- 1 | package com.hi.dhl.paging3.data.local 2 | 3 | import androidx.paging.PagingSource 4 | import androidx.room.* 5 | 6 | /** 7 | *
8 | * author: dhl 9 | * date : 2020/6/16 10 | * desc : 11 | *12 | */ 13 | 14 | @Dao 15 | interface PersonDao { 16 | 17 | @Query("SELECT * FROM PersonEntity order by updateTime desc") 18 | fun queryAllData(): PagingSource
8 | * author: dhl 9 | * date : 2020/6/26 10 | * desc : 11 | *12 | */ 13 | class TasksRepository @Inject constructor( 14 | private val localDataSource: DataSource, 15 | private val remoteDataSource: DataSource 16 | ) : Repository { 17 | override fun updateData(person: PersonEntity) { 18 | AppExecutors.disIO { 19 | localDataSource.saveTask(person) 20 | remoteDataSource.saveTask(person) 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /HiltSimple/app/src/main/java/com/hi/dhl/hilt/ui/AppExecutors.kt: -------------------------------------------------------------------------------- 1 | package com.hi.dhl.hilt.ui 2 | 3 | import org.jetbrains.anko.doAsync 4 | import org.jetbrains.anko.uiThread 5 | 6 | /** 7 | *
8 | * author: dhl 9 | * date : 2020/6/24 10 | * desc : 11 | *12 | */ 13 | 14 | 15 | object AppExecutors{ 16 | 17 | fun disIO(disk:() -> Unit){ 18 | doAsync { 19 | disk() 20 | } 21 | } 22 | 23 | fun networkIO(network:()->Unit){ 24 | doAsync { 25 | network() 26 | } 27 | } 28 | 29 | fun mainThread(io:()->Unit,main:()->Unit){ 30 | doAsync { 31 | io() 32 | uiThread { 33 | main() 34 | } 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /Paging3Simple/app/src/main/java/com/hi/dhl/paging3/data/AppExecutors.kt: -------------------------------------------------------------------------------- 1 | package com.hi.dhl.paging3.data 2 | 3 | import org.jetbrains.anko.doAsync 4 | import org.jetbrains.anko.uiThread 5 | 6 | /** 7 | *
8 | * author: dhl 9 | * date : 2020/6/16 10 | * desc : 11 | *12 | */ 13 | 14 | 15 | object AppExecutors{ 16 | 17 | fun disIO(disk:() -> Unit){ 18 | doAsync { 19 | disk() 20 | } 21 | } 22 | 23 | fun networkIO(network:()->Unit){ 24 | doAsync { 25 | network() 26 | } 27 | } 28 | 29 | fun mainThread(io:()->Unit,main:()->Unit){ 30 | doAsync { 31 | io() 32 | uiThread { 33 | main() 34 | } 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /Paging3SimpleWithNetWork/app/src/main/java/com/hi/dhl/paging3/network/App.kt: -------------------------------------------------------------------------------- 1 | package com.hi.dhl.paging3.network 2 | 3 | import android.app.Application 4 | import com.hi.dhl.paging3.network.di.appModule 5 | import org.koin.android.ext.koin.androidContext 6 | import org.koin.android.logger.AndroidLogger 7 | import org.koin.core.context.startKoin 8 | import org.koin.core.logger.Level 9 | 10 | /** 11 | *
12 | * author: dhl 13 | * date : 2020/6/20 14 | * desc : 15 | *16 | */ 17 | class App : Application() { 18 | 19 | 20 | override fun onCreate() { 21 | super.onCreate() 22 | startKoin { 23 | AndroidLogger(Level.DEBUG) 24 | androidContext(this@App) 25 | modules(appModule) 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /Paging3Simple/app/src/main/java/com/hi/dhl/paging3/bean/Person.kt: -------------------------------------------------------------------------------- 1 | package com.hi.dhl.paging3.bean 2 | 3 | import androidx.recyclerview.widget.DiffUtil 4 | import java.util.jar.Attributes 5 | 6 | /** 7 | *
8 | * author: dhl 9 | * date : 2020/6/16 10 | * desc : 11 | *12 | */ 13 | data class Person(val id: Int, val name: String, val updateTime: Long) { 14 | companion object { 15 | 16 | val diffCallback = object : DiffUtil.ItemCallback
8 | * author: dhl 9 | * date : 2020/6/20 10 | * desc : 11 | *12 | */ 13 | 14 | 15 | object AppExecutors{ 16 | 17 | fun disIO(disk:() -> Unit){ 18 | doAsync { 19 | disk() 20 | } 21 | } 22 | 23 | fun networkIO(network:()->Unit){ 24 | doAsync { 25 | network() 26 | } 27 | } 28 | 29 | fun mainThread(io:()->Unit,main:()->Unit){ 30 | doAsync { 31 | io() 32 | uiThread { 33 | main() 34 | } 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /HiltWithAppStartupSimple/app/src/main/java/com/hi/dhl/hilt/appstartup/data/AppExecutors.kt: -------------------------------------------------------------------------------- 1 | package com.hi.dhl.hilt.appstartup.data 2 | 3 | import org.jetbrains.anko.doAsync 4 | import org.jetbrains.anko.uiThread 5 | 6 | /** 7 | *
8 | * author: dhl 9 | * date : 2020/6/24 10 | * desc : 11 | *12 | */ 13 | 14 | 15 | object AppExecutors { 16 | 17 | fun disIO(disk: () -> Unit) { 18 | doAsync { 19 | disk() 20 | } 21 | } 22 | 23 | fun networkIO(network: () -> Unit) { 24 | doAsync { 25 | network() 26 | } 27 | } 28 | 29 | fun mainThread(io: () -> Unit, main: () -> Unit) { 30 | doAsync { 31 | io() 32 | uiThread { 33 | main() 34 | } 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /HiltSimple/app/src/androidTest/java/com/hi/dhl/hilt/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package com.hi.dhl.hilt 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.hi.dhl.hilt", appContext.packageName) 23 | } 24 | } -------------------------------------------------------------------------------- /HiltWithMultiModuleSimple/feature-task/src/main/java/com/hi/dhl/hilt/hilt/feature/task/AppExecutors.kt: -------------------------------------------------------------------------------- 1 | package com.hi.dhl.hilt.hilt.feature.task 2 | 3 | import org.jetbrains.anko.doAsync 4 | import org.jetbrains.anko.uiThread 5 | 6 | /** 7 | *
8 | * author: dhl 9 | * date : 2020/6/30 10 | * desc : 11 | *12 | */ 13 | 14 | 15 | object AppExecutors { 16 | 17 | fun disIO(disk: () -> Unit) { 18 | doAsync { 19 | disk() 20 | } 21 | } 22 | 23 | fun networkIO(network: () -> Unit) { 24 | doAsync { 25 | network() 26 | } 27 | } 28 | 29 | fun mainThread(io: () -> Unit, main: () -> Unit) { 30 | doAsync { 31 | io() 32 | uiThread { 33 | main() 34 | } 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /Paging3Simple/app/src/androidTest/java/com/hi/dhl/paging3/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package com.hi.dhl.paging3 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.hi.dhl.paging3", appContext.packageName) 23 | } 24 | } -------------------------------------------------------------------------------- /AppStartupSimple/Startup-Library/src/main/java/com/hi/dhl/startup/library/LibaryA.kt: -------------------------------------------------------------------------------- 1 | package com.hi.dhl.startup.library 2 | 3 | import android.content.Context 4 | import android.util.Log 5 | import androidx.startup.Initializer 6 | 7 | /** 8 | *
9 | * author: dhl 10 | * date : 2020/6/13 11 | * desc : 12 | *13 | */ 14 | class LibaryA : Initializer
14 | * author: dhl 15 | * date : 2020/6/16 16 | * desc : 17 | *18 | */ 19 | class App : Application() { 20 | 21 | 22 | override fun onCreate() { 23 | super.onCreate() 24 | startKoin { 25 | AndroidLogger(Level.DEBUG) 26 | androidContext(this@App) 27 | modules(appModule) 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /HiltSimple/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile -------------------------------------------------------------------------------- /HiltWithAppStartupSimple/app/src/main/java/com/hi/dhl/hilt/appstartup/HiltApplication.kt: -------------------------------------------------------------------------------- 1 | package com.hi.dhl.hilt 2 | 3 | import android.app.Application 4 | import dagger.hilt.android.HiltAndroidApp 5 | 6 | /** 7 | *
8 | * author: dhl 9 | * date : 2020/6/24 10 | * desc : 11 | *12 | */ 13 | 14 | @HiltAndroidApp 15 | class HiltApplication : Application() { 16 | /** 17 | * 1. 所有使用 Hilt 的 App 必须包含一个使用 @HiltAndroidApp 注解的 Application 18 | * 2. @HiltAndroidApp 将会触发 Hilt 代码的生成,包括用作应用程序依赖项容器的基类 19 | * 3. 生成的 Hilt 组件依附于 Application 的生命周期,它也是 App 的父组件,提供其他组件访问的依赖 20 | * 4. 在 Application 中设置好 @HiltAndroidApp 之后,就可以使用 Hilt 提供的组件了, 21 | * Hilt 提供的 @AndroidEntryPoint 注解用于提供 Android 类的依赖(Activity、Fragment、View、Service、BroadcastReceiver)等等 22 | * Application 使用 @HiltAndroidApp 注解 23 | */ 24 | 25 | } -------------------------------------------------------------------------------- /HiltWithAppStartupSimple/app/src/main/java/com/hi/dhl/hilt/appstartup/init/AppInitializer.kt: -------------------------------------------------------------------------------- 1 | package com.hi.dhl.hilt.appstartup.init 2 | 3 | import android.content.Context 4 | import android.util.Log 5 | import androidx.startup.Initializer 6 | 7 | /** 8 | *
9 | * author: dhl 10 | * date : 2020/6/25 11 | * desc : 12 | *13 | */ 14 | 15 | class AppInitializer : Initializer
11 | * author: dhl 12 | * date : 2020/6/20 13 | * desc : 14 | *15 | */ 16 | 17 | val viewModele = module { 18 | viewModel { MainViewModel(get()) } 19 | } 20 | 21 | val repoModule = module { 22 | single { RepositoryFactory(get()).makeGutHubRepository() } 23 | } 24 | 25 | val remodeModule = module { 26 | single { GitHubService.create() } 27 | } 28 | 29 | val appModule = listOf(viewModele, repoModule, remodeModule) -------------------------------------------------------------------------------- /Splashscreen/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile -------------------------------------------------------------------------------- /AppStartupSimple/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile -------------------------------------------------------------------------------- /DataStoreSimple/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile -------------------------------------------------------------------------------- /AppStartupSimple/Startup-Library/src/main/java/com/hi/dhl/startup/library/LibaryB.kt: -------------------------------------------------------------------------------- 1 | package com.hi.dhl.startup.library 2 | 3 | import android.content.Context 4 | import android.util.Log 5 | import androidx.startup.Initializer 6 | 7 | /** 8 | *
9 | * author: dhl 10 | * date : 2020/6/13 11 | * desc : 12 | *13 | */ 14 | class LibaryB : Initializer
9 | * author: dhl 10 | * date : 2020/6/13 11 | * desc : 12 | *13 | */ 14 | class LibaryC : Initializer
8 | * author: dhl 9 | * date : 2020/6/30 10 | * desc : 11 | *12 | */ 13 | 14 | @HiltAndroidApp 15 | class HiltApplication : Application() { 16 | /** 17 | * 1. 所有使用 Hilt 的 App 必须包含一个使用 @HiltAndroidApp 注解的 Application 18 | * 2. @HiltAndroidApp 将会触发 Hilt 代码的生成,包括用作应用程序依赖项容器的基类 19 | * 3. 生成的 Hilt 组件依附于 Application 的生命周期,它也是 App 的父组件,提供其他组件访问的依赖 20 | * 4. 在 Application 中设置好 @HiltAndroidApp 之后,就可以使用 Hilt 提供的组件了, 21 | * Hilt 提供的 @AndroidEntryPoint 注解用于提供 Android 类的依赖(Activity、Fragment、View、Service、BroadcastReceiver)等等 22 | * Application 使用 @HiltAndroidApp 注解 23 | */ 24 | 25 | } -------------------------------------------------------------------------------- /Paging3SimpleWithNetWork/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile -------------------------------------------------------------------------------- /Paging3SimpleWithNetWork/app/src/androidTest/java/com/hi/dhl/paging3/network/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package com.hi.dhl.paging3.network 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.hi.dhl.paging3.network", appContext.packageName) 23 | } 24 | } -------------------------------------------------------------------------------- /AppStartupSimple/ContentProvider/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 -------------------------------------------------------------------------------- /AppStartupSimple/Startup-Library/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 -------------------------------------------------------------------------------- /HiltWithMultiModuleSimple/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile -------------------------------------------------------------------------------- /HiltWithMultiModuleSimple/app/src/androidTest/java/com/hi/dhl/hilt/hilt/module/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package com.hi.dhl.hilt.hilt.module 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.hi.dhl.hilt.hilt.module", appContext.packageName) 23 | } 24 | } -------------------------------------------------------------------------------- /AppStartupSimple/Startup-Library/src/androidTest/java/com/hi/dhl/startup/library/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package com.hi.dhl.startup.library 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.hi.dhl.startup.library.test", appContext.packageName) 23 | } 24 | } -------------------------------------------------------------------------------- /HiltWithMultiModuleSimple/common-core/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile -------------------------------------------------------------------------------- /HiltWithMultiModuleSimple/feature-task/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 -------------------------------------------------------------------------------- /Paging3Simple/app/src/main/java/com/hi/dhl/paging3/di/AppModule.kt: -------------------------------------------------------------------------------- 1 | package com.hi.dhl.paging3.di 2 | 3 | import com.hi.dhl.paging3.data.RepositoryFactory 4 | import com.hi.dhl.paging3.data.local.AppDataBase 5 | import com.hi.dhl.paging3.ui.MainViewModel 6 | import org.koin.android.ext.koin.androidApplication 7 | import org.koin.androidx.viewmodel.dsl.viewModel 8 | import org.koin.dsl.module 9 | 10 | /** 11 | *
12 | * author: dhl 13 | * date : 2020/6/16 14 | * desc : 15 | *16 | */ 17 | 18 | val viewModele = module { 19 | viewModel { MainViewModel(get()) } 20 | } 21 | 22 | val localModule = module { 23 | single { AppDataBase.initDataBase(androidApplication()) } 24 | } 25 | 26 | val repoModule = module { 27 | single { RepositoryFactory(get()).makeLocalRepository() } 28 | } 29 | 30 | val appModule = listOf(viewModele, localModule, repoModule) -------------------------------------------------------------------------------- /HiltWithMultiModuleSimple/app/src/main/java/com/hi/dhl/hilt/hilt/module/HiltViewModel.kt: -------------------------------------------------------------------------------- 1 | package com.hi.dhl.hilt.hilt.module 2 | 3 | import androidx.hilt.Assisted 4 | import androidx.hilt.lifecycle.ViewModelInject 5 | import androidx.lifecycle.SavedStateHandle 6 | import androidx.lifecycle.ViewModel 7 | import com.hi.dhl.hilt.hilt.feature.task.Repository 8 | 9 | /** 10 | *
11 | * author: dhl 12 | * date : 2020/6/30 13 | * desc : 14 | *15 | */ 16 | class HiltViewModel @ViewModelInject constructor( 17 | private val tasksRepository: Repository, 18 | //SavedStateHandle 用于进程被终止时,存储和恢复数据 19 | @Assisted private val savedStateHandle: SavedStateHandle 20 | ) : ViewModel() { 21 | 22 | fun insert() { 23 | tasksRepository.updateData("dhl") 24 | } 25 | 26 | companion object { 27 | private val USER_KEY = "userId" 28 | } 29 | } -------------------------------------------------------------------------------- /Paging3SimpleWithNetWork/app/src/main/java/com/hi/dhl/paging3/network/ui/MainViewModel.kt: -------------------------------------------------------------------------------- 1 | package com.hi.dhl.paging3.network.ui 2 | 3 | import androidx.lifecycle.LiveData 4 | import androidx.lifecycle.ViewModel 5 | import androidx.lifecycle.asLiveData 6 | import androidx.paging.PagingData 7 | import com.hi.dhl.paging3.network.bean.GitHubAccount 8 | import com.hi.dhl.paging3.network.data.repository.Repository 9 | 10 | /** 11 | *
12 | * author: dhl 13 | * date : 2020/6/20 14 | * desc : 15 | *16 | */ 17 | class MainViewModel(val repository: Repository) : 18 | ViewModel() { 19 | 20 | 21 | /** 22 | * 我们使用的是 Flow,调用 Flow 的 asLiveData 方法转为 LiveData 23 | */ 24 | val gitHubLiveData: LiveData
10 | * author: dhl 11 | * date : 2020/6/16 12 | * desc : DataBindingViewHolder 是基于 DataBinding 封装的 ViewHolder, 13 | * 更多信息可以查看 @see 14 | *15 | */ 16 | 17 | 18 | class PersonViewHolder(view: View) : DataBindingViewHolder
5 | * author: dhl 6 | * date : 2020/6/24 7 | * desc : 8 | *9 | */ 10 | data class GithubAccountModel( 11 | var login: String? = null, 12 | var id: Int = 0, 13 | var node_id: String? = null, 14 | var avatar_url: String? = null, 15 | var gravatar_id: String? = null, 16 | var url: String? = null, 17 | var html_url: String? = null, 18 | var followers_url: String? = null, 19 | var following_url: String? = null, 20 | var gists_url: String? = null, 21 | var starred_url: String? = null, 22 | var subscriptions_url: String? = null, 23 | var organizations_url: String? = null, 24 | var repos_url: String? = null, 25 | var events_url: String? = null, 26 | var received_events_url: String? = null, 27 | var type: String? = null, 28 | var isSite_admin: Boolean = false 29 | ) -------------------------------------------------------------------------------- /Paging3Simple/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | buildscript { 3 | ext.kotlin_version = "1.4.21" 4 | repositories { 5 | google() 6 | jcenter() 7 | } 8 | dependencies { 9 | classpath "com.android.tools.build:gradle:4.1.1" 10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 11 | 12 | // NOTE: Do not place your application dependencies here; they belong 13 | // in the individual module build.gradle files 14 | } 15 | } 16 | 17 | 18 | /** 19 | * plugins {} 默认的行为是解析和应用插件 20 | * apply false 告诉 Gradle 不要应用插件 21 | * 在多项目构建中,可以通过 subprojects{} 应用在子项目中 22 | */ 23 | plugins { 24 | // 这个 id 就是在 versionPlugin 文件夹下 build.gradle 文件内定义的id 25 | id "com.hi.dhl.plugin" apply false 26 | } 27 | 28 | /** 29 | * 在多项目构建中,可以通过 subprojects{} 应用在子项目中,细节查看 subproject.gradle 30 | */ 31 | apply from: '../subproject.gradle' 32 | -------------------------------------------------------------------------------- /Paging3SimpleWithNetWork/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | buildscript { 3 | ext.kotlin_version = "1.4.21" 4 | repositories { 5 | google() 6 | jcenter() 7 | } 8 | dependencies { 9 | classpath "com.android.tools.build:gradle:4.1.1" 10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 11 | 12 | // NOTE: Do not place your application dependencies here; they belong 13 | // in the individual module build.gradle files 14 | } 15 | } 16 | 17 | 18 | /** 19 | * plugins {} 默认的行为是解析和应用插件 20 | * apply false 告诉 Gradle 不要应用插件 21 | * 在多项目构建中,可以通过 subprojects{} 应用在子项目中 22 | */ 23 | plugins { 24 | // 这个 id 就是在 versionPlugin 文件夹下 build.gradle 文件内定义的id 25 | id "com.hi.dhl.plugin" apply false 26 | } 27 | 28 | /** 29 | * 在多项目构建中,可以通过 subprojects{} 应用在子项目中,细节查看 subproject.gradle 30 | */ 31 | apply from: '../subproject.gradle' -------------------------------------------------------------------------------- /Paging3Simple/app/src/main/res/layout/recycie_item_person.xml: -------------------------------------------------------------------------------- 1 | 2 |
9 | * author: dhl 10 | * date : 2020/6/13 11 | * desc : 12 | *13 | */ 14 | class LibaryD : Initializer
5 | * author: dhl 6 | * date : 2020/6/24 7 | * desc : 8 | *9 | */ 10 | data class GithubAccountModel( 11 | var login: String? = null, 12 | var id: Int = 0, 13 | var node_id: String? = null, 14 | var avatar_url: String? = null, 15 | var gravatar_id: String? = null, 16 | var url: String? = null, 17 | var html_url: String? = null, 18 | var followers_url: String? = null, 19 | var following_url: String? = null, 20 | var gists_url: String? = null, 21 | var starred_url: String? = null, 22 | var subscriptions_url: String? = null, 23 | var organizations_url: String? = null, 24 | var repos_url: String? = null, 25 | var events_url: String? = null, 26 | var received_events_url: String? = null, 27 | var type: String? = null, 28 | var isSite_admin: Boolean = false 29 | ) -------------------------------------------------------------------------------- /Paging3SimpleWithNetWork/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 |
5 | * author: dhl 6 | * date : 2020/6/20 7 | * desc : 8 | *9 | */ 10 | data class GithubAccountModel( 11 | var login: String? = null, 12 | var id: Int = 0, 13 | var node_id: String? = null, 14 | var avatar_url: String? = null, 15 | var gravatar_id: String? = null, 16 | var url: String? = null, 17 | var html_url: String? = null, 18 | var followers_url: String? = null, 19 | var following_url: String? = null, 20 | var gists_url: String? = null, 21 | var starred_url: String? = null, 22 | var subscriptions_url: String? = null, 23 | var organizations_url: String? = null, 24 | var repos_url: String? = null, 25 | var events_url: String? = null, 26 | var received_events_url: String? = null, 27 | var type: String? = null, 28 | var isSite_admin: Boolean = false 29 | ) -------------------------------------------------------------------------------- /HiltWithMultiModuleSimple/common-core/src/main/java/com/hi/dhl/hilt/hilt/common/core/remote/GithubAccountModel.kt: -------------------------------------------------------------------------------- 1 | package com.hi.dhl.hilt.hilt.common.core.remote 2 | 3 | /** 4 | *
5 | * author: dhl 6 | * date : 2020/6/30 7 | * desc : 8 | *9 | */ 10 | data class GithubAccountModel( 11 | var login: String? = null, 12 | var id: Int = 0, 13 | var node_id: String? = null, 14 | var avatar_url: String? = null, 15 | var gravatar_id: String? = null, 16 | var url: String? = null, 17 | var html_url: String? = null, 18 | var followers_url: String? = null, 19 | var following_url: String? = null, 20 | var gists_url: String? = null, 21 | var starred_url: String? = null, 22 | var subscriptions_url: String? = null, 23 | var organizations_url: String? = null, 24 | var repos_url: String? = null, 25 | var events_url: String? = null, 26 | var received_events_url: String? = null, 27 | var type: String? = null, 28 | var isSite_admin: Boolean = false 29 | ) -------------------------------------------------------------------------------- /VersionPlugin/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | jcenter() 4 | } 5 | dependencies { 6 | // 因为使用的 Kotlin 需要需要添加 Kotlin 插件 7 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.72" 8 | } 9 | } 10 | 11 | apply plugin: 'kotlin' 12 | apply plugin: 'java-gradle-plugin' 13 | 14 | repositories { 15 | // 需要添加 jcenter 否则会提示找不到 gradlePlugin 16 | jcenter() 17 | } 18 | 19 | dependencies { 20 | implementation gradleApi() 21 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.72" 22 | 23 | } 24 | 25 | compileKotlin { 26 | kotlinOptions { 27 | jvmTarget = "1.8" 28 | } 29 | } 30 | compileTestKotlin { 31 | kotlinOptions { 32 | jvmTarget = "1.8" 33 | } 34 | } 35 | 36 | gradlePlugin { 37 | plugins { 38 | version { 39 | // 在 app 模块需要通过 id 引用这个插件 40 | id = 'com.hi.dhl.plugin' 41 | // 实现这个插件的类的路径 42 | implementationClass = 'com.hi.dhl.plugin.VersionPlugin' 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /HiltWithAppStartupSimple/app/src/main/java/com/hi/dhl/hilt/appstartup/di/WorkServiceModule.kt: -------------------------------------------------------------------------------- 1 | package com.hi.dhl.hilt.appstartup.di 2 | 3 | import com.hi.dhl.hilt.appstartup.data.WorkService 4 | import com.hi.dhl.hilt.appstartup.data.WorkServiceImpl 5 | import dagger.Binds 6 | import dagger.Module 7 | import dagger.hilt.InstallIn 8 | import dagger.hilt.android.components.ApplicationComponent 9 | 10 | /** 11 | *
12 | * author: dhl 13 | * date : 2020/6/26 14 | * desc : 15 | *16 | */ 17 | 18 | @Module 19 | @InstallIn(ApplicationComponent::class) 20 | // 这里使用了 ActivityComponent,因此 WorkServiceModule 绑定到 ActivityComponent 的生命周期。 21 | abstract class WorkServiceModule { 22 | 23 | /** 24 | * @Binds 注解告诉 Hilt 需要提供接口实例时使用哪个实现 25 | * 26 | * bindAnalyticsService 函数需要为 Hilt 提供了以下信息 27 | * 1. 函数返回类型告诉 Hilt 提供了哪个接口的实例 28 | * 2. 函数参数告诉 Hilt 提供哪个实现 29 | */ 30 | @Binds 31 | abstract fun bindAnalyticsService( 32 | workServiceImpl: WorkServiceImpl 33 | ): WorkService 34 | } -------------------------------------------------------------------------------- /HiltWithMultiModuleSimple/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | buildscript { 3 | ext.kotlin_version = "1.4.21" 4 | repositories { 5 | google() 6 | jcenter() 7 | } 8 | dependencies { 9 | classpath "com.android.tools.build:gradle:4.1.1" 10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 11 | classpath 'com.google.dagger:hilt-android-gradle-plugin:2.28-alpha' 12 | // NOTE: Do not place your application dependencies here; they belong 13 | // in the individual module build.gradle files 14 | } 15 | } 16 | 17 | /** 18 | * plugins {} 默认的行为是解析和应用插件 19 | * apply false 告诉 Gradle 不要应用插件 20 | * 在多项目构建中,可以通过 subprojects{} 应用在子项目中 21 | */ 22 | plugins { 23 | // 这个 id 就是在 versionPlugin 文件夹下 build.gradle 文件内定义的id 24 | id "com.hi.dhl.plugin" apply false 25 | } 26 | 27 | /** 28 | * 在多项目构建中,可以通过 subprojects{} 应用在子项目中,细节查看 subproject.gradle 29 | */ 30 | apply from: '../subproject.gradle' -------------------------------------------------------------------------------- /HiltWithAppStartupSimple/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | buildscript { 3 | ext.kotlin_version = "1.4.21" 4 | repositories { 5 | google() 6 | jcenter() 7 | } 8 | dependencies { 9 | classpath "com.android.tools.build:gradle:4.1.1" 10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 11 | classpath 'com.google.dagger:hilt-android-gradle-plugin:2.28-alpha' 12 | // NOTE: Do not place your application dependencies here; they belong 13 | // in the individual module build.gradle files 14 | } 15 | } 16 | 17 | 18 | /** 19 | * plugins {} 默认的行为是解析和应用插件 20 | * apply false 告诉 Gradle 不要应用插件 21 | * 在多项目构建中,可以通过 subprojects{} 应用在子项目中 22 | */ 23 | plugins { 24 | // 这个 id 就是在 versionPlugin 文件夹下 build.gradle 文件内定义的id 25 | id "com.hi.dhl.plugin" apply false 26 | } 27 | 28 | /** 29 | * 在多项目构建中,可以通过 subprojects{} 应用在子项目中,细节查看 subproject.gradle 30 | */ 31 | apply from: '../subproject.gradle' -------------------------------------------------------------------------------- /DataStoreSimple/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | buildscript { 3 | ext.kotlin_version = "1.4.21" 4 | repositories { 5 | google() 6 | jcenter() 7 | } 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:4.1.1' 10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 11 | classpath 'com.google.dagger:hilt-android-gradle-plugin:2.29.1-alpha' 12 | // NOTE: Do not place your application dependencies here; they belong 13 | // in the individual module build.gradle files 14 | } 15 | } 16 | 17 | 18 | /** 19 | * plugins {} 默认的行为是解析和应用插件 20 | * apply false 告诉 Gradle 不要应用插件 21 | * 在多项目构建中,可以通过 subprojects{} 应用在子项目中 22 | */ 23 | plugins { 24 | // 这个 id 就是在 versionPlugin 文件夹下 build.gradle 文件内定义的id 25 | id "com.hi.dhl.plugin" apply false 26 | } 27 | 28 | /** 29 | * 在多项目构建中,可以通过 subprojects{} 应用在子项目中,细节查看 subproject.gradle 30 | */ 31 | apply from: '../subproject.gradle' 32 | 33 | -------------------------------------------------------------------------------- /HiltWithMultiModuleSimple/feature-task/src/main/java/com/hi/dhl/hilt/hilt/feature/task/TasksRepository.kt: -------------------------------------------------------------------------------- 1 | package com.hi.dhl.hilt.hilt.feature.task 2 | 3 | import com.hi.dhl.hilt.hilt.common.core.DataSource 4 | import com.hi.dhl.hilt.hilt.common.core.local.PersonEntity 5 | import com.hi.dhl.hilt.hilt.feature.task.AppExecutors 6 | import com.hi.dhl.hilt.hilt.feature.task.Repository 7 | import javax.inject.Inject 8 | 9 | /** 10 | *
11 | * author: dhl 12 | * date : 2020/6/30 13 | * desc : 14 | *15 | */ 16 | class TasksRepository @Inject constructor( 17 | private val localDataSource: DataSource, 18 | private val remoteDataSource: DataSource 19 | ) : Repository { 20 | override fun updateData(name: String) { 21 | AppExecutors.disIO { 22 | val person = PersonEntity( 23 | name = "dhl", 24 | updateTime = System.currentTimeMillis() 25 | ) 26 | localDataSource.saveTask(person) 27 | remoteDataSource.saveTask(person) 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /HiltWithMultiModuleSimple/app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 |
12 | * author: dhl 13 | * date : 2020/6/25 14 | * desc : 15 | *16 | */ 17 | 18 | @EntryPoint 19 | @InstallIn(ApplicationComponent::class) 20 | interface InitializerEntryPoint { 21 | 22 | fun injectWorkService(): WorkService 23 | 24 | companion object { 25 | fun resolve(context: Context): InitializerEntryPoint { 26 | 27 | val appContext = context.applicationContext ?: throw IllegalStateException() 28 | return EntryPointAccessors.fromApplication( 29 | appContext, 30 | InitializerEntryPoint::class.java 31 | ) 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /HiltSimple/app/src/main/java/com/hi/dhl/hilt/HiltApplication.kt: -------------------------------------------------------------------------------- 1 | package com.hi.dhl.hilt 2 | 3 | import android.app.Application 4 | import com.hi.dhl.hilt.di.HiltSimple 5 | import dagger.hilt.android.HiltAndroidApp 6 | import javax.inject.Inject 7 | 8 | /** 9 | *
10 | * author: dhl 11 | * date : 2020/6/24 12 | * desc : 13 | *14 | */ 15 | 16 | @HiltAndroidApp 17 | class HiltApplication : Application() { 18 | /** 19 | * 1. 所有使用 Hilt 的 App 必须包含一个使用 @HiltAndroidApp 注解的 Application 20 | * 2. @HiltAndroidApp 将会触发 Hilt 代码的生成,包括用作应用程序依赖项容器的基类 21 | * 3. 生成的 Hilt 组件依附于 Application 的生命周期,它也是 App 的父组件,提供其他组件访问的依赖 22 | * 4. 在 Application 中设置好 @HiltAndroidApp 之后,就可以使用 Hilt 提供的组件了, 23 | * Hilt 提供的 @AndroidEntryPoint 注解用于提供 Android 类的依赖(Activity、Fragment、View、Service、BroadcastReceiver)等等 24 | * Application 使用 @HiltAndroidApp 注解 25 | */ 26 | 27 | @Inject 28 | lateinit var mHiltSimple: HiltSimple 29 | 30 | override fun onCreate() { 31 | super.onCreate() 32 | mHiltSimple.doSomething() 33 | } 34 | } -------------------------------------------------------------------------------- /AppStartupSimple/app/src/main/java/com/hi/dhl/startup/simple/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.hi.dhl.startup.simple 2 | 3 | import android.os.Bundle 4 | import androidx.appcompat.app.AppCompatActivity 5 | import androidx.startup.AppInitializer 6 | import com.hi.dhl.binding.viewbind 7 | import com.hi.dhl.startup.library.LibaryD 8 | import com.hi.dhl.startup.simple.databinding.ActivityMainBinding 9 | 10 | class MainActivity : AppCompatActivity() { 11 | val binding: ActivityMainBinding by viewbind() 12 | 13 | override fun onCreate(savedInstanceState: Bundle?) { 14 | super.onCreate(savedInstanceState) 15 | 16 | with(binding) { 17 | handView.setOnClickListener { 18 | AppInitializer.getInstance(applicationContext) 19 | .initializeComponent(LibaryD::class.java) 20 | 21 | if (LibaryD.Dependency.initializer) { 22 | tvTip.setText("手动初始化成功") 23 | } else { 24 | tvTip.setText("手动初始化失败") 25 | } 26 | } 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /DataStoreSimple/app/src/main/java/com/hi/dhl/datastore/data/SharedPreferencesRepository.kt: -------------------------------------------------------------------------------- 1 | package com.hi.dhl.datastore.data 2 | 3 | import android.content.Context 4 | import androidx.core.content.edit 5 | import kotlinx.coroutines.ExperimentalCoroutinesApi 6 | 7 | /** 8 | *
9 | * author: dhl 10 | * date : 2020/10/2 11 | * desc : 12 | * 13 | * SharedPreferences 文件存放目录: /data/data/<包名>/shared_prefs 14 | * hi-dhl 的公众号:ByteCode 15 | * 16 | *17 | */ 18 | @OptIn(ExperimentalCoroutinesApi::class) 19 | class SharedPreferencesRepository(context: Context) : IRepository { 20 | 21 | val sp = context.getSharedPreferences(PREFERENCE_NAME, Context.MODE_PRIVATE) 22 | 23 | override fun saveData(key: String) { 24 | sp.edit { 25 | val value = !readData(key) 26 | putBoolean(key, value) 27 | } 28 | } 29 | 30 | override fun readData(key: String): Boolean { 31 | return sp.getBoolean(key, false) 32 | } 33 | 34 | companion object { 35 | val PREFERENCE_NAME = "Preferences" 36 | } 37 | } -------------------------------------------------------------------------------- /AppStartupSimple/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | buildscript { 3 | ext.kotlin_version = "1.4.21" 4 | repositories { 5 | maven { url "https://maven.aliyun.com/repository/public" } 6 | maven { url 'https://maven.aliyun.com/repository/google' } 7 | google() 8 | jcenter() 9 | } 10 | dependencies { 11 | classpath "com.android.tools.build:gradle:4.1.1" 12 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 13 | // NOTE: Do not place your application dependencies here; they belong 14 | // in the individual module build.gradle files 15 | } 16 | } 17 | 18 | /** 19 | * plugins {} 默认的行为是解析和应用插件 20 | * apply false 告诉 Gradle 不要应用插件 21 | * 在多项目构建中,可以通过 subprojects{} 应用在子项目中 22 | */ 23 | plugins { 24 | // 这个 id 就是在 versionPlugin 文件夹下 build.gradle 文件内定义的id 25 | id "com.hi.dhl.plugin" apply false 26 | } 27 | 28 | /** 29 | * 在多项目构建中,可以通过 subprojects{} 应用在子项目中,细节查看 subproject.gradle 30 | */ 31 | apply from: '../subproject.gradle' 32 | 33 | -------------------------------------------------------------------------------- /Paging3SimpleWithNetWork/app/src/main/java/com/hi/dhl/paging3/network/data/remote/GitHubService.kt: -------------------------------------------------------------------------------- 1 | package com.hi.dhl.paging3.network.data.remote 2 | 3 | import okhttp3.OkHttpClient 4 | import retrofit2.Retrofit 5 | import retrofit2.converter.gson.GsonConverterFactory 6 | import retrofit2.http.GET 7 | import retrofit2.http.Query 8 | 9 | /** 10 | *
11 | * author: dhl 12 | * date : 2020/6/20 13 | * desc : 14 | *15 | */ 16 | interface GitHubService { 17 | 18 | @GET("users") 19 | suspend fun getGithubAccount(@Query("since") id: Int, @Query("per_page") perPage: Int): 20 | List
17 | * author: dhl 18 | * date : 2020/10/2 19 | * desc : 20 | *21 | */ 22 | 23 | @Module 24 | @InstallIn(ApplicationComponent::class) 25 | class RepositoryModule { 26 | 27 | @Provides 28 | @Singleton 29 | fun provideSharedPreferencesRepository(@ApplicationContext ctx: Context): IRepository { 30 | return SharedPreferencesRepository(ctx) 31 | } 32 | 33 | @Provides 34 | @Singleton 35 | fun provideDataStoreRepository(@ApplicationContext ctx: Context): IDataStoreRepository { 36 | return DataStoreRepository(ctx) 37 | } 38 | } -------------------------------------------------------------------------------- /HiltSimple/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 -------------------------------------------------------------------------------- /AppStartupSimple/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 -------------------------------------------------------------------------------- /DataStoreSimple/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 -------------------------------------------------------------------------------- /Paging3Simple/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 -------------------------------------------------------------------------------- /Paging3SimpleWithNetWork/app/src/main/java/com/hi/dhl/paging3/network/data/mapper/GitHub2ModelMapper.kt: -------------------------------------------------------------------------------- 1 | package com.hi.dhl.paging3.network.data.mapper 2 | 3 | import com.hi.dhl.paging3.network.bean.GitHubAccount 4 | import com.hi.dhl.paging3.network.data.remote.GithubAccountModel 5 | 6 | /** 7 | *
8 | * author: dhl 9 | * date : 2020/6/20 10 | * desc : 数据映射, 上层用到的实体 GithubAccount ——> 数据库实体 GithubAccountModel 11 | *12 | */ 13 | class GitHub2ModelMapper : Mapper
8 | * author: dhl 9 | * date : 2020/6/20 10 | * desc : 数据映射, 数据库实体 GithubAccountModel ——> 上层用到的实体 GithubAccount 11 | *12 | */ 13 | class Model2GitHubMapper : Mapper
14 | * author: dhl 15 | * date : 2020/6/20 16 | * desc : DataBindingViewHolder 是基于 DataBinding 封装的 ViewHolder, 17 | * 更多信息可以查看 @see 18 | *19 | */ 20 | 21 | 22 | class GitHubViewHolder(view: View) : DataBindingViewHolder
15 | * author: dhl 16 | * date : 2020/6/24 17 | * desc : 18 | *19 | */ 20 | @Module 21 | @InstallIn(ApplicationComponent::class) 22 | // 这里使用了 ApplicationComponent,因此 NetworkModule 绑定到 Application 的生命周期。 23 | object RoomModule { 24 | 25 | /** 26 | * @Provides 常用于被 @Module 注解标记类的内部的方法,并提供依赖项对象。 27 | * @Singleton 提供单例 28 | */ 29 | @Provides 30 | @Singleton 31 | fun provideAppDataBase(application: Application): AppDataBase { 32 | return Room 33 | .databaseBuilder(application, AppDataBase::class.java, "dhl.db") 34 | .fallbackToDestructiveMigration() 35 | .allowMainThreadQueries() 36 | .build() 37 | } 38 | 39 | @Provides 40 | @Singleton 41 | fun providePersonDao(appDatabase: AppDataBase): PersonDao { 42 | return appDatabase.personDao() 43 | } 44 | } -------------------------------------------------------------------------------- /AppStartupSimple/app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 |
14 | * author: dhl 15 | * date : 2020/6/20 16 | * desc : 17 | *18 | */ 19 | class FooterAdapter(val adapter: GitHubAdapter) : LoadStateAdapter
15 | * author: dhl 16 | * date : 2020/6/24 17 | * desc : 18 | *19 | */ 20 | 21 | @Module 22 | @InstallIn(ApplicationComponent::class) 23 | // 这里使用了 ApplicationComponent,因此 RoomModule 绑定到 Application 的生命周期。 24 | object RoomModule { 25 | 26 | /** 27 | * @Provides 常用于被 @Module 注解标记类的内部的方法,并提供依赖项对象。 28 | * @Singleton 提供单例 29 | */ 30 | @Provides 31 | @Singleton 32 | fun provideAppDataBase(application: Application): AppDataBase { 33 | return Room 34 | .databaseBuilder(application, AppDataBase::class.java, "dhl.db") 35 | .fallbackToDestructiveMigration() 36 | .allowMainThreadQueries() 37 | .build() 38 | } 39 | 40 | @Provides 41 | @Singleton 42 | fun providePersonDao(appDatabase: AppDataBase): PersonDao { 43 | return appDatabase.personDao() 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /HiltWithMultiModuleSimple/app/src/main/java/com/hi/dhl/hilt/hilt/module/di/RoomModule.kt: -------------------------------------------------------------------------------- 1 | package com.hi.dhl.hilt.hilt.module.di 2 | 3 | import android.app.Application 4 | import androidx.room.Room 5 | import com.hi.dhl.hilt.hilt.common.core.local.AppDataBase 6 | import com.hi.dhl.hilt.hilt.common.core.local.PersonDao 7 | import dagger.Module 8 | import dagger.Provides 9 | import dagger.hilt.InstallIn 10 | import dagger.hilt.android.components.ApplicationComponent 11 | import javax.inject.Singleton 12 | 13 | /** 14 | *
15 | * author: dhl 16 | * date : 2020/6/30 17 | * desc : 18 | *19 | */ 20 | 21 | @Module 22 | @InstallIn(ApplicationComponent::class) 23 | // 这里使用了 ApplicationComponent,因此 RoomModule 绑定到 Application 的生命周期。 24 | object RoomModule { 25 | 26 | /** 27 | * @Provides 常用于被 @Module 注解标记类的内部的方法,并提供依赖项对象。 28 | * @Singleton 提供单例 29 | */ 30 | @Provides 31 | @Singleton 32 | fun provideAppDataBase(application: Application): AppDataBase { 33 | return Room 34 | .databaseBuilder(application, AppDataBase::class.java, "dhl.db") 35 | .fallbackToDestructiveMigration() 36 | .allowMainThreadQueries() 37 | .build() 38 | } 39 | 40 | @Provides 41 | @Singleton 42 | fun providePersonDao(appDatabase: AppDataBase): PersonDao { 43 | return appDatabase.personDao() 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /AppStartupSimple/ContentProvider/src/main/java/com/hi/dhl/startup/contentprovider/WorkContentProvider.kt: -------------------------------------------------------------------------------- 1 | package com.hi.dhl.startup.contentprovider 2 | 3 | import android.content.ContentProvider 4 | import android.content.ContentValues 5 | import android.database.Cursor 6 | import android.net.Uri 7 | import android.util.Log 8 | 9 | /** 10 | *
11 | * author: dhl 12 | * date : 2020/6/13 13 | * desc : 14 | *15 | */ 16 | class WorkContentProvider : ContentProvider() { 17 | 18 | override fun onCreate(): Boolean { 19 | Log.d(TAG, "WorkContentProvider create()") 20 | return true 21 | } 22 | 23 | override fun insert(uri: Uri, values: ContentValues?): Uri? = null 24 | 25 | override fun query( 26 | uri: Uri, 27 | projection: Array
14 | * author: dhl 15 | * date : 2020/6/24 16 | * desc : 17 | *18 | */ 19 | @AndroidEntryPoint 20 | class HitAppCompatActivity : AppCompatActivity() { 21 | private val mHitViewModule: HiltViewModel by viewModels() 22 | private val binding: ActivityHiltBinding by viewbind() 23 | 24 | override fun onCreate(savedInstanceState: Bundle?) { 25 | super.onCreate(savedInstanceState) 26 | 27 | // 用到了 Fragment 1.2.0 中重要的更新 28 | // 可以查看之前写的这篇文章 @see https://juejin.im/post/5ecb16f1f265da76fb0c3967 29 | supportFragmentManager.beginTransaction() 30 | .add(R.id.container, HiltFragment::class.java, null) 31 | .commit() 32 | 33 | mHitViewModule.mHitLiveData.observe(this, Observer { 34 | binding.tvResult.setText(it) 35 | }) 36 | 37 | binding.btnArgument.setOnClickListener { 38 | mHitViewModule.passArgument("address : shanghai") 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /Paging3Simple/app/src/main/java/com/hi/dhl/paging3/ui/PersonAdapter.kt: -------------------------------------------------------------------------------- 1 | package com.hi.dhl.paging3.ui 2 | 3 | import android.view.LayoutInflater 4 | import android.view.View 5 | import android.view.ViewGroup 6 | import androidx.annotation.LayoutRes 7 | import androidx.paging.PagingDataAdapter 8 | import com.hi.dhl.jdatabinding.dowithTry 9 | import com.hi.dhl.paging3.R 10 | import com.hi.dhl.paging3.bean.Person 11 | 12 | /** 13 | *
14 | * author: dhl 15 | * date : 2020/6/16 16 | * desc : 不久会开发一个基于 databinding 封装的 PagingDataAdapter,只需要几行代码就可以解决 17 | *18 | */ 19 | 20 | class PersonAdapter : PagingDataAdapter
10 | * author: dhl 11 | * date : 2020/6/20 12 | * desc : 13 | *14 | */ 15 | class GitHubItemPagingSource( 16 | private val api: GitHubService 17 | ) : PagingSource
11 | * author: dhl 12 | * date : 2020/6/20 13 | * desc : 用到 koin 的依赖注入 , 上层不需要关心 Repository 和 Mapper,隐藏了 Repository 和 Mapper 显示的依赖关系 14 | *15 | */ 16 | 17 | class RepositoryFactory( 18 | val gitHubApi: GitHubService 19 | ) { 20 | 21 | // 传递 PagingConfig 和 Data Mapper 22 | fun makeGutHubRepository(): Repository = 23 | GitHubRepositoryImpl( 24 | pagingConfig, 25 | gitHubApi, Model2GitHubMapper() 26 | ) 27 | 28 | val pagingConfig = PagingConfig( 29 | // 每页显示的数据的大小 30 | pageSize = 30, 31 | 32 | // 开启占位符 33 | enablePlaceholders = false 34 | 35 | // 预刷新的距离,距离最后一个 item 多远时加载数据 36 | // prefetchDistance = 3, 37 | 38 | /** 39 | * 初始化加载数量,默认为 pageSize * 3 40 | * 41 | * internal const val DEFAULT_INITIAL_PAGE_MULTIPLIER = 3 42 | * val initialLoadSize: Int = pageSize * DEFAULT_INITIAL_PAGE_MULTIPLIER 43 | */ 44 | // initialLoadSize = 60 45 | ) 46 | 47 | } -------------------------------------------------------------------------------- /Paging3SimpleWithNetWork/app/src/main/java/com/hi/dhl/paging3/network/ui/GitHubAdapter.kt: -------------------------------------------------------------------------------- 1 | package com.hi.dhl.paging3.network.ui 2 | 3 | import android.view.LayoutInflater 4 | import android.view.View 5 | import android.view.ViewGroup 6 | import androidx.annotation.LayoutRes 7 | import androidx.paging.PagingDataAdapter 8 | import com.hi.dhl.jdatabinding.dowithTry 9 | import com.hi.dhl.paging3.network.R 10 | import com.hi.dhl.paging3.network.bean.GitHubAccount 11 | 12 | /** 13 | *
14 | * author: dhl 15 | * date : 2020/6/20 16 | * desc : 不久会开发一个基于 databinding 封装的 PagingDataAdapter,只需要几行代码就可以解决 17 | *18 | */ 19 | 20 | class GitHubAdapter : 21 | PagingDataAdapter
10 | * author: dhl 11 | * date : 2020/6/20 12 | * desc : 13 | *14 | */ 15 | class NetworkStateItemViewHolder(view: View, private val retryCallback: () -> Unit) : 16 | DataBindingViewHolder
13 | * author: dhl 14 | * date : 2020/6/24 15 | * desc : 16 | *17 | */ 18 | class HiltViewModel @ViewModelInject constructor( 19 | val personDao: PersonDao 20 | 21 | ) : ViewModel() { 22 | 23 | private val _mAdressLiveData = MutableLiveData
15 | * author: dhl 16 | * date : 2020/6/24 17 | * desc : 18 | *19 | */ 20 | 21 | @Module 22 | @InstallIn(ApplicationComponent::class) 23 | // 这里使用了 ApplicationComponent,因此 NetworkModule 绑定到 Application 的生命周期。 24 | object NetworkModule { 25 | 26 | /** 27 | * @Provides 常用于被 @Module 注解标记类的内部的方法,并提供依赖项对象。 28 | * @Singleton 提供单例 29 | */ 30 | @Provides 31 | @Singleton 32 | fun provideOkHttpClient(): OkHttpClient { 33 | return OkHttpClient.Builder() 34 | .build() 35 | } 36 | 37 | @Provides 38 | @Singleton 39 | fun provideRetrofit(okHttpClient: OkHttpClient): Retrofit { 40 | return Retrofit.Builder() 41 | .client(okHttpClient) 42 | .baseUrl("https://api.github.com/") 43 | .addConverterFactory(GsonConverterFactory.create()) 44 | .build() 45 | } 46 | 47 | @Provides 48 | @Singleton 49 | fun provideGitHubService(retrofit: Retrofit): GitHubService { 50 | return retrofit.create(GitHubService::class.java) 51 | } 52 | } -------------------------------------------------------------------------------- /HiltSimple/app/src/main/java/com/hi/dhl/hilt/ui/HiltFragment.kt: -------------------------------------------------------------------------------- 1 | package com.hi.dhl.hilt.ui 2 | 3 | import android.os.Bundle 4 | import android.view.View 5 | import androidx.fragment.app.Fragment 6 | import androidx.fragment.app.activityViewModels 7 | import androidx.lifecycle.Observer 8 | import com.hi.dhl.binding.viewbind 9 | import com.hi.dhl.hilt.R 10 | import com.hi.dhl.hilt.databinding.FragmentHiltBinding 11 | import com.hi.dhl.hilt.di.HiltSimple 12 | import dagger.hilt.android.AndroidEntryPoint 13 | import javax.inject.Inject 14 | 15 | /** 16 | *
17 | * author: dhl 18 | * date : 2020/6/24 19 | * desc : 20 | *21 | */ 22 | 23 | /** 24 | * 如果 注解 fragment 然后还必须注解 fragment 依赖的 Activity, 否则会抛出以下异常 25 | * java.lang.IllegalStateException: Hilt Fragments must be attached to an @AndroidEntryPoint Activity. Found: class com.hi.dhl.hilt.ui.MainActivity 26 | */ 27 | @AndroidEntryPoint 28 | class HiltFragment : Fragment(R.layout.fragment_hilt) { 29 | 30 | // 使用 @Inject 注解从组件中获取依赖 31 | @Inject 32 | lateinit var hiltSimple: HiltSimple 33 | 34 | private val hiltViewModel: HiltViewModel by activityViewModels() 35 | private val binding: FragmentHiltBinding by viewbind() 36 | 37 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) { 38 | super.onViewCreated(view, savedInstanceState) 39 | hiltSimple.doSomething() 40 | 41 | hiltViewModel.mAdressLiveData.observe(viewLifecycleOwner, Observer { 42 | binding.tvAddress.setText(it) 43 | }) 44 | } 45 | } -------------------------------------------------------------------------------- /HiltWithAppStartupSimple/app/src/main/java/com/hi/dhl/hilt/appstartup/init/WorkContentProvider.kt: -------------------------------------------------------------------------------- 1 | package com.hi.dhl.hilt.appstartup.init 2 | 3 | import android.content.ContentProvider 4 | import android.content.ContentValues 5 | import android.database.Cursor 6 | import android.net.Uri 7 | import android.util.Log 8 | 9 | /** 10 | *
11 | * author: dhl 12 | * date : 2020/6/26 13 | * desc : 14 | *15 | */ 16 | class WorkContentProvider : ContentProvider() { 17 | 18 | override fun onCreate(): Boolean { 19 | context?.run { 20 | val service = InitializerEntryPoint.resolve(this).injectWorkService() 21 | Log.e(TAG, "WorkContentProvider ${service.init()}") 22 | } 23 | return true 24 | } 25 | 26 | override fun insert(uri: Uri, values: ContentValues?): Uri? = null 27 | 28 | override fun query( 29 | uri: Uri, 30 | projection: Array
7 | * author: dhl 8 | * date : 2020/6/20 9 | * desc : 10 | *11 | */ 12 | data class GitHubAccount( 13 | var login: String? = null, 14 | var id: Int = 0, 15 | var node_id: String? = null, 16 | var avatar_url: String? = null, 17 | var gravatar_id: String? = null, 18 | var url: String? = null, 19 | var html_url: String? = null, 20 | var followers_url: String? = null, 21 | var following_url: String? = null, 22 | var gists_url: String? = null, 23 | var starred_url: String? = null, 24 | var subscriptions_url: String? = null, 25 | var organizations_url: String? = null, 26 | var repos_url: String? = null, 27 | var events_url: String? = null, 28 | var received_events_url: String? = null, 29 | var type: String? = null, 30 | var isSite_admin: Boolean = false 31 | ) { 32 | companion object { 33 | 34 | val diffCallback = object : DiffUtil.ItemCallback