Fix InterceptActivity crash

This commit is contained in:
Jobobby04 2024-11-03 21:03:22 -05:00
parent ffc1e2d97b
commit c2df6ee54a

View File

@ -36,6 +36,7 @@ import kotlinx.coroutines.flow.onEach
import tachiyomi.core.common.Constants import tachiyomi.core.common.Constants
import tachiyomi.core.common.i18n.stringResource import tachiyomi.core.common.i18n.stringResource
import tachiyomi.core.common.util.lang.launchIO import tachiyomi.core.common.util.lang.launchIO
import tachiyomi.core.common.util.lang.withUIContext
import tachiyomi.domain.chapter.model.Chapter import tachiyomi.domain.chapter.model.Chapter
import tachiyomi.domain.manga.model.Manga import tachiyomi.domain.manga.model.Manga
import tachiyomi.domain.source.service.SourceManager import tachiyomi.domain.source.service.SourceManager
@ -180,8 +181,9 @@ class InterceptActivity : BaseActivity() {
status.value = InterceptResult.Loading status.value = InterceptResult.Loading
val sources = galleryAdder.pickSource(gallery) val sources = galleryAdder.pickSource(gallery)
if (sources.size > 1) { if (sources.size > 1) {
MaterialAlertDialogBuilder(this) withUIContext {
.setTitle(MR.strings.label_sources.getString(this)) MaterialAlertDialogBuilder(this@InterceptActivity)
.setTitle(MR.strings.label_sources.getString(this@InterceptActivity))
.setSingleChoiceItems(sources.map { it.toString() }.toTypedArray(), 0) { dialog, index -> .setSingleChoiceItems(sources.map { it.toString() }.toTypedArray(), 0) { dialog, index ->
dialog.dismiss() dialog.dismiss()
lifecycleScope.launchIO { lifecycleScope.launchIO {
@ -189,6 +191,7 @@ class InterceptActivity : BaseActivity() {
} }
} }
.show() .show()
}
} else { } else {
loadGalleryEnd(gallery) loadGalleryEnd(gallery)
} }