mirror of
https://github.com/gedoor/legado.git
synced 2024-08-30 09:23:26 +08:00
优化
This commit is contained in:
parent
42fe73ac35
commit
f5d0e22eaa
@ -136,7 +136,7 @@ data class BookSource(
|
||||
|
||||
fun hasGroup(group: String): Boolean {
|
||||
bookSourceGroup?.splitNotBlank(AppPattern.splitGroupRegex)?.toHashSet()?.let {
|
||||
return if (it.indexOf(group) != -1) true else false
|
||||
return it.indexOf(group) != -1
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import io.legado.app.constant.BookType
|
||||
import io.legado.app.data.entities.BookSource
|
||||
import io.legado.app.data.entities.rule.*
|
||||
import io.legado.app.utils.*
|
||||
import splitties.init.appCtx
|
||||
import timber.log.Timber
|
||||
import java.util.regex.Pattern
|
||||
|
||||
@ -17,11 +18,13 @@ object SourceAnalyzer {
|
||||
|
||||
fun jsonToBookSources(json: String): List<BookSource> {
|
||||
val bookSources = mutableListOf<BookSource>()
|
||||
val items: List<Map<String, Any>> = jsonPath.parse(json).read("$")
|
||||
for (item in items) {
|
||||
val jsonItem = jsonPath.parse(item)
|
||||
jsonToBookSource(jsonItem.jsonString())?.let {
|
||||
bookSources.add(it)
|
||||
if (json.isJsonArray()) {
|
||||
val items: List<Map<String, Any>> = jsonPath.parse(json).read("$")
|
||||
for (item in items) {
|
||||
val jsonItem = jsonPath.parse(item)
|
||||
jsonToBookSource(jsonItem.jsonString())?.let {
|
||||
bookSources.add(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
return bookSources
|
||||
|
Loading…
Reference in New Issue
Block a user