diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupRestoreService.kt b/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupRestoreService.kt index 6aa8f2b39..0cd976ede 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupRestoreService.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupRestoreService.kt @@ -194,7 +194,7 @@ class BackupRestoreService : Service() { return Observable.just(Unit) .map { val reader = JsonReader(contentResolver.openInputStream(uri)!!.bufferedReader()) - val json = JsonParser().parse(reader).asJsonObject + val json = JsonParser.parseReader(reader).asJsonObject // Get parser version val version = json.get(VERSION)?.asInt ?: 1 diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/anilist/AnilistApi.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/anilist/AnilistApi.kt index c4a676385..321daa7b7 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/anilist/AnilistApi.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/anilist/AnilistApi.kt @@ -21,7 +21,6 @@ import rx.Observable class AnilistApi(val client: OkHttpClient, interceptor: AnilistInterceptor) { - private val parser = JsonParser() private val jsonMime = "application/json; charset=utf-8".toMediaTypeOrNull() private val authClient = client.newBuilder().addInterceptor(interceptor).build() @@ -56,7 +55,7 @@ class AnilistApi(val client: OkHttpClient, interceptor: AnilistInterceptor) { if (responseBody.isEmpty()) { throw Exception("Null Response") } - val response = parser.parse(responseBody).obj + val response = JsonParser.parseString(responseBody).obj track.library_id = response["data"]["SaveMediaListEntry"]["id"].asLong track } @@ -138,7 +137,7 @@ class AnilistApi(val client: OkHttpClient, interceptor: AnilistInterceptor) { if (responseBody.isEmpty()) { throw Exception("Null Response") } - val response = parser.parse(responseBody).obj + val response = JsonParser.parseString(responseBody).obj val data = response["data"]!!.obj val page = data["Page"].obj val media = page["media"].array @@ -198,7 +197,7 @@ class AnilistApi(val client: OkHttpClient, interceptor: AnilistInterceptor) { if (responseBody.isEmpty()) { throw Exception("Null Response") } - val response = parser.parse(responseBody).obj + val response = JsonParser.parseString(responseBody).obj val data = response["data"]!!.obj val page = data["Page"].obj val media = page["mediaList"].array @@ -242,7 +241,7 @@ class AnilistApi(val client: OkHttpClient, interceptor: AnilistInterceptor) { if (responseBody.isEmpty()) { throw Exception("Null Response") } - val response = parser.parse(responseBody).obj + val response = JsonParser.parseString(responseBody).obj val data = response["data"]!!.obj val viewer = data["Viewer"].obj Pair(viewer["id"].asInt, viewer["mediaListOptions"]["scoreFormat"].asString) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/bangumi/BangumiApi.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/bangumi/BangumiApi.kt index a0e050315..809574464 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/bangumi/BangumiApi.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/bangumi/BangumiApi.kt @@ -22,7 +22,6 @@ import uy.kohesive.injekt.injectLazy class BangumiApi(private val client: OkHttpClient, interceptor: BangumiInterceptor) { private val gson: Gson by injectLazy() - private val parser = JsonParser() private val authClient = client.newBuilder().addInterceptor(interceptor).build() fun addLibManga(track: Track): Observable { @@ -91,7 +90,7 @@ class BangumiApi(private val client: OkHttpClient, interceptor: BangumiIntercept if (responseBody.contains("\"code\":404")) { responseBody = "{\"results\":0,\"list\":[]}" } - val response = parser.parse(responseBody).obj["list"]?.array + val response = JsonParser.parseString(responseBody).obj["list"]?.array response?.filter { it.obj["type"].asInt == 1 }?.map { jsonToSearch(it.obj) } } } @@ -130,7 +129,7 @@ class BangumiApi(private val client: OkHttpClient, interceptor: BangumiIntercept .map { netResponse -> // get comic info val responseBody = netResponse.body?.string().orEmpty() - jsonToTrack(parser.parse(responseBody).obj) + jsonToTrack(JsonParser.parseString(responseBody).obj) } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/shikimori/ShikimoriApi.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/shikimori/ShikimoriApi.kt index 15c4626d3..a56d06347 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/shikimori/ShikimoriApi.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/shikimori/ShikimoriApi.kt @@ -25,7 +25,6 @@ import uy.kohesive.injekt.injectLazy class ShikimoriApi(private val client: OkHttpClient, interceptor: ShikimoriInterceptor) { private val gson: Gson by injectLazy() - private val parser = JsonParser() private val jsonime = "application/json; charset=utf-8".toMediaTypeOrNull() private val authClient = client.newBuilder().addInterceptor(interceptor).build() @@ -71,7 +70,7 @@ class ShikimoriApi(private val client: OkHttpClient, interceptor: ShikimoriInter if (responseBody.isEmpty()) { throw Exception("Null Response") } - val response = parser.parse(responseBody).array + val response = JsonParser.parseString(responseBody).array response.map { jsonToSearch(it.obj) } } } @@ -124,7 +123,7 @@ class ShikimoriApi(private val client: OkHttpClient, interceptor: ShikimoriInter .asObservableSuccess() .map { netResponse -> val responseBody = netResponse.body?.string().orEmpty() - parser.parse(responseBody).obj + JsonParser.parseString(responseBody).obj }.flatMap { mangas -> authClient.newCall(request) .asObservableSuccess() @@ -133,7 +132,7 @@ class ShikimoriApi(private val client: OkHttpClient, interceptor: ShikimoriInter if (responseBody.isEmpty()) { throw Exception("Null Response") } - val response = parser.parse(responseBody).array + val response = JsonParser.parseString(responseBody).array if (response.size() > 1) { throw Exception("Too much mangas in response") } @@ -147,7 +146,7 @@ class ShikimoriApi(private val client: OkHttpClient, interceptor: ShikimoriInter fun getCurrentUser(): Int { val user = authClient.newCall(GET("$apiUrl/users/whoami")).execute().body?.string() - return parser.parse(user).obj["id"].asInt + return JsonParser.parseString(user).obj["id"].asInt } fun accessToken(code: String): Observable {