This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//... | |
apply plugin: 'kotlin-kapt' | |
android { | |
//... | |
kotlinOptions { | |
jvmTarget = "1.8" | |
} | |
kapt { | |
correctErrorTypes true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RuntimeArg {} | |
@Singleton class A @Inject constructor() | |
@Singleton class B @Inject constructor(private val a: A) | |
@Singleton class C @Inject constructor(private val b: B) | |
class D @AssistedInject constructor( | |
private val a: A, | |
private val b: B, | |
private val c: C, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RuntimeArg {} | |
@Singleton class A @Inject constructor() | |
@Singleton class B @Inject constructor(private val a: A) | |
@Singleton class C @Inject constructor(private val b: B) | |
class D( | |
private val a: A, | |
private val b: B, | |
private val c: C, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// assisted injected worker | |
class ActualWorker @AssistedInject constructor( | |
private val someDependency: SomeDependency, | |
@Assisted appContext: Context, | |
@Assisted workerParams: WorkerParameters | |
) : ListenableWorker(appContext, workerParams) { | |
@AssistedInject.Factory | |
interface Factory : AssistedWorkerFactory<ActualWorker> | |
override fun startWork(): ListenableFuture<Result> { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private class LiveEvent<T> constructor( | |
private val eventSource: EventSource<T>, | |
private val lifecycleOwner: LifecycleOwner, | |
private val observer: EventSource.EventObserver<T> | |
) : LifecycleObserver { | |
init { | |
if (lifecycleOwner.lifecycle.currentState.isAtLeast(Lifecycle.State.INITIALIZED)) { | |
lifecycleOwner.lifecycle.addObserver(this) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Singleton | |
@Component(modules = [AssistedInjectionModule::class]) | |
interface ApplicationComponent { | |
fun mySavedStateViewModelFactory(): MySavedStateViewModel.Factory | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Singleton | |
@Component | |
class ApplicationComponent { | |
fun myViewModelProvider(): Provider<MyViewModel> | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Provide package of your application (com.example.myapp) | |
PACKAGE=$1 | |
# First, put your app to background and then run this script | |
echo "Killing $PACKAGE" | |
adb shell ps | grep $PACKAGE | awk '{print $2}' | xargs adb shell run-as $PACKAGE kill |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Provide package of your application (com.example.myapp) | |
PACKAGE=$1 | |
# First, put your app to background and then run this script | |
echo "Killing $PACKAGE" | |
adb shell ps | grep $PACKAGE | awk '{print $2}' | xargs adb shell run-as $PACKAGE kill |