|
|
@@ -3,9 +3,6 @@ package io.legado.app.data.entities
|
|
|
import android.os.Parcelable
|
|
|
import android.text.TextUtils
|
|
|
import androidx.room.*
|
|
|
-import com.google.gson.JsonDeserializationContext
|
|
|
-import com.google.gson.JsonDeserializer
|
|
|
-import com.google.gson.JsonElement
|
|
|
import io.legado.app.constant.AppPattern
|
|
|
import io.legado.app.constant.BookSourceType
|
|
|
import io.legado.app.data.entities.rule.*
|
|
|
@@ -15,7 +12,6 @@ import io.legado.app.utils.fromJsonObject
|
|
|
import io.legado.app.utils.splitNotBlank
|
|
|
import kotlinx.parcelize.Parcelize
|
|
|
import java.io.InputStream
|
|
|
-import java.lang.reflect.Type
|
|
|
|
|
|
@Suppress("unused")
|
|
|
@Parcelize
|
|
|
@@ -228,7 +224,6 @@ data class BookSource(
|
|
|
|
|
|
private val gson by lazy {
|
|
|
GSON.newBuilder()
|
|
|
- .registerTypeAdapter(String::class.java, StringJsonDeserializer())
|
|
|
.registerTypeAdapter(ExploreRule::class.java, ExploreRule.jsonDeserializer)
|
|
|
.registerTypeAdapter(SearchRule::class.java, SearchRule.jsonDeserializer)
|
|
|
.registerTypeAdapter(BookInfoRule::class.java, BookInfoRule.jsonDeserializer)
|
|
|
@@ -250,22 +245,6 @@ data class BookSource(
|
|
|
return gson.fromJsonArray(inputStream)
|
|
|
}
|
|
|
|
|
|
- class StringJsonDeserializer : JsonDeserializer<String?> {
|
|
|
-
|
|
|
- override fun deserialize(
|
|
|
- json: JsonElement,
|
|
|
- typeOfT: Type,
|
|
|
- context: JsonDeserializationContext?
|
|
|
- ): String? {
|
|
|
- return when {
|
|
|
- json.isJsonPrimitive -> json.asString
|
|
|
- json.isJsonNull -> null
|
|
|
- else -> json.toString()
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
}
|
|
|
|
|
|
class Converters {
|