diff --git a/kokain-di/src/main/java/com/schwarz/kokain/di/ActivityContextGuard.kt b/kokain-di/src/main/java/com/schwarz/kokain/di/ActivityContextGuard.kt index c0fe6f5..85e5b74 100644 --- a/kokain-di/src/main/java/com/schwarz/kokain/di/ActivityContextGuard.kt +++ b/kokain-di/src/main/java/com/schwarz/kokain/di/ActivityContextGuard.kt @@ -29,9 +29,11 @@ class ActivityContextGuard(applicationContext: Application) : LifecycleObserver private var currentRef: WeakReference = WeakReference(activity) init { - activity.lifecycle.addObserver(this) if(activity.lifecycle.currentState != Lifecycle.State.DESTROYED){ + activity.lifecycle.addObserver(this) map[reference] = this + }else{ + currentRef.clear() } }