Use a buffered reader instead of a scanner for custom manga info
This commit is contained in:
parent
2ddf5f5037
commit
0925bd6a37
@ -8,7 +8,6 @@ import kotlinx.serialization.decodeFromString
|
|||||||
import kotlinx.serialization.encodeToString
|
import kotlinx.serialization.encodeToString
|
||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.util.Scanner
|
|
||||||
|
|
||||||
class CustomMangaManager(val context: Context) {
|
class CustomMangaManager(val context: Context) {
|
||||||
|
|
||||||
@ -23,7 +22,7 @@ class CustomMangaManager(val context: Context) {
|
|||||||
|
|
||||||
val json = try {
|
val json = try {
|
||||||
Json.decodeFromString<MangaList>(
|
Json.decodeFromString<MangaList>(
|
||||||
Scanner(editJson).useDelimiter("\\Z").next()
|
editJson.bufferedReader().use { it.readText() }
|
||||||
)
|
)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
null
|
null
|
||||||
@ -90,17 +89,5 @@ class CustomMangaManager(val context: Context) {
|
|||||||
genre = this@MangaJson.genre?.joinToString(", ")
|
genre = this@MangaJson.genre?.joinToString(", ")
|
||||||
status = this@MangaJson.status ?: 0
|
status = this@MangaJson.status ?: 0
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun equals(other: Any?): Boolean {
|
|
||||||
if (this === other) return true
|
|
||||||
if (javaClass != other?.javaClass) return false
|
|
||||||
other as MangaJson
|
|
||||||
if (id != other.id) return false
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun hashCode(): Int {
|
|
||||||
return id.hashCode()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user