|
@@ -2,12 +2,14 @@ package eu.kanade.tachiyomi.data.track.kitsu
|
|
|
|
|
|
import android.content.Context
|
|
|
import android.graphics.Color
|
|
|
-import com.google.gson.Gson
|
|
|
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.Completable
|
|
|
import rx.Observable
|
|
|
import uy.kohesive.injekt.injectLazy
|
|
@@ -28,9 +30,9 @@ class Kitsu(private val context: Context, id: Int) : TrackService(id) {
|
|
|
|
|
|
override val name = "Kitsu"
|
|
|
|
|
|
- private val gson: Gson by injectLazy()
|
|
|
+ private val json: Json by injectLazy()
|
|
|
|
|
|
- private val interceptor by lazy { KitsuInterceptor(this, gson) }
|
|
|
+ private val interceptor by lazy { KitsuInterceptor(this) }
|
|
|
|
|
|
private val api by lazy { KitsuApi(client, interceptor) }
|
|
|
|
|
@@ -124,13 +126,12 @@ class Kitsu(private val context: Context, id: Int) : TrackService(id) {
|
|
|
}
|
|
|
|
|
|
fun saveToken(oauth: OAuth?) {
|
|
|
- val json = gson.toJson(oauth)
|
|
|
- preferences.trackToken(this).set(json)
|
|
|
+ preferences.trackToken(this).set(json.encodeToString(oauth))
|
|
|
}
|
|
|
|
|
|
fun restoreToken(): OAuth? {
|
|
|
return try {
|
|
|
- gson.fromJson(preferences.trackToken(this).get(), OAuth::class.java)
|
|
|
+ json.decodeFromString<OAuth>(preferences.trackToken(this).get())
|
|
|
} catch (e: Exception) {
|
|
|
null
|
|
|
}
|