pull/1111/head
gedoor 3 years ago
parent 9180a4c40d
commit c49e6bae53
  1. 2
      app/build.gradle
  2. 16
      app/src/main/java/io/legado/app/data/entities/BookSource.kt
  3. 21
      app/src/main/java/io/legado/app/ui/main/explore/ExploreAdapter.kt
  4. 3
      app/src/main/java/io/legado/app/ui/main/explore/ExploreFragment.kt
  5. 2
      app/src/main/res/layout/item_find_book.xml

@ -135,7 +135,7 @@ dependencies {
implementation 'androidx.viewpager2:viewpager2:1.0.0'
implementation 'com.google.android.material:material:1.4.0'
implementation 'com.google.android.flexbox:flexbox:3.0.0'
implementation 'com.google.code.gson:gson:2.8.6'
implementation 'com.google.code.gson:gson:2.8.7'
implementation 'androidx.webkit:webkit:1.4.0'
//media

@ -101,12 +101,12 @@ data class BookSource(
}
fun getExploreKinds() = arrayListOf<ExploreKind>().apply {
exploreUrl?.let { urlRule ->
var a = urlRule
exploreUrl?.let { exploreUrl ->
var a = exploreUrl
if (a.isNotBlank()) {
kotlin.runCatching {
if (urlRule.startsWith("<js>", false)
|| urlRule.startsWith("@js", false)
if (exploreUrl.startsWith("<js>", false)
|| exploreUrl.startsWith("@js", false)
) {
val aCache = ACache.get(appCtx, "explore")
a = aCache.getAsString(bookSourceUrl) ?: ""
@ -116,10 +116,10 @@ data class BookSource(
bindings["java"] = this
bindings["cookie"] = CookieStore
bindings["cache"] = CacheManager
val jsStr = if (urlRule.startsWith("@")) {
urlRule.substring(3)
val jsStr = if (exploreUrl.startsWith("@")) {
exploreUrl.substring(3)
} else {
urlRule.substring(4, urlRule.lastIndexOf("<"))
exploreUrl.substring(4, exploreUrl.lastIndexOf("<"))
}
a = AppConst.SCRIPT_ENGINE.eval(jsStr, bindings).toString()
aCache.put(bookSourceUrl, a)
@ -173,7 +173,7 @@ data class BookSource(
data class ExploreKind(
var title: String,
var url: String? = null
var url: String? = null,
)
class Converters {

@ -5,6 +5,7 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.PopupMenu
import com.google.android.flexbox.FlexboxLayout
import io.legado.app.R
import io.legado.app.base.adapter.ItemViewHolder
import io.legado.app.base.adapter.RecyclerAdapter
@ -56,18 +57,18 @@ class ExploreAdapter(context: Context, private val scope: CoroutineScope, val ca
item.getExploreKinds()
}.onSuccess { kindList ->
if (!kindList.isNullOrEmpty()) {
glChild.visible()
glChild.removeAllViews()
flexbox.visible()
flexbox.removeAllViews()
kindList.map { kind ->
val tv = ItemFilletTextBinding.inflate(
LayoutInflater.from(context),
glChild,
flexbox,
false
)
glChild.addView(tv.root)
tv.textView.text = kind.title
).root
flexbox.addView(tv)
tv.text = kind.title
if (!kind.url.isNullOrEmpty()) {
tv.textView.setOnClickListener {
tv.setOnClickListener {
callBack.openExplore(
item.bookSourceUrl,
kind.title,
@ -75,6 +76,10 @@ class ExploreAdapter(context: Context, private val scope: CoroutineScope, val ca
)
}
}
val lp = tv.layoutParams as FlexboxLayout.LayoutParams
lp.let {
}
}
}
}.onFinally {
@ -87,7 +92,7 @@ class ExploreAdapter(context: Context, private val scope: CoroutineScope, val ca
} else {
binding.ivStatus.setImageResource(R.drawable.ic_arrow_right)
binding.rotateLoading.hide()
binding.glChild.gone()
binding.flexbox.gone()
}
}
}

@ -155,6 +155,9 @@ class ExploreFragment : VMBaseFragment<ExploreViewModel>(R.layout.fragment_explo
}
override fun openExplore(sourceUrl: String, title: String, exploreUrl: String) {
if (exploreUrl.isBlank()) {
return
}
startActivity<ExploreShowActivity> {
putExtra("exploreName", title)
putExtra("sourceUrl", sourceUrl)

@ -56,7 +56,7 @@
android:layout_gravity="center">
<com.google.android.flexbox.FlexboxLayout
android:id="@+id/gl_child"
android:id="@+id/flexbox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"

Loading…
Cancel
Save