pull/32/head
kunfei 5 years ago
parent 8d85662aa1
commit fd74bcedcf
  1. 9
      app/src/main/java/io/legado/app/data/entities/BookSource.kt
  2. 18
      app/src/main/java/io/legado/app/ui/main/explore/FindBookAdapter.kt

@ -118,6 +118,7 @@ data class BookSource(
}
fun getExploreKinds(): ArrayList<ExploreKind>? {
val exploreKinds = arrayListOf<ExploreKind>()
exploreUrl?.let {
var a = it
if (a.isNotBlank()) {
@ -131,24 +132,22 @@ data class BookSource(
bindings
).toString()
}
val exploreKinds = arrayListOf<ExploreKind>()
val b = a.split("(&&|\n)+".toRegex())
b.map { c ->
val d = c.split("::")
if (d.size > 1)
exploreKinds.add(ExploreKind(d[0], d[1]))
}
return exploreKinds
} catch (e: Exception) {
e.printStackTrace()
exploreKinds.add(ExploreKind(e.localizedMessage))
}
}
}
return null
return exploreKinds
}
data class ExploreKind(
var title: String,
var url: String
var url: String? = null
)
}

@ -56,20 +56,22 @@ class FindBookAdapter(context: Context, private val scope: CoroutineScope, val c
rotate_loading.show()
Coroutine.async(scope) {
item.getExploreKinds()
}.onSuccess {
it?.let {
}.onSuccess { kindList ->
if (!kindList.isNullOrEmpty()) {
gl_child.visible()
gl_child.removeAllViews()
it.map { kind ->
kindList.map { kind ->
val tv = LayoutInflater.from(context)
.inflate(R.layout.item_text, gl_child, false)
tv.text_view.text = kind.title
tv.text_view.onClick {
callBack.openExplore(
item.bookSourceUrl,
kind.title,
kind.url
)
kind.url?.let { kindUrl ->
callBack.openExplore(
item.bookSourceUrl,
kind.title,
kindUrl
)
}
}
gl_child.addView(tv)
}

Loading…
Cancel
Save