From 7d713b87b1d50accb33e7475d4159ad2db00625f Mon Sep 17 00:00:00 2001 From: arkon Date: Sun, 3 Jan 2021 23:41:36 -0500 Subject: [PATCH] Fully remove usages of RxJava from tracker classes TODO: refactor usages to coroutines as well --- .../java/eu/kanade/tachiyomi/data/track/TrackService.kt | 3 +-- .../eu/kanade/tachiyomi/data/track/anilist/Anilist.kt | 6 ++---- .../eu/kanade/tachiyomi/data/track/bangumi/Bangumi.kt | 6 ++---- .../java/eu/kanade/tachiyomi/data/track/kitsu/Kitsu.kt | 6 ++---- .../tachiyomi/data/track/myanimelist/MyAnimeList.kt | 8 +++----- .../eu/kanade/tachiyomi/data/track/shikimori/Shikimori.kt | 6 ++---- .../eu/kanade/tachiyomi/ui/manga/track/TrackPresenter.kt | 2 +- 7 files changed, 13 insertions(+), 24 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/TrackService.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/TrackService.kt index 5dfc7462f2..906edc040b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/TrackService.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/TrackService.kt @@ -8,7 +8,6 @@ import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.data.track.model.TrackSearch import eu.kanade.tachiyomi.network.NetworkHelper import okhttp3.OkHttpClient -import rx.Observable import uy.kohesive.injekt.injectLazy abstract class TrackService(val id: Int) { @@ -48,7 +47,7 @@ abstract class TrackService(val id: Int) { abstract suspend fun bind(track: Track): Track - abstract fun search(query: String): Observable> + abstract suspend fun search(query: String): List abstract suspend fun refresh(track: Track): Track diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/anilist/Anilist.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/anilist/Anilist.kt index 4166418007..6cdc178893 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/anilist/Anilist.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/anilist/Anilist.kt @@ -6,11 +6,9 @@ import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.database.models.Track import eu.kanade.tachiyomi.data.track.TrackService import eu.kanade.tachiyomi.data.track.model.TrackSearch -import eu.kanade.tachiyomi.util.lang.runAsObservable import kotlinx.serialization.decodeFromString import kotlinx.serialization.encodeToString import kotlinx.serialization.json.Json -import rx.Observable import uy.kohesive.injekt.injectLazy class Anilist(private val context: Context, id: Int) : TrackService(id) { @@ -160,8 +158,8 @@ class Anilist(private val context: Context, id: Int) : TrackService(id) { } } - override fun search(query: String): Observable> { - return runAsObservable({ api.search(query) }) + override suspend fun search(query: String): List { + return api.search(query) } override suspend fun refresh(track: Track): Track { diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/bangumi/Bangumi.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/bangumi/Bangumi.kt index 7973d78c65..ff54e6eaba 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/bangumi/Bangumi.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/bangumi/Bangumi.kt @@ -6,11 +6,9 @@ import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.database.models.Track import eu.kanade.tachiyomi.data.track.TrackService import eu.kanade.tachiyomi.data.track.model.TrackSearch -import eu.kanade.tachiyomi.util.lang.runAsObservable import kotlinx.serialization.decodeFromString import kotlinx.serialization.encodeToString import kotlinx.serialization.json.Json -import rx.Observable import uy.kohesive.injekt.injectLazy class Bangumi(private val context: Context, id: Int) : TrackService(id) { @@ -57,8 +55,8 @@ class Bangumi(private val context: Context, id: Int) : TrackService(id) { } } - override fun search(query: String): Observable> { - return runAsObservable({ api.search(query) }) + override suspend fun search(query: String): List { + return api.search(query) } override suspend fun refresh(track: Track): Track { diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/kitsu/Kitsu.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/kitsu/Kitsu.kt index 279c969ceb..36f0db94ae 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/kitsu/Kitsu.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/kitsu/Kitsu.kt @@ -6,11 +6,9 @@ import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.database.models.Track import eu.kanade.tachiyomi.data.track.TrackService import eu.kanade.tachiyomi.data.track.model.TrackSearch -import eu.kanade.tachiyomi.util.lang.runAsObservable import kotlinx.serialization.decodeFromString import kotlinx.serialization.encodeToString import kotlinx.serialization.json.Json -import rx.Observable import uy.kohesive.injekt.injectLazy import java.text.DecimalFormat @@ -91,8 +89,8 @@ class Kitsu(private val context: Context, id: Int) : TrackService(id) { } } - override fun search(query: String): Observable> { - return runAsObservable({ api.search(query) }) + override suspend fun search(query: String): List { + return api.search(query) } override suspend fun refresh(track: Track): Track { diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/myanimelist/MyAnimeList.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/myanimelist/MyAnimeList.kt index 4169570318..dc7d3b5da9 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/myanimelist/MyAnimeList.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/myanimelist/MyAnimeList.kt @@ -6,11 +6,9 @@ import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.database.models.Track import eu.kanade.tachiyomi.data.track.TrackService import eu.kanade.tachiyomi.data.track.model.TrackSearch -import eu.kanade.tachiyomi.util.lang.runAsObservable import kotlinx.serialization.decodeFromString import kotlinx.serialization.encodeToString import kotlinx.serialization.json.Json -import rx.Observable import uy.kohesive.injekt.injectLazy class MyAnimeList(private val context: Context, id: Int) : TrackService(id) { @@ -83,14 +81,14 @@ class MyAnimeList(private val context: Context, id: Int) : TrackService(id) { } } - override fun search(query: String): Observable> { + override suspend fun search(query: String): List { if (query.startsWith(SEARCH_ID_PREFIX)) { query.substringAfter(SEARCH_ID_PREFIX).toIntOrNull()?.let { id -> - return runAsObservable({ listOf(api.getMangaDetails(id)) }) + return listOf(api.getMangaDetails(id)) } } - return runAsObservable({ api.search(query) }) + return api.search(query) } override suspend fun refresh(track: Track): Track { diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/shikimori/Shikimori.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/shikimori/Shikimori.kt index 99b8ae3965..eebe0eb463 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/shikimori/Shikimori.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/shikimori/Shikimori.kt @@ -6,11 +6,9 @@ import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.database.models.Track import eu.kanade.tachiyomi.data.track.TrackService import eu.kanade.tachiyomi.data.track.model.TrackSearch -import eu.kanade.tachiyomi.util.lang.runAsObservable import kotlinx.serialization.decodeFromString import kotlinx.serialization.encodeToString import kotlinx.serialization.json.Json -import rx.Observable import uy.kohesive.injekt.injectLazy class Shikimori(private val context: Context, id: Int) : TrackService(id) { @@ -65,8 +63,8 @@ class Shikimori(private val context: Context, id: Int) : TrackService(id) { } } - override fun search(query: String): Observable> { - return runAsObservable({ api.search(query) }) + override suspend fun search(query: String): List { + return api.search(query) } override suspend fun refresh(track: Track): Track { 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 d93ea17579..8f854eaedd 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 @@ -79,7 +79,7 @@ class TrackPresenter( fun search(query: String, service: TrackService) { searchSubscription?.let { remove(it) } - searchSubscription = service.search(query) + searchSubscription = runAsObservable({ service.search(query) }) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribeLatestCache(