From 8efb20439a3d06766f257227f68bf1b762f9c432 Mon Sep 17 00:00:00 2001 From: arkon Date: Mon, 29 Aug 2022 15:15:18 -0400 Subject: [PATCH] Remove some usages of global scope --- .../ui/browse/source/browse/BrowseSourceController.kt | 4 ++-- .../ui/browse/source/browse/BrowseSourcePresenter.kt | 2 +- .../main/java/eu/kanade/tachiyomi/ui/manga/MangaPresenter.kt | 2 +- .../java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt | 2 +- .../eu/kanade/tachiyomi/ui/setting/track/TrackLoginDialog.kt | 2 -- 5 files changed, 5 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourceController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourceController.kt index 99450f3acb..cba2725a2e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourceController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourceController.kt @@ -595,7 +595,7 @@ open class BrowseSourceController(bundle: Bundle) : override fun onItemLongClick(position: Int) { val activity = activity ?: return val manga = (adapter?.getItem(position) as? SourceItem?)?.manga ?: return - launchIO { + viewScope.launchIO { val duplicateManga = presenter.getDuplicateLibraryManga(manga) withUIContext { @@ -631,7 +631,7 @@ open class BrowseSourceController(bundle: Bundle) : private fun addToLibrary(newManga: Manga, position: Int) { val activity = activity ?: return - launchIO { + viewScope.launchIO { val categories = presenter.getCategories() val defaultCategoryId = preferences.defaultCategory() val defaultCategory = categories.find { it.id == defaultCategoryId.toLong() } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourcePresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourcePresenter.kt index b4cc39fe99..c6c187c382 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourcePresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourcePresenter.kt @@ -194,7 +194,7 @@ open class BrowseSourcePresenter( if (!hasNextPage()) return nextPageJob?.cancel() - nextPageJob = launchIO { + nextPageJob = presenterScope.launchIO { try { pager.requestNextPage() } catch (e: Throwable) { 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 ab43f0bcb3..71a38fe5b3 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 @@ -920,7 +920,7 @@ class MangaPresenter( fun trackingSearch(query: String, service: TrackService) { searchTrackerJob?.cancel() - searchTrackerJob = launchIO { + searchTrackerJob = presenterScope.launchIO { try { val results = service.search(query) withUIContext { view?.onTrackingSearchResults(results) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt index d7b595f5c7..5e65c9484e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt @@ -249,7 +249,7 @@ class ReaderPresenter( fun init(mangaId: Long, initialChapterId: Long) { if (!needsInit()) return - launchIO { + presenterScope.launchIO { try { val manga = getManga.await(mangaId) withUIContext { 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 e8cae61c85..39f891c562 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 @@ -21,8 +21,6 @@ class TrackLoginDialog( private val service = Injekt.get().getService(args.getLong("serviceId"))!! - constructor(service: TrackService) : this(service, null) - constructor(service: TrackService, @StringRes usernameLabelRes: Int?) : this(usernameLabelRes, bundleOf("serviceId" to service.id))