diff --git a/app/src/main/java/io/legado/app/data/entities/SearchShow.kt b/app/src/main/java/io/legado/app/data/entities/SearchShow.kt index a0e24316a..a738909ea 100644 --- a/app/src/main/java/io/legado/app/data/entities/SearchShow.kt +++ b/app/src/main/java/io/legado/app/data/entities/SearchShow.kt @@ -1,17 +1,29 @@ package io.legado.app.data.entities +import io.legado.app.utils.splitNotBlank + data class SearchShow( var name: String = "", var author: String = "", - override var kind: String? = null, + var kind: String? = null, var coverUrl: String? = null, var intro: String? = null, - override var wordCount: String? = null, + var wordCount: String? = null, var latestChapterTitle: String? = null, var time: Long = 0L, var originCount: Int = 0 -) : BaseBook { - override var variableMap: HashMap? = null +) { + + fun getKindList(): List { + val kindList = arrayListOf() + wordCount?.let { + if (it.isNotBlank()) kindList.add(it) + } + kind?.let { + val kinds = it.splitNotBlank(",", "\n") + kindList.addAll(kinds) + } + return kindList + } - override fun putVariable(key: String, value: String) = Unit } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/main/findbook/FindBookAdapter.kt b/app/src/main/java/io/legado/app/ui/main/findbook/FindBookAdapter.kt index 144628dc5..7f44fe28b 100644 --- a/app/src/main/java/io/legado/app/ui/main/findbook/FindBookAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/main/findbook/FindBookAdapter.kt @@ -85,7 +85,11 @@ class FindBookAdapter(private val scope: CoroutineScope, val callBack: CallBack) rowNum++ } tv.onClick { - + callBack.openExplore( + bookSource.bookSourceUrl, + kind.title, + kind.url + ) } } } @@ -96,13 +100,15 @@ class FindBookAdapter(private val scope: CoroutineScope, val callBack: CallBack) rotate_loading.hide() gl_child.gone() } + } } - } class MyViewHolder(view: View) : RecyclerView.ViewHolder(view) interface CallBack { fun scrollTo(pos: Int) + + fun openExplore(sourceUrl: String, title: String, exploreUrl: String) } } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/main/findbook/FindBookFragment.kt b/app/src/main/java/io/legado/app/ui/main/findbook/FindBookFragment.kt index 97a532801..75988f74b 100644 --- a/app/src/main/java/io/legado/app/ui/main/findbook/FindBookFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/findbook/FindBookFragment.kt @@ -13,6 +13,8 @@ import io.legado.app.R import io.legado.app.base.BaseFragment import io.legado.app.data.entities.BookSource import io.legado.app.lib.theme.ATH +import io.legado.app.ui.explore.ExploreShowActivity +import io.legado.app.utils.startActivity import kotlinx.android.synthetic.main.fragment_find_book.* import kotlinx.android.synthetic.main.view_title_bar.* @@ -48,4 +50,12 @@ class FindBookFragment : BaseFragment(R.layout.fragment_find_book), override fun scrollTo(pos: Int) { rv_find.scrollToPosition(pos) } + + override fun openExplore(sourceUrl: String, title: String, exploreUrl: String) { + startActivity( + Pair("exploreName", title), + Pair("sourceUrl", sourceUrl), + Pair("exploreUrl", exploreUrl) + ) + } } \ No newline at end of file