diff --git a/app/build.gradle b/app/build.gradle index ba28c8557..71aab6b30 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -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 diff --git a/app/src/main/java/io/legado/app/data/entities/BookSource.kt b/app/src/main/java/io/legado/app/data/entities/BookSource.kt index 8f5adc182..f5843f486 100644 --- a/app/src/main/java/io/legado/app/data/entities/BookSource.kt +++ b/app/src/main/java/io/legado/app/data/entities/BookSource.kt @@ -101,12 +101,12 @@ data class BookSource( } fun getExploreKinds() = arrayListOf().apply { - exploreUrl?.let { urlRule -> - var a = urlRule + exploreUrl?.let { exploreUrl -> + var a = exploreUrl if (a.isNotBlank()) { kotlin.runCatching { - if (urlRule.startsWith("", false) - || urlRule.startsWith("@js", false) + if (exploreUrl.startsWith("", 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 { diff --git a/app/src/main/java/io/legado/app/ui/main/explore/ExploreAdapter.kt b/app/src/main/java/io/legado/app/ui/main/explore/ExploreAdapter.kt index e36db00be..dce02afaa 100644 --- a/app/src/main/java/io/legado/app/ui/main/explore/ExploreAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/main/explore/ExploreAdapter.kt @@ -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() } } } diff --git a/app/src/main/java/io/legado/app/ui/main/explore/ExploreFragment.kt b/app/src/main/java/io/legado/app/ui/main/explore/ExploreFragment.kt index 4660e2ea1..359ec8dea 100644 --- a/app/src/main/java/io/legado/app/ui/main/explore/ExploreFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/explore/ExploreFragment.kt @@ -155,6 +155,9 @@ class ExploreFragment : VMBaseFragment(R.layout.fragment_explo } override fun openExplore(sourceUrl: String, title: String, exploreUrl: String) { + if (exploreUrl.isBlank()) { + return + } startActivity { putExtra("exploreName", title) putExtra("sourceUrl", sourceUrl) diff --git a/app/src/main/res/layout/item_find_book.xml b/app/src/main/res/layout/item_find_book.xml index 61ce006c7..b27c04cba 100644 --- a/app/src/main/res/layout/item_find_book.xml +++ b/app/src/main/res/layout/item_find_book.xml @@ -56,7 +56,7 @@ android:layout_gravity="center">