Add ID search workaround for MAL tracking

This commit is contained in:
arkon 2020-12-30 15:08:10 -05:00
parent 3df98d576e
commit a49adbd09c
2 changed files with 7 additions and 1 deletions

View File

@ -76,6 +76,12 @@ class MyAnimeList(private val context: Context, id: Int) : TrackService(id) {
} }
override fun search(query: String): Observable<List<TrackSearch>> { override fun search(query: String): Observable<List<TrackSearch>> {
if (query.startsWith("my:")) {
query.substringAfter("my:").toIntOrNull()?.let { id ->
return runAsObservable({ listOf(api.getMangaDetails(id)) })
}
}
return runAsObservable({ api.search(query) }) return runAsObservable({ api.search(query) })
} }

View File

@ -79,7 +79,7 @@ class MyAnimeListApi(private val client: OkHttpClient, interceptor: MyAnimeListI
} }
} }
private suspend fun getMangaDetails(id: Int): TrackSearch { suspend fun getMangaDetails(id: Int): TrackSearch {
return withContext(Dispatchers.IO) { return withContext(Dispatchers.IO) {
val url = "$baseApiUrl/manga".toUri().buildUpon() val url = "$baseApiUrl/manga".toUri().buildUpon()
.appendPath(id.toString()) .appendPath(id.toString())