Various crash fixes

This commit is contained in:
Jays2Kings 2022-05-02 14:12:00 -04:00
parent fd7f87b2eb
commit d32a902a57
5 changed files with 22 additions and 13 deletions

View file

@ -7,6 +7,7 @@ import kotlinx.coroutines.cancel
open class BaseCoroutinePresenter<T> {
lateinit var presenterScope: CoroutineScope
val isScopeInitialized get() = this::presenterScope.isInitialized
protected var controller: T? = null
/**

View file

@ -1225,7 +1225,7 @@ class LibraryPresenter(
val mangaFetcher = MangaFetcher()
val libraryManga = db.getFavoriteMangas().executeOnIO()
libraryManga.forEach { manga ->
mangaFetcher.setRatioAndColors(manga)
try { withUIContext { mangaFetcher.setRatioAndColors(manga) } } catch (_: Exception) { }
}
MangaCoverMetadata.savePrefs()
}

View file

@ -72,6 +72,7 @@ import eu.kanade.tachiyomi.ui.base.activity.BaseActivity
import eu.kanade.tachiyomi.ui.base.controller.BaseController
import eu.kanade.tachiyomi.ui.base.controller.DialogController
import eu.kanade.tachiyomi.ui.library.LibraryController
import eu.kanade.tachiyomi.ui.library.LibraryPresenter
import eu.kanade.tachiyomi.ui.manga.MangaDetailsController
import eu.kanade.tachiyomi.ui.more.AboutController
import eu.kanade.tachiyomi.ui.more.OverflowDialog
@ -468,6 +469,9 @@ open class MainActivity : BaseActivity<MainActivityBinding>(), DownloadServiceLi
}
}
}
lifecycleScope.launchIO {
LibraryPresenter.updateRatiosAndColors()
}
}
getExtensionUpdates(true)

View file

@ -556,17 +556,20 @@ class MangaDetailsController :
//region Lifecycle methods
override fun onActivityResumed(activity: Activity) {
super.onActivityResumed(activity)
presenter.isLockedFromSearch = shouldLockIfNeeded && SecureActivityDelegate.shouldBeLocked()
presenter.headerItem.isLocked = presenter.isLockedFromSearch
manga!!.thumbnail_url = presenter.refreshMangaFromDb().thumbnail_url
presenter.fetchChapters(refreshTracker == null)
if (refreshTracker != null) {
trackingBottomSheet?.refreshItem(refreshTracker ?: 0)
presenter.refreshTracking()
refreshTracker = null
if (presenter.isScopeInitialized) {
presenter.isLockedFromSearch =
shouldLockIfNeeded && SecureActivityDelegate.shouldBeLocked()
presenter.headerItem.isLocked = presenter.isLockedFromSearch
manga!!.thumbnail_url = presenter.refreshMangaFromDb().thumbnail_url
presenter.fetchChapters(refreshTracker == null)
if (refreshTracker != null) {
trackingBottomSheet?.refreshItem(refreshTracker ?: 0)
presenter.refreshTracking()
refreshTracker = null
}
// fetch cover again in case the user set a new cover while reading
setPaletteColor()
}
// fetch cover again in case the user set a new cover while reading
setPaletteColor()
val isCurrentController = router?.backstack?.lastOrNull()?.controller ==
this
if (isCurrentController) {

View file

@ -478,9 +478,10 @@ fun Controller.scrollViewWith(
preferences.hideBottomNavOnScroll().get()
) closerToBottom else closerToTop
lastY = activityBinding!!.appBar.snapAppBarY(recycler) {
val activityBinding = activityBinding ?: return@snapAppBarY
swipeCircle?.translationY = max(
activityBinding!!.appBar.y,
-activityBinding!!.appBar.height + activityBinding!!.appBar.paddingTop.toFloat()
activityBinding.appBar.y,
-activityBinding.appBar.height + activityBinding.appBar.paddingTop.toFloat()
)
}
if (activityBinding!!.bottomNav?.isVisible == true &&