diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index bca5f59fb..86b1d669a 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -61,6 +61,7 @@
+
diff --git a/app/src/main/java/io/legado/app/data/entities/BaseBook.kt b/app/src/main/java/io/legado/app/data/entities/BaseBook.kt
index e3605d6f6..6a7d561ee 100644
--- a/app/src/main/java/io/legado/app/data/entities/BaseBook.kt
+++ b/app/src/main/java/io/legado/app/data/entities/BaseBook.kt
@@ -1,6 +1,23 @@
package io.legado.app.data.entities
+import io.legado.app.utils.splitNotBlank
+
interface BaseBook {
var variableMap: HashMap?
+ var kind: String?
+ var wordCount: String?
+
fun putVariable(key: String, value: String)
+
+ 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
+ }
}
\ No newline at end of file
diff --git a/app/src/main/java/io/legado/app/data/entities/Book.kt b/app/src/main/java/io/legado/app/data/entities/Book.kt
index ebd007a10..118acf35b 100644
--- a/app/src/main/java/io/legado/app/data/entities/Book.kt
+++ b/app/src/main/java/io/legado/app/data/entities/Book.kt
@@ -9,7 +9,6 @@ import androidx.room.PrimaryKey
import io.legado.app.constant.BookType
import io.legado.app.utils.GSON
import io.legado.app.utils.fromJsonObject
-import io.legado.app.utils.splitNotBlank
import kotlinx.android.parcel.IgnoredOnParcel
import kotlinx.android.parcel.Parcelize
import kotlin.math.max
@@ -24,7 +23,7 @@ data class Book(
var originName: String = "", //书源名称
var name: String = "", // 书籍名称(书源获取)
var author: String = "", // 作者名称(书源获取)
- var kind: String? = null, // 分类信息(书源获取)
+ override var kind: String? = null, // 分类信息(书源获取)
var customTag: String? = null, // 分类信息(用户修改)
var coverUrl: String? = null, // 封面Url(书源获取)
var customCoverUrl: String? = null, // 封面Url(用户修改)
@@ -42,7 +41,7 @@ data class Book(
var durChapterIndex: Int = 0, // 当前章节索引
var durChapterPos: Int = 0, // 当前阅读的进度(首行字符的索引位置)
var durChapterTime: Long = System.currentTimeMillis(), // 最近一次阅读书籍的时间(打开正文的时间)
- var wordCount: String? = null,
+ override var wordCount: String? = null,
var canUpdate: Boolean = true, // 刷新书架时更新书籍信息
var order: Int = 0, // 手动排序
var originOrder: Int = 0, //书源排序
@@ -79,18 +78,6 @@ data class Book(
variable = GSON.toJson(variableMap)
}
- 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
- }
-
fun toSearchBook(): SearchBook {
return SearchBook(
name = name,
diff --git a/app/src/main/java/io/legado/app/data/entities/SearchBook.kt b/app/src/main/java/io/legado/app/data/entities/SearchBook.kt
index 4423ff6f8..00efc0e47 100644
--- a/app/src/main/java/io/legado/app/data/entities/SearchBook.kt
+++ b/app/src/main/java/io/legado/app/data/entities/SearchBook.kt
@@ -20,10 +20,10 @@ data class SearchBook(
var originName: String = "",
var name: String = "",
var author: String = "",
- var kind: String? = null,
+ override var kind: String? = null,
var coverUrl: String? = null,
var intro: String? = null,
- var wordCount: String? = null,
+ override var wordCount: String? = null,
var latestChapterTitle: String? = null,
var tocUrl: String = "", // 目录页Url (toc=table of Contents)
var time: Long = System.currentTimeMillis(),
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 1611e04ac..faa7c3575 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,27 +1,19 @@
package io.legado.app.data.entities
-import io.legado.app.utils.splitNotBlank
-
data class SearchShow(
var name: String = "",
var author: String = "",
- var kind: String? = null,
+ override var kind: String? = null,
var coverUrl: String? = null,
var intro: String? = null,
- var wordCount: String? = null,
+ override var wordCount: String? = null,
var latestChapterTitle: String? = null,
var time: Long = 0L,
var originCount: Int = 0
-) {
- 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
+) : BaseBook {
+ override var variableMap: HashMap? = null
+
+ override fun putVariable(key: String, value: String) {
+
}
}
\ No newline at end of file
diff --git a/app/src/main/java/io/legado/app/ui/explore/DiffCallBack.kt b/app/src/main/java/io/legado/app/ui/explore/DiffCallBack.kt
new file mode 100644
index 000000000..1027dd31d
--- /dev/null
+++ b/app/src/main/java/io/legado/app/ui/explore/DiffCallBack.kt
@@ -0,0 +1,30 @@
+package io.legado.app.ui.explore
+
+import androidx.recyclerview.widget.DiffUtil
+import io.legado.app.data.entities.SearchShow
+
+class DiffCallBack : DiffUtil.ItemCallback() {
+ override fun areItemsTheSame(oldItem: SearchShow, newItem: SearchShow): Boolean {
+ return oldItem.name == newItem.name
+ && oldItem.author == newItem.author
+ }
+
+ override fun areContentsTheSame(oldItem: SearchShow, newItem: SearchShow): Boolean {
+ return oldItem.originCount == newItem.originCount
+ && (oldItem.coverUrl == newItem.coverUrl || !oldItem.coverUrl.isNullOrEmpty())
+ && (oldItem.kind == newItem.kind || !oldItem.kind.isNullOrEmpty())
+ && (oldItem.latestChapterTitle == newItem.latestChapterTitle || !oldItem.kind.isNullOrEmpty())
+ && oldItem.intro?.length ?: 0 > newItem.intro?.length ?: 0
+ }
+
+ override fun getChangePayload(oldItem: SearchShow, newItem: SearchShow): Any? {
+ return when {
+ oldItem.originCount != newItem.originCount -> 1
+ oldItem.coverUrl != newItem.coverUrl -> 2
+ oldItem.kind != newItem.kind -> 3
+ oldItem.latestChapterTitle != newItem.latestChapterTitle -> 4
+ oldItem.intro != newItem.intro -> 5
+ else -> null
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/io/legado/app/ui/explore/ExploreShowActivity.kt b/app/src/main/java/io/legado/app/ui/explore/ExploreShowActivity.kt
new file mode 100644
index 000000000..ba9930159
--- /dev/null
+++ b/app/src/main/java/io/legado/app/ui/explore/ExploreShowActivity.kt
@@ -0,0 +1,26 @@
+package io.legado.app.ui.explore
+
+import android.os.Bundle
+import io.legado.app.R
+import io.legado.app.base.BaseActivity
+import kotlinx.android.synthetic.main.activity_explore_show.*
+
+class ExploreShowActivity : BaseActivity(R.layout.activity_explore_show) {
+
+ override fun onActivityCreated(savedInstanceState: Bundle?) {
+ intent.getStringExtra("exploreName")?.let {
+ title_bar.title = it
+ }
+ initRecyclerView()
+ }
+
+ private fun initRecyclerView() {
+
+ }
+
+ private fun initData() {
+ val sourceUrl = intent.getStringExtra("sourceUrl")
+ val exploreUrl = intent.getStringExtra("exploreUrl")
+ }
+
+}
\ No newline at end of file
diff --git a/app/src/main/java/io/legado/app/ui/explore/ExploreShowAdapter.kt b/app/src/main/java/io/legado/app/ui/explore/ExploreShowAdapter.kt
new file mode 100644
index 000000000..a9f8bf4d0
--- /dev/null
+++ b/app/src/main/java/io/legado/app/ui/explore/ExploreShowAdapter.kt
@@ -0,0 +1,75 @@
+package io.legado.app.ui.explore
+
+import android.content.Context
+import io.legado.app.R
+import io.legado.app.base.adapter.ItemViewHolder
+import io.legado.app.base.adapter.SimpleRecyclerAdapter
+import io.legado.app.data.entities.SearchBook
+import io.legado.app.help.ImageLoader
+import io.legado.app.utils.gone
+import io.legado.app.utils.visible
+import kotlinx.android.synthetic.main.item_bookshelf_list.view.iv_cover
+import kotlinx.android.synthetic.main.item_bookshelf_list.view.tv_name
+import kotlinx.android.synthetic.main.item_search.view.*
+import org.jetbrains.anko.sdk27.listeners.onClick
+
+class ExploreShowAdapter(context: Context, val callBack: CallBack) :
+ SimpleRecyclerAdapter(context, R.layout.item_search) {
+
+ override fun convert(holder: ItemViewHolder, item: SearchBook, payloads: MutableList) =
+ with(holder.itemView) {
+ tv_name.text = item.name
+ tv_author.text = context.getString(R.string.author_show, item.author)
+ if (item.latestChapterTitle.isNullOrEmpty()) {
+ tv_lasted.gone()
+ } else {
+ tv_lasted.text = context.getString(R.string.lasted_show, item.latestChapterTitle)
+ tv_lasted.visible()
+ }
+ tv_introduce.text = context.getString(R.string.intro_show, item.intro)
+ val kinds = item.getKindList()
+ if (kinds.isEmpty()) {
+ ll_kind.gone()
+ } else {
+ ll_kind.visible()
+ for (index in 0..2) {
+ if (kinds.size > index) {
+ when (index) {
+ 0 -> {
+ tv_kind.text = kinds[index]
+ tv_kind.visible()
+ }
+ 1 -> {
+ tv_kind_1.text = kinds[index]
+ tv_kind_1.visible()
+ }
+ 2 -> {
+ tv_kind_2.text = kinds[index]
+ tv_kind_2.visible()
+ }
+ }
+ } else {
+ when (index) {
+ 0 -> tv_kind.gone()
+ 1 -> tv_kind_1.gone()
+ 2 -> tv_kind_2.gone()
+ }
+ }
+ }
+ }
+ item.coverUrl.let {
+ ImageLoader.load(context, it)//Glide自动识别http://和file://
+ .placeholder(R.drawable.img_cover_default)
+ .error(R.drawable.img_cover_default)
+ .centerCrop()
+ .setAsDrawable(iv_cover)
+ }
+ onClick {
+ callBack.showBookInfo(item.name, item.author)
+ }
+ }
+
+ interface CallBack {
+ fun showBookInfo(name: String, author: String)
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/io/legado/app/ui/search/SearchActivity.kt b/app/src/main/java/io/legado/app/ui/search/SearchActivity.kt
index c521d56b1..4f0623009 100644
--- a/app/src/main/java/io/legado/app/ui/search/SearchActivity.kt
+++ b/app/src/main/java/io/legado/app/ui/search/SearchActivity.kt
@@ -70,8 +70,7 @@ class SearchActivity : VMBaseActivity(R.layout.activity_search)
private fun initRecyclerView() {
ATH.applyEdgeEffectColor(rv_search_list)
- adapter = SearchAdapter()
- adapter.callBack = this
+ adapter = SearchAdapter(this)
rv_search_list.layoutManager = LinearLayoutManager(this)
rv_search_list.adapter = adapter
}
diff --git a/app/src/main/java/io/legado/app/ui/search/SearchAdapter.kt b/app/src/main/java/io/legado/app/ui/search/SearchAdapter.kt
index 6ee7337eb..0b40007ff 100644
--- a/app/src/main/java/io/legado/app/ui/search/SearchAdapter.kt
+++ b/app/src/main/java/io/legado/app/ui/search/SearchAdapter.kt
@@ -15,9 +15,8 @@ import kotlinx.android.synthetic.main.item_bookshelf_list.view.tv_name
import kotlinx.android.synthetic.main.item_search.view.*
import org.jetbrains.anko.sdk27.listeners.onClick
-class SearchAdapter : PagedListAdapter(DiffCallBack()) {
-
- var callBack: CallBack? = null
+class SearchAdapter(val callBack: CallBack) :
+ PagedListAdapter(DiffCallBack()) {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyViewHolder {
return MyViewHolder(LayoutInflater.from(parent.context).inflate(R.layout.item_search, parent, false))
diff --git a/app/src/main/res/layout/activity_explore_show.xml b/app/src/main/res/layout/activity_explore_show.xml
new file mode 100644
index 000000000..7419b0de8
--- /dev/null
+++ b/app/src/main/res/layout/activity_explore_show.xml
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file