Make sure some toasts are used in the main thread
This commit is contained in:
parent
1b09eecfce
commit
9694c8310c
@ -56,10 +56,12 @@ class SmartSearchController(bundle: Bundle? = null) : NucleusController<EhSmartS
|
||||
router.replaceTopController(transaction)
|
||||
}
|
||||
} else {
|
||||
if (results is SmartSearchPresenter.SearchResults.NotFound) {
|
||||
applicationContext?.toast("Couldn't find the manga in the source!")
|
||||
} else {
|
||||
applicationContext?.toast("Error performing automatic search!")
|
||||
withUIContext {
|
||||
if (results is SmartSearchPresenter.SearchResults.NotFound) {
|
||||
applicationContext?.toast("Couldn't find the manga in the source!")
|
||||
} else {
|
||||
applicationContext?.toast("Error performing automatic search!")
|
||||
}
|
||||
}
|
||||
|
||||
val transaction = BrowseSourceController(source, smartSearchConfig.origTitle, smartSearchConfig).withFadeTransaction()
|
||||
|
@ -18,6 +18,7 @@ import eu.kanade.tachiyomi.source.Source
|
||||
import eu.kanade.tachiyomi.source.SourceManager
|
||||
import eu.kanade.tachiyomi.source.online.all.MangaDex
|
||||
import eu.kanade.tachiyomi.ui.base.controller.DialogController
|
||||
import eu.kanade.tachiyomi.util.lang.launchUI
|
||||
import eu.kanade.tachiyomi.util.system.toast
|
||||
import exh.source.getMainSource
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
@ -79,7 +80,9 @@ class MangadexLoginDialog(bundle: Bundle? = null) : DialogController(bundle) {
|
||||
val twoFactor = binding.twoFactorEdit.text?.toString()
|
||||
if (username.isNullOrBlank() || password.isNullOrBlank() || (binding.twoFactorCheck.isChecked && twoFactor.isNullOrBlank())) {
|
||||
errorResult()
|
||||
binding.root.context.toast(R.string.fields_cannot_be_blank)
|
||||
launchUI {
|
||||
binding.root.context.toast(R.string.fields_cannot_be_blank)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -98,13 +101,15 @@ class MangadexLoginDialog(bundle: Bundle? = null) : DialogController(bundle) {
|
||||
if (result) {
|
||||
dialog?.dismiss()
|
||||
preferences.setTrackCredentials(service, username, password)
|
||||
binding.root.context.toast(R.string.login_success)
|
||||
launchUI {
|
||||
binding.root.context.toast(R.string.login_success)
|
||||
}
|
||||
} else {
|
||||
errorResult()
|
||||
}
|
||||
} catch (error: Exception) {
|
||||
errorResult()
|
||||
error.message?.let { binding.root.context.toast(it) }
|
||||
error.message?.let { launchUI { binding.root.context.toast(it) } }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ import eu.kanade.tachiyomi.source.SourceManager
|
||||
import eu.kanade.tachiyomi.source.online.all.MangaDex
|
||||
import eu.kanade.tachiyomi.ui.base.controller.DialogController
|
||||
import eu.kanade.tachiyomi.util.lang.launchNow
|
||||
import eu.kanade.tachiyomi.util.lang.launchUI
|
||||
import eu.kanade.tachiyomi.util.lang.withIOContext
|
||||
import eu.kanade.tachiyomi.util.system.toast
|
||||
import exh.source.getMainSource
|
||||
@ -53,13 +54,15 @@ class MangadexLogoutDialog(bundle: Bundle? = null) : DialogController(bundle) {
|
||||
activity?.toast(R.string.logout_success)
|
||||
(targetController as? Listener)?.siteLogoutDialogClosed(source)
|
||||
} else {
|
||||
if (exception != null) {
|
||||
activity?.toast(exception.message)
|
||||
} else {
|
||||
activity?.toast(R.string.unknown_error)
|
||||
launchUI {
|
||||
if (exception != null) {
|
||||
activity?.toast(exception.message)
|
||||
} else {
|
||||
activity?.toast(R.string.unknown_error)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else activity?.toast("Mangadex not enabled")
|
||||
} else launchUI { activity?.toast("Mangadex not enabled") }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user