Instant apps sample using dagger2 android support.
This sample uses Github API.
This application is flux-like architecture.
--------------
| base module |
--------------
/ \
/ \
/ \
------------------ ------------------
| feature module 1 | | feature module 2 |
------------------ ------------------
| \ |
| \____________ |
| \ |
---------------------- -------------
| Instant Apps module | | App module |
---------------------- -------------
- Define models
- API connection
- Common utilities
- Repository screen
- Repository List screen
- Pull Request List screen
- Issue List screen
- Start github repository
- [owner]
- [repository name]
https://aakira.github.com/[owner]/[repository name]
- e.g.
https://aakira.github.com/aakira/DaggerInstantApps
You should set your access token into /gradle.properties
.
You don't have to set it but github api has limitations of the number of times.
# Add your github token
gitHubToken = [YOUR ACCESS TOKEN]
- Access this link Github settings
- Generate new token
- Input new personal access token
- Enter your token into
gradle.properties
.
This class refers to DaggerApplication class.
You can use dagger android support even if each module is separated.
- Base/AppComponent
@Singleton
@Component(modules = [
AndroidSupportInjectionModule::class,
AppModule::class
])
interface AppComponent : AndroidInjector<App>, AppComponentProviders {
override fun inject(instance: App)
@Component.Builder
interface Builder {
@BindsInstance
fun application(application: Application): Builder
fun build(): AppComponent
}
}
- Feature/ModuleComponent
@PerModuleScope
@Component(
dependencies = [AppComponent::class],
modules = [
AndroidSupportInjectionModule::class,
FeatureOneUiBuilder::class,
FeatureOneModule::class
]
)
interface FeatureOneComponent : AndroidInjector<FeatureOneModuleInjector>
- Feature/ModuleInjector
@Module
abstract class FeatureOneUiBuilder {
@PerUiScope
@ContributesAndroidInjector(modules = [RepoModule::class])
internal abstract fun bindRepoActivity(): RepoActivity
}
- Feature/ModuleUiBuilder
@Module
abstract class FeatureOneUiBuilder {
@PerUiScope
@ContributesAndroidInjector(modules = [RepoModule::class])
internal abstract fun bindRepoActivity(): RepoActivity
}
- View
override fun onCreate(savedInstanceState: Bundle?) {
FeatureOneModuleInjector.inject(this)
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_repo)
}
Copyright (C) 2018 A.Akira
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.