From 7b9ee0d75b1c9bb9655b6407bcb3c95628a5fe10 Mon Sep 17 00:00:00 2001 From: Jay Date: Thu, 7 May 2020 20:17:07 -0400 Subject: [PATCH] Fixed #357 --- .../tachiyomi/ui/setting/AboutController.kt | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/AboutController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/AboutController.kt index e861b4ebc8..8d7060e530 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/AboutController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/AboutController.kt @@ -17,6 +17,7 @@ import eu.kanade.tachiyomi.data.updater.UpdaterService import eu.kanade.tachiyomi.ui.base.controller.DialogController import eu.kanade.tachiyomi.ui.main.ChangelogDialogController import eu.kanade.tachiyomi.util.lang.toTimestampString +import eu.kanade.tachiyomi.util.system.isOnline import eu.kanade.tachiyomi.util.system.toast import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers @@ -102,7 +103,13 @@ class AboutController : SettingsController() { else BuildConfig.VERSION_NAME if (isUpdaterEnabled) { - onClick { checkVersion() } + onClick { + if (activity!!.isOnline()) { + checkVersion() + } else { + activity!!.toast(R.string.no_network_connection) + } + } } } preference { @@ -134,8 +141,10 @@ class AboutController : SettingsController() { val result = try { updateChecker.checkForUpdate() } catch (error: Exception) { - activity?.toast(error.message) - Timber.e(error) + withContext(Dispatchers.Main) { + activity?.toast(error.message) + Timber.e(error) + } } when (result) { is UpdateResult.NewUpdate<*> -> {