Skip to content

Instantly share code, notes, and snippets.

@Target(AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER)
@Retention(value = RUNTIME)
@MapKey
internal annotation class FragmentKey(val value: KClass<out Fragment>)
@Module
abstract class NavHostModule {
@ContributesAndroidInjector(modules = [FragmentBindingModule::class])
abstract fun navHostFragmentInjector(): InjectingNavHostFragment
}
@Module
abstract class AppModule {
@Binds
abstract fun bindApplication(app: CustomApplication): Application
@ContributesAndroidInjector(modules = [NavHostModule::class])
abstract fun mainActivityInjector(): MainActivity
@Module
@Singleton
@Component(
modules = [
AndroidSupportInjectionModule::class,
AppModule::class
]
)
interface ApplicationComponent : AndroidInjector<CustomApplication> {
@Component.Builder
@zawadz88
zawadz88 / build.gradle
Created September 10, 2018 20:58
Main build.gradle after changes
apply plugin: 'com.android.application'
apply from: "${rootProject.projectDir}/flavors.gradle"
android {
// other config...
with flavorConfig
}
@zawadz88
zawadz88 / flavors.gradle
Last active September 11, 2018 07:42
Shared flavor config
ext.flavorConfig = { // 1
flavorDimensions "pricing"
productFlavors {
free {
dimension "pricing"
ext.myApplicationIdSuffix = '.free' // 2
}
paid {
dimension "pricing"
@zawadz88
zawadz88 / build.gradle
Created September 10, 2018 18:00
Library build.gradle
apply plugin: 'com.android.feature'
// apply plugin: 'com.android.library'
// Might be this ^ if you're not interested in Google Play Instant: https://stackoverflow.com/questions/44361335/why-use-the-new-android-feature-plugin-over-the-library-plugin
android {
// other config...
flavorDimensions "pricing"
productFlavors {
free {
@zawadz88
zawadz88 / build.gradle
Created September 10, 2018 18:00
Library build.gradle
apply plugin: 'com.android.feature'
// apply plugin: 'com.android.library'
// Might be this ^ if you're not interested in Google Play Instant: https://stackoverflow.com/questions/44361335/why-use-the-new-android-feature-plugin-over-the-library-plugin
android {
// other config...
flavorDimensions "pricing"
productFlavors {
free {
@zawadz88
zawadz88 / build.gradle
Created September 10, 2018 17:56
Installed app's build.gradle
apply plugin: 'com.android.application'
android {
// other config...
flavorDimensions "pricing"
productFlavors {
free {
dimension "pricing"
applicationIdSuffix = '.free'
abstract class BaseReactiveUseCase(threadExecutor: ThreadExecutor,
postExecutionThread: PostExecutionThread) {
protected val threadExecutorScheduler: Scheduler = Schedulers.from(threadExecutor)
protected val postExecutionThreadScheduler: Scheduler = postExecutionThread.scheduler
private val disposables = CompositeDisposable()
open fun dispose() {