From 22d2807a9c00cbb1cce3c98aceb0267d4bb57276 Mon Sep 17 00:00:00 2001 From: kunfei Date: Wed, 4 Sep 2019 17:39:12 +0800 Subject: [PATCH] up --- .../io/legado/app/ui/explore/DiffCallBack.kt | 30 ------------------- .../app/ui/explore/ExploreShowActivity.kt | 16 ++++++++-- .../io/legado/app/ui/search/SearchActivity.kt | 6 ++-- .../main/res/layout/activity_explore_show.xml | 2 +- app/src/main/res/layout/activity_search.xml | 2 +- 5 files changed, 19 insertions(+), 37 deletions(-) delete mode 100644 app/src/main/java/io/legado/app/ui/explore/DiffCallBack.kt 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 deleted file mode 100644 index 1027dd31d..000000000 --- a/app/src/main/java/io/legado/app/ui/explore/DiffCallBack.kt +++ /dev/null @@ -1,30 +0,0 @@ -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 index ba9930159..9b9566f96 100644 --- a/app/src/main/java/io/legado/app/ui/explore/ExploreShowActivity.kt +++ b/app/src/main/java/io/legado/app/ui/explore/ExploreShowActivity.kt @@ -1,11 +1,17 @@ package io.legado.app.ui.explore import android.os.Bundle +import androidx.recyclerview.widget.DividerItemDecoration +import androidx.recyclerview.widget.LinearLayoutManager +import androidx.recyclerview.widget.RecyclerView 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) { +class ExploreShowActivity : BaseActivity(R.layout.activity_explore_show), + ExploreShowAdapter.CallBack { + + private lateinit var adapter: ExploreShowAdapter override fun onActivityCreated(savedInstanceState: Bundle?) { intent.getStringExtra("exploreName")?.let { @@ -15,7 +21,10 @@ class ExploreShowActivity : BaseActivity(R.layout.activity_explore_show) { } private fun initRecyclerView() { - + adapter = ExploreShowAdapter(this, this) + recycler_view.layoutManager = LinearLayoutManager(this) + recycler_view.addItemDecoration(DividerItemDecoration(this, RecyclerView.VERTICAL)) + recycler_view.adapter = adapter } private fun initData() { @@ -23,4 +32,7 @@ class ExploreShowActivity : BaseActivity(R.layout.activity_explore_show) { val exploreUrl = intent.getStringExtra("exploreUrl") } + override 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 4f0623009..d8b9cdf7e 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 @@ -69,10 +69,10 @@ class SearchActivity : VMBaseActivity(R.layout.activity_search) } private fun initRecyclerView() { - ATH.applyEdgeEffectColor(rv_search_list) + ATH.applyEdgeEffectColor(recycler_view) adapter = SearchAdapter(this) - rv_search_list.layoutManager = LinearLayoutManager(this) - rv_search_list.adapter = adapter + recycler_view.layoutManager = LinearLayoutManager(this) + recycler_view.adapter = adapter } private fun initData() { diff --git a/app/src/main/res/layout/activity_explore_show.xml b/app/src/main/res/layout/activity_explore_show.xml index 7419b0de8..9637cd8b0 100644 --- a/app/src/main/res/layout/activity_explore_show.xml +++ b/app/src/main/res/layout/activity_explore_show.xml @@ -24,7 +24,7 @@ diff --git a/app/src/main/res/layout/activity_search.xml b/app/src/main/res/layout/activity_search.xml index 296dc6b9f..df00899cd 100644 --- a/app/src/main/res/layout/activity_search.xml +++ b/app/src/main/res/layout/activity_search.xml @@ -25,7 +25,7 @@