From b7914909d0a12692ff6aa6a2137bfd217adf5339 Mon Sep 17 00:00:00 2001 From: arkon Date: Thu, 31 Dec 2020 18:37:43 -0500 Subject: [PATCH] Remove some unnecessary coroutine dispatcher switching --- .../eu/kanade/tachiyomi/ui/manga/MangaPresenter.kt | 5 +---- .../tachiyomi/ui/manga/track/TrackPresenter.kt | 6 ++---- .../ui/setting/track/AnilistLoginActivity.kt | 5 +---- .../ui/setting/track/BangumiLoginActivity.kt | 5 +---- .../ui/setting/track/MyAnimeListLoginActivity.kt | 5 +---- .../ui/setting/track/ShikimoriLoginActivity.kt | 5 +---- .../tachiyomi/ui/setting/track/TrackLoginDialog.kt | 14 +++++--------- 7 files changed, 12 insertions(+), 33 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaPresenter.kt index ece062a2c5..9aa2311177 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaPresenter.kt @@ -24,7 +24,6 @@ import eu.kanade.tachiyomi.util.isLocal import eu.kanade.tachiyomi.util.lang.await import eu.kanade.tachiyomi.util.lang.isNullOrUnsubscribed import eu.kanade.tachiyomi.util.lang.launchIO -import eu.kanade.tachiyomi.util.lang.launchUI import eu.kanade.tachiyomi.util.prepUpdateCover import eu.kanade.tachiyomi.util.removeCovers import eu.kanade.tachiyomi.util.shouldDownloadNewChapters @@ -511,9 +510,7 @@ class MangaPresenter( refreshChapters() } - launchUI { - view?.onChaptersDeleted(chapters) - } + view?.onChaptersDeleted(chapters) } catch (e: Throwable) { view?.onChaptersDeletedError(e) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackPresenter.kt index 1b3538e04e..ff3c2130cd 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackPresenter.kt @@ -114,12 +114,10 @@ class TrackPresenter( try { service.update(track) db.insertTrack(track).await() - launchUI { - view!!.onRefreshDone() - } + view?.onRefreshDone() } catch (e: Throwable) { launchUI { - view!!.onRefreshError(e) + view?.onRefreshError(e) // Restart on error to set old values fetchTrackings() diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/track/AnilistLoginActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/track/AnilistLoginActivity.kt index 262a603141..3a7f1b663b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/track/AnilistLoginActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/track/AnilistLoginActivity.kt @@ -2,7 +2,6 @@ package eu.kanade.tachiyomi.ui.setting.track import android.net.Uri import eu.kanade.tachiyomi.util.lang.launchIO -import eu.kanade.tachiyomi.util.lang.launchUI class AnilistLoginActivity : BaseOAuthLoginActivity() { @@ -12,9 +11,7 @@ class AnilistLoginActivity : BaseOAuthLoginActivity() { if (matchResult?.groups?.get(1) != null) { launchIO { trackManager.aniList.login(matchResult.groups[1]!!.value) - launchUI { - returnToSettings() - } + returnToSettings() } } else { trackManager.aniList.logout() diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/track/BangumiLoginActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/track/BangumiLoginActivity.kt index 86538fc081..2e202718df 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/track/BangumiLoginActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/track/BangumiLoginActivity.kt @@ -2,7 +2,6 @@ package eu.kanade.tachiyomi.ui.setting.track import android.net.Uri import eu.kanade.tachiyomi.util.lang.launchIO -import eu.kanade.tachiyomi.util.lang.launchUI class BangumiLoginActivity : BaseOAuthLoginActivity() { @@ -11,9 +10,7 @@ class BangumiLoginActivity : BaseOAuthLoginActivity() { if (code != null) { launchIO { trackManager.bangumi.login(code) - launchUI { - returnToSettings() - } + returnToSettings() } } else { trackManager.bangumi.logout() diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/track/MyAnimeListLoginActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/track/MyAnimeListLoginActivity.kt index d5ab330844..02f8947674 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/track/MyAnimeListLoginActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/track/MyAnimeListLoginActivity.kt @@ -2,7 +2,6 @@ package eu.kanade.tachiyomi.ui.setting.track import android.net.Uri import eu.kanade.tachiyomi.util.lang.launchIO -import eu.kanade.tachiyomi.util.lang.launchUI class MyAnimeListLoginActivity : BaseOAuthLoginActivity() { @@ -11,9 +10,7 @@ class MyAnimeListLoginActivity : BaseOAuthLoginActivity() { if (code != null) { launchIO { trackManager.myAnimeList.login(code) - launchUI { - returnToSettings() - } + returnToSettings() } } else { trackManager.myAnimeList.logout() diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/track/ShikimoriLoginActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/track/ShikimoriLoginActivity.kt index 0a8fe541f1..53f00a25cd 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/track/ShikimoriLoginActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/track/ShikimoriLoginActivity.kt @@ -2,7 +2,6 @@ package eu.kanade.tachiyomi.ui.setting.track import android.net.Uri import eu.kanade.tachiyomi.util.lang.launchIO -import eu.kanade.tachiyomi.util.lang.launchUI class ShikimoriLoginActivity : BaseOAuthLoginActivity() { @@ -11,9 +10,7 @@ class ShikimoriLoginActivity : BaseOAuthLoginActivity() { if (code != null) { launchIO { trackManager.shikimori.login(code) - launchUI { - returnToSettings() - } + returnToSettings() } } else { trackManager.shikimori.logout() diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/track/TrackLoginDialog.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/track/TrackLoginDialog.kt index a56d4d1fbc..2db114ca75 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/track/TrackLoginDialog.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/track/TrackLoginDialog.kt @@ -45,16 +45,12 @@ class TrackLoginDialog( launchIO { try { service.login(user, pass) - launchUI { - dialog?.dismiss() - view?.context?.toast(R.string.login_success) - } + dialog?.dismiss() + launchUI { view?.context?.toast(R.string.login_success) } } catch (e: Throwable) { - launchUI { - binding!!.login.progress = -1 - binding!!.login.setText(R.string.unknown_error) - e.message?.let { view?.context?.toast(it) } - } + binding?.login?.progress = -1 + binding?.login?.setText(R.string.unknown_error) + launchUI { e.message?.let { view?.context?.toast(it) } } } } }