书架动画与性能优化 #291
This commit is contained in:
@@ -127,9 +127,7 @@ 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) {
|
||||
@@ -289,8 +287,6 @@ class BooksFragment() : BaseFragment(R.layout.fragment_books),
|
||||
/**
|
||||
* 将 RecyclerView 中的视图全部回收到 RecycledViewPool 中
|
||||
*/
|
||||
upLastUpdateTimeJob?.cancel()
|
||||
booksFlowJob?.cancel()
|
||||
binding.rvBookshelf.setItemViewCacheSize(0)
|
||||
binding.rvBookshelf.adapter = null
|
||||
}
|
||||
|
||||
+1
-1
@@ -77,7 +77,7 @@ abstract class BaseBooksAdapter<VB : ViewBinding>(context: Context) :
|
||||
fun notification(bookUrl: String) {
|
||||
getItems().forEachIndexed { i, it ->
|
||||
if (it.bookUrl == bookUrl) {
|
||||
notifyItemChanged(i, bundleOf("refresh" to true, "lastUpdateTime" to true))
|
||||
notifyItemChanged(i, bundleOf(Pair("refresh", null), Pair("lastUpdateTime", null)))
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
+8
-7
@@ -9,6 +9,7 @@ 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) :
|
||||
@@ -44,7 +45,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.gone()
|
||||
binding.cdUnread.invisible()
|
||||
binding.rlLoading.visible()
|
||||
} else {
|
||||
binding.rlLoading.gone()
|
||||
@@ -54,25 +55,25 @@ class BooksAdapterGrid(context: Context, private val callBack: CallBack) :
|
||||
binding.cdUnread.visible()
|
||||
binding.tvUnread.text = unreadCount.toString()
|
||||
} else {
|
||||
binding.cdUnread.gone()
|
||||
binding.cdUnread.invisible()
|
||||
}
|
||||
} else {
|
||||
binding.cdUnread.gone()
|
||||
binding.cdUnread.invisible()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun registerListener(holder: ItemViewHolder, binding: ItemBookshelfGridBinding) {
|
||||
|
||||
binding.cvContent.setOnClickListener {
|
||||
holder.itemView.setOnClickListener {
|
||||
getItem(holder.layoutPosition)?.let {
|
||||
callBack.open(it, binding.cdCover)
|
||||
callBack.open(it, binding.root)
|
||||
}
|
||||
}
|
||||
|
||||
binding.cvContent.setOnLongClickListener {
|
||||
holder.itemView.setOnLongClickListener {
|
||||
getItem(holder.layoutPosition)?.let {
|
||||
callBack.openBookInfo(it, binding.cdCover)
|
||||
callBack.openBookInfo(it, binding.root)
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
+4
-4
@@ -73,15 +73,15 @@ class BooksAdapterGridCompact(context: Context, private val callBack: CallBack)
|
||||
binding: ItemBookshelfGridCompactBinding
|
||||
) {
|
||||
|
||||
binding.cvContent.setOnClickListener {
|
||||
holder.itemView.setOnClickListener {
|
||||
getItem(holder.layoutPosition)?.let {
|
||||
callBack.open(it, binding.cvContent)
|
||||
callBack.open(it, binding.root)
|
||||
}
|
||||
}
|
||||
|
||||
binding.cvContent.setOnLongClickListener {
|
||||
holder.itemView.setOnLongClickListener {
|
||||
getItem(holder.layoutPosition)?.let {
|
||||
callBack.openBookInfo(it, binding.cvContent)
|
||||
callBack.openBookInfo(it, binding.root)
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
+4
-4
@@ -74,15 +74,15 @@ class BooksAdapterGridCover(context: Context, private val callBack: CallBack) :
|
||||
binding: ItemBookshelfGridCompactBinding
|
||||
) {
|
||||
|
||||
binding.cvContent.setOnClickListener {
|
||||
holder.itemView.setOnClickListener {
|
||||
getItem(holder.layoutPosition)?.let {
|
||||
callBack.open(it, binding.cvContent)
|
||||
callBack.open(it, binding.root)
|
||||
}
|
||||
}
|
||||
|
||||
binding.cvContent.setOnLongClickListener {
|
||||
holder.itemView.setOnLongClickListener {
|
||||
getItem(holder.layoutPosition)?.let {
|
||||
callBack.openBookInfo(it, binding.cvContent)
|
||||
callBack.openBookInfo(it, binding.root)
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
+2
-2
@@ -104,13 +104,13 @@ class BooksAdapterList(
|
||||
holder.itemView.apply {
|
||||
binding.cvContent.setOnClickListener {
|
||||
getItem(holder.layoutPosition)?.let {
|
||||
callBack.open(it, binding.cdCover)
|
||||
callBack.open(it, binding.cvContent)
|
||||
}
|
||||
}
|
||||
|
||||
binding.cvContent.onLongClick {
|
||||
getItem(holder.layoutPosition)?.let {
|
||||
callBack.openBookInfo(it, binding.cdCover)
|
||||
callBack.openBookInfo(it, binding.cvContent)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -108,13 +108,13 @@ class BooksAdapterListCompact(
|
||||
holder.itemView.apply {
|
||||
binding.cvContent.setOnClickListener {
|
||||
getItem(holder.layoutPosition)?.let {
|
||||
callBack.open(it, binding.cdCover)
|
||||
callBack.open(it, binding.cvContent)
|
||||
}
|
||||
}
|
||||
|
||||
binding.cvContent.onLongClick {
|
||||
getItem(holder.layoutPosition)?.let {
|
||||
callBack.openBookInfo(it, binding.cdCover)
|
||||
callBack.openBookInfo(it, binding.cvContent)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -113,10 +113,10 @@ class BooksAdapterList(context: Context, callBack: CallBack) :
|
||||
|
||||
fun registerListener(item: Any) {
|
||||
binding.cvContent.setOnClickListener {
|
||||
callBack.onItemClick(item, binding.cdCover)
|
||||
callBack.onItemClick(item, binding.cvContent)
|
||||
}
|
||||
binding.cvContent.onLongClick {
|
||||
callBack.onItemLongClick(item, binding.cdCover)
|
||||
callBack.onItemLongClick(item, binding.cvContent)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -111,10 +111,10 @@ class BooksAdapterListCompact(context: Context, callBack: CallBack) :
|
||||
|
||||
fun registerListener(item: Any) {
|
||||
binding.cvContent.setOnClickListener {
|
||||
callBack.onItemClick(item, binding.cdCover)
|
||||
callBack.onItemClick(item, binding.cvContent)
|
||||
}
|
||||
binding.cvContent.onLongClick {
|
||||
callBack.onItemLongClick(item, binding.cdCover)
|
||||
callBack.onItemLongClick(item, binding.cvContent)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user