Warning cleanup

This commit is contained in:
casey langen 2018-08-25 17:02:04 -07:00
parent 27a46cac19
commit 78f935c59f

View File

@ -32,7 +32,7 @@ import java.util.concurrent.atomic.AtomicLong
} }
open fun onDestroy() { open fun onDestroy() {
handler.postDelayed(cleanup, cleanupDelayMs) handler.postDelayed(cleanup, CLEANUP_DELAY_MS)
} }
open fun onCleanup() { open fun onCleanup() {
@ -45,7 +45,7 @@ import java.util.concurrent.atomic.AtomicLong
.subscribeOn(AndroidSchedulers.mainThread()) .subscribeOn(AndroidSchedulers.mainThread())
} }
val context: Context = Application.instance!! val context: Context = Application.instance
internal val cleanup = Runnable { internal val cleanup = Runnable {
idToInstance.remove(id) idToInstance.remove(id)
@ -67,7 +67,7 @@ import java.util.concurrent.atomic.AtomicLong
} }
companion object { companion object {
private val cleanupDelayMs = 3000L private const val CLEANUP_DELAY_MS = 3000L
private val nextId = AtomicLong(System.currentTimeMillis() + 0) private val nextId = AtomicLong(System.currentTimeMillis() + 0)
private val handler by lazy { Handler(Looper.getMainLooper()) } private val handler by lazy { Handler(Looper.getMainLooper()) }
private val idToInstance = mutableMapOf<Long, ViewModel<*>>() private val idToInstance = mutableMapOf<Long, ViewModel<*>>()