Fix crash in base presenter

This commit is contained in:
Jays2Kings 2023-04-16 16:51:08 -04:00
parent ebe8edb110
commit 35dd94c179
2 changed files with 2 additions and 6 deletions

View file

@ -7,8 +7,7 @@ import kotlinx.coroutines.cancel
import java.lang.ref.WeakReference
open class BaseCoroutinePresenter<T> {
lateinit var presenterScope: CoroutineScope
val isScopeInitialized get() = this::presenterScope.isInitialized
var presenterScope = CoroutineScope(SupervisorJob() + Dispatchers.Default)
private var weakView: WeakReference<T>? = null
protected val view: T?
get() = weakView?.get()
@ -23,9 +22,6 @@ open class BaseCoroutinePresenter<T> {
}
open fun onCreate() {
if (!isScopeInitialized) {
presenterScope = CoroutineScope(SupervisorJob() + Dispatchers.Default)
}
}
open fun onDestroy() {

View file

@ -615,7 +615,7 @@ class MangaDetailsController :
//region Lifecycle methods
override fun onActivityResumed(activity: Activity) {
super.onActivityResumed(activity)
if (presenter.isScopeInitialized) {
if (adapter != null) {
presenter.isLockedFromSearch =
shouldLockIfNeeded && SecureActivityDelegate.shouldBeLocked()
presenter.headerItem.isLocked = presenter.isLockedFromSearch