Revert "书架动画与性能优化 #291"
This commit is contained in:
@@ -124,7 +124,9 @@ class BooksFragment() : BaseFragment(R.layout.fragment_books),
|
||||
}
|
||||
|
||||
private fun initRecyclerView() {
|
||||
//binding.rvBookshelf.setEdgeEffectColor(primaryColor)
|
||||
upFastScrollerBar()
|
||||
//binding.refreshLayout.setColorSchemeColors(accentColor)
|
||||
binding.refreshLayout.setOnRefreshListener {
|
||||
val books = booksAdapter.getItems()
|
||||
val refreshList = if (AppConfig.bookshelfRefreshingLimit > 0) {
|
||||
@@ -281,6 +283,8 @@ class BooksFragment() : BaseFragment(R.layout.fragment_books),
|
||||
/**
|
||||
* 将 RecyclerView 中的视图全部回收到 RecycledViewPool 中
|
||||
*/
|
||||
upLastUpdateTimeJob?.cancel()
|
||||
booksFlowJob?.cancel()
|
||||
binding.rvBookshelf.setItemViewCacheSize(0)
|
||||
binding.rvBookshelf.adapter = null
|
||||
}
|
||||
|
||||
+1
-1
@@ -84,7 +84,7 @@ abstract class BaseBooksAdapter<VB : ViewBinding>(context: Context) :
|
||||
fun notification(bookUrl: String) {
|
||||
getItems().forEachIndexed { i, it ->
|
||||
if (it.bookUrl == bookUrl) {
|
||||
notifyItemChanged(i, bundleOf(Pair("refresh", null), Pair("lastUpdateTime", null)))
|
||||
notifyItemChanged(i, bundleOf("refresh" to true, "lastUpdateTime" to true))
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
+7
-8
@@ -9,7 +9,6 @@ import io.legado.app.databinding.ItemBookshelfGridBinding
|
||||
import io.legado.app.help.book.isLocal
|
||||
import io.legado.app.help.config.AppConfig
|
||||
import io.legado.app.utils.gone
|
||||
import io.legado.app.utils.invisible
|
||||
import io.legado.app.utils.visible
|
||||
|
||||
class BooksAdapterGrid(context: Context, private val callBack: CallBack) :
|
||||
@@ -45,7 +44,7 @@ class BooksAdapterGrid(context: Context, private val callBack: CallBack) :
|
||||
|
||||
private fun upRefresh(binding: ItemBookshelfGridBinding, item: Book) {
|
||||
if (!item.isLocal && callBack.isUpdate(item.bookUrl)) {
|
||||
binding.cdUnread.invisible()
|
||||
binding.cdUnread.gone()
|
||||
binding.rlLoading.visible()
|
||||
} else {
|
||||
binding.rlLoading.gone()
|
||||
@@ -55,25 +54,25 @@ class BooksAdapterGrid(context: Context, private val callBack: CallBack) :
|
||||
binding.cdUnread.visible()
|
||||
binding.tvUnread.text = unreadCount.toString()
|
||||
} else {
|
||||
binding.cdUnread.invisible()
|
||||
binding.cdUnread.gone()
|
||||
}
|
||||
} else {
|
||||
binding.cdUnread.invisible()
|
||||
binding.cdUnread.gone()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun registerListener(holder: ItemViewHolder, binding: ItemBookshelfGridBinding) {
|
||||
|
||||
holder.itemView.setOnClickListener {
|
||||
binding.cvContent.setOnClickListener {
|
||||
getItem(holder.layoutPosition)?.let {
|
||||
callBack.open(it, binding.root)
|
||||
callBack.open(it, binding.cdCover)
|
||||
}
|
||||
}
|
||||
|
||||
holder.itemView.setOnLongClickListener {
|
||||
binding.cvContent.setOnLongClickListener {
|
||||
getItem(holder.layoutPosition)?.let {
|
||||
callBack.openBookInfo(it, binding.root)
|
||||
callBack.openBookInfo(it, binding.cdCover)
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
+4
-4
@@ -73,15 +73,15 @@ class BooksAdapterGridCompact(context: Context, private val callBack: CallBack)
|
||||
binding: ItemBookshelfGridCompactBinding
|
||||
) {
|
||||
|
||||
holder.itemView.setOnClickListener {
|
||||
binding.cvContent.setOnClickListener {
|
||||
getItem(holder.layoutPosition)?.let {
|
||||
callBack.open(it, binding.root)
|
||||
callBack.open(it, binding.cvContent)
|
||||
}
|
||||
}
|
||||
|
||||
holder.itemView.setOnLongClickListener {
|
||||
binding.cvContent.setOnLongClickListener {
|
||||
getItem(holder.layoutPosition)?.let {
|
||||
callBack.openBookInfo(it, binding.root)
|
||||
callBack.openBookInfo(it, binding.cvContent)
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
+4
-4
@@ -74,15 +74,15 @@ class BooksAdapterGridCover(context: Context, private val callBack: CallBack) :
|
||||
binding: ItemBookshelfGridCompactBinding
|
||||
) {
|
||||
|
||||
holder.itemView.setOnClickListener {
|
||||
binding.cvContent.setOnClickListener {
|
||||
getItem(holder.layoutPosition)?.let {
|
||||
callBack.open(it, binding.root)
|
||||
callBack.open(it, binding.cvContent)
|
||||
}
|
||||
}
|
||||
|
||||
holder.itemView.setOnLongClickListener {
|
||||
binding.cvContent.setOnLongClickListener {
|
||||
getItem(holder.layoutPosition)?.let {
|
||||
callBack.openBookInfo(it, binding.root)
|
||||
callBack.openBookInfo(it, binding.cvContent)
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
+2
-2
@@ -108,13 +108,13 @@ class BooksAdapterListCompact(
|
||||
holder.itemView.apply {
|
||||
binding.cvContent.setOnClickListener {
|
||||
getItem(holder.layoutPosition)?.let {
|
||||
callBack.open(it, binding.cvContent)
|
||||
callBack.open(it, binding.cdCover)
|
||||
}
|
||||
}
|
||||
|
||||
binding.cvContent.onLongClick {
|
||||
getItem(holder.layoutPosition)?.let {
|
||||
callBack.openBookInfo(it, binding.cvContent)
|
||||
callBack.openBookInfo(it, binding.cdCover)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -111,10 +111,10 @@ class BooksAdapterListCompact(context: Context, callBack: CallBack) :
|
||||
|
||||
fun registerListener(item: Any) {
|
||||
binding.cvContent.setOnClickListener {
|
||||
callBack.onItemClick(item, binding.cvContent)
|
||||
callBack.onItemClick(item, binding.cdCover)
|
||||
}
|
||||
binding.cvContent.onLongClick {
|
||||
callBack.onItemLongClick(item, binding.cvContent)
|
||||
callBack.onItemLongClick(item, binding.cdCover)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user