pull/32/head
kunfei 5 years ago
parent 6da676f74e
commit 22d2807a9c
  1. 30
      app/src/main/java/io/legado/app/ui/explore/DiffCallBack.kt
  2. 16
      app/src/main/java/io/legado/app/ui/explore/ExploreShowActivity.kt
  3. 6
      app/src/main/java/io/legado/app/ui/search/SearchActivity.kt
  4. 2
      app/src/main/res/layout/activity_explore_show.xml
  5. 2
      app/src/main/res/layout/activity_search.xml

@ -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<SearchShow>() {
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
}
}
}

@ -1,11 +1,17 @@
package io.legado.app.ui.explore package io.legado.app.ui.explore
import android.os.Bundle 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.R
import io.legado.app.base.BaseActivity import io.legado.app.base.BaseActivity
import kotlinx.android.synthetic.main.activity_explore_show.* 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?) { override fun onActivityCreated(savedInstanceState: Bundle?) {
intent.getStringExtra("exploreName")?.let { intent.getStringExtra("exploreName")?.let {
@ -15,7 +21,10 @@ class ExploreShowActivity : BaseActivity(R.layout.activity_explore_show) {
} }
private fun initRecyclerView() { 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() { private fun initData() {
@ -23,4 +32,7 @@ class ExploreShowActivity : BaseActivity(R.layout.activity_explore_show) {
val exploreUrl = intent.getStringExtra("exploreUrl") val exploreUrl = intent.getStringExtra("exploreUrl")
} }
override fun showBookInfo(name: String, author: String) {
}
} }

@ -69,10 +69,10 @@ class SearchActivity : VMBaseActivity<SearchViewModel>(R.layout.activity_search)
} }
private fun initRecyclerView() { private fun initRecyclerView() {
ATH.applyEdgeEffectColor(rv_search_list) ATH.applyEdgeEffectColor(recycler_view)
adapter = SearchAdapter(this) adapter = SearchAdapter(this)
rv_search_list.layoutManager = LinearLayoutManager(this) recycler_view.layoutManager = LinearLayoutManager(this)
rv_search_list.adapter = adapter recycler_view.adapter = adapter
} }
private fun initData() { private fun initData() {

@ -24,7 +24,7 @@
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_search_list" android:id="@+id/recycler_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" /> android:layout_height="match_parent" />

@ -25,7 +25,7 @@
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_search_list" android:id="@+id/recycler_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"/> android:layout_height="match_parent"/>

Loading…
Cancel
Save