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