This commit is contained in:
Jay 2020-05-07 20:17:07 -04:00
parent e69b51accb
commit 7b9ee0d75b

View File

@ -17,6 +17,7 @@ import eu.kanade.tachiyomi.data.updater.UpdaterService
import eu.kanade.tachiyomi.ui.base.controller.DialogController import eu.kanade.tachiyomi.ui.base.controller.DialogController
import eu.kanade.tachiyomi.ui.main.ChangelogDialogController import eu.kanade.tachiyomi.ui.main.ChangelogDialogController
import eu.kanade.tachiyomi.util.lang.toTimestampString import eu.kanade.tachiyomi.util.lang.toTimestampString
import eu.kanade.tachiyomi.util.system.isOnline
import eu.kanade.tachiyomi.util.system.toast import eu.kanade.tachiyomi.util.system.toast
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
@ -102,7 +103,13 @@ class AboutController : SettingsController() {
else BuildConfig.VERSION_NAME else BuildConfig.VERSION_NAME
if (isUpdaterEnabled) { if (isUpdaterEnabled) {
onClick { checkVersion() } onClick {
if (activity!!.isOnline()) {
checkVersion()
} else {
activity!!.toast(R.string.no_network_connection)
}
}
} }
} }
preference { preference {
@ -134,8 +141,10 @@ class AboutController : SettingsController() {
val result = try { val result = try {
updateChecker.checkForUpdate() updateChecker.checkForUpdate()
} catch (error: Exception) { } catch (error: Exception) {
activity?.toast(error.message) withContext(Dispatchers.Main) {
Timber.e(error) activity?.toast(error.message)
Timber.e(error)
}
} }
when (result) { when (result) {
is UpdateResult.NewUpdate<*> -> { is UpdateResult.NewUpdate<*> -> {