From c6b5f46bd62d5aa79cb71f384924043e5f3fc935 Mon Sep 17 00:00:00 2001 From: Rene Dohan Date: Sat, 22 Jul 2023 00:13:50 +0200 Subject: [PATCH] ... --- .../android/event/registration/CSRegistrationsMap.kt | 7 ++++--- .../test/java/renetik/android/event/EventOwnerEventTest.kt | 7 +++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/library/src/main/java/renetik/android/event/registration/CSRegistrationsMap.kt b/library/src/main/java/renetik/android/event/registration/CSRegistrationsMap.kt index dd1dcdb..e361105 100644 --- a/library/src/main/java/renetik/android/event/registration/CSRegistrationsMap.kt +++ b/library/src/main/java/renetik/android/event/registration/CSRegistrationsMap.kt @@ -5,9 +5,10 @@ import renetik.android.core.java.lang.nanoTime import renetik.android.core.kotlin.collections.removeValue import renetik.android.core.lang.variable.CSVariable.Companion.variable import renetik.android.core.logging.CSLog.logWarnTrace +import renetik.android.event.common.CSHasDestruct class CSRegistrationsMap( - private val parent: Any, + private val parent: CSHasDestruct, ) : CSRegistrations, CSHasRegistrations { override val registrations: CSRegistrationsMap = this @@ -17,10 +18,10 @@ class CSRegistrationsMap( private set @get:Synchronized - override var isCanceled: Boolean = false + override var isCanceled: Boolean = parent.isDestructed private set - private val registrationMap: MutableMap = mutableMapOf() + private val registrationMap: MutableMap by lazy(::mutableMapOf) private var idCount: Int = 0 private fun createUniqueId() = "$idCount: $nanoTime".also { idCount++ } diff --git a/library/src/test/java/renetik/android/event/EventOwnerEventTest.kt b/library/src/test/java/renetik/android/event/EventOwnerEventTest.kt index a885bf7..74903aa 100644 --- a/library/src/test/java/renetik/android/event/EventOwnerEventTest.kt +++ b/library/src/test/java/renetik/android/event/EventOwnerEventTest.kt @@ -3,6 +3,8 @@ package renetik.android.event import org.junit.Assert.assertEquals import org.junit.Before import org.junit.Test +import org.junit.runner.RunWith +import org.robolectric.RobolectricTestRunner import renetik.android.core.logging.CSDummyLogger import renetik.android.core.logging.CSLog.init import renetik.android.event.CSEvent.Companion.event @@ -10,9 +12,7 @@ import renetik.android.event.common.CSModel import renetik.android.event.common.destruct import renetik.android.event.registration.register -/** - * Event unregister after owner nulled - */ +@RunWith(RobolectricTestRunner::class) class EventOwnerEventTest { @Before @@ -42,5 +42,4 @@ class EventOwnerEventTest { event.fire() assertEquals(0, count) } - }