Remove some unnecessary coroutine dispatcher switching

This commit is contained in:
arkon 2020-12-31 18:37:43 -05:00
parent 63398fe491
commit b7914909d0
7 changed files with 12 additions and 33 deletions

View File

@ -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)
}
} catch (e: Throwable) {
view?.onChaptersDeletedError(e)
}

View File

@ -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()

View File

@ -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,10 +11,8 @@ class AnilistLoginActivity : BaseOAuthLoginActivity() {
if (matchResult?.groups?.get(1) != null) {
launchIO {
trackManager.aniList.login(matchResult.groups[1]!!.value)
launchUI {
returnToSettings()
}
}
} else {
trackManager.aniList.logout()
returnToSettings()

View File

@ -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,10 +10,8 @@ class BangumiLoginActivity : BaseOAuthLoginActivity() {
if (code != null) {
launchIO {
trackManager.bangumi.login(code)
launchUI {
returnToSettings()
}
}
} else {
trackManager.bangumi.logout()
returnToSettings()

View File

@ -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,10 +10,8 @@ class MyAnimeListLoginActivity : BaseOAuthLoginActivity() {
if (code != null) {
launchIO {
trackManager.myAnimeList.login(code)
launchUI {
returnToSettings()
}
}
} else {
trackManager.myAnimeList.logout()
returnToSettings()

View File

@ -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,10 +10,8 @@ class ShikimoriLoginActivity : BaseOAuthLoginActivity() {
if (code != null) {
launchIO {
trackManager.shikimori.login(code)
launchUI {
returnToSettings()
}
}
} else {
trackManager.shikimori.logout()
returnToSettings()

View File

@ -45,16 +45,12 @@ class TrackLoginDialog(
launchIO {
try {
service.login(user, pass)
launchUI {
dialog?.dismiss()
view?.context?.toast(R.string.login_success)
}
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) } }
}
}
}