书架动画与性能优化 #291
This commit is contained in:
7 files changed
+4
-7
No files matched your search
@@ -187,10 +187,12 @@ class BooksFragment() : BaseFragment(R.layout.fragment_books),
|
|||||||
|
|
||||||
fun upBookSort(sort: Int) {
|
fun upBookSort(sort: Int) {
|
||||||
if (!isAdded || view == null) return
|
if (!isAdded || view == null) return
|
||||||
|
binding.root.post {
|
||||||
arguments?.putInt("bookSort", sort)
|
arguments?.putInt("bookSort", sort)
|
||||||
bookSort = sort
|
bookSort = sort
|
||||||
upRecyclerData()
|
upRecyclerData()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun setEnableRefresh(enable: Boolean) {
|
fun setEnableRefresh(enable: Boolean) {
|
||||||
enableRefresh = enable
|
enableRefresh = enable
|
||||||
@@ -246,6 +248,7 @@ class BooksFragment() : BaseFragment(R.layout.fragment_books),
|
|||||||
binding.emptyView.isGone = list.isNotEmpty()
|
binding.emptyView.isGone = list.isNotEmpty()
|
||||||
binding.refreshLayout.isEnabled = enableRefresh && list.isNotEmpty()
|
binding.refreshLayout.isEnabled = enableRefresh && list.isNotEmpty()
|
||||||
booksAdapter.setItems(list)
|
booksAdapter.setItems(list)
|
||||||
|
delay(100)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-2
@@ -18,8 +18,7 @@ abstract class BaseBooksAdapter<VB : ViewBinding>(context: Context) :
|
|||||||
object : DiffUtil.ItemCallback<Book>() {
|
object : DiffUtil.ItemCallback<Book>() {
|
||||||
|
|
||||||
override fun areItemsTheSame(oldItem: Book, newItem: Book): Boolean {
|
override fun areItemsTheSame(oldItem: Book, newItem: Book): Boolean {
|
||||||
return oldItem.bookUrl == newItem.bookUrl &&
|
return oldItem.bookUrl == newItem.bookUrl
|
||||||
oldItem.durChapterTime == newItem.durChapterTime
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun areContentsTheSame(oldItem: Book, newItem: Book): Boolean {
|
override fun areContentsTheSame(oldItem: Book, newItem: Book): Boolean {
|
||||||
|
|||||||
-1
@@ -24,7 +24,6 @@ class BooksAdapterGrid(context: Context, private val callBack: CallBack) :
|
|||||||
item: Book,
|
item: Book,
|
||||||
payloads: MutableList<Any>
|
payloads: MutableList<Any>
|
||||||
) = binding.run {
|
) = binding.run {
|
||||||
binding.cdCover.transitionName = "book_${item.bookUrl}"
|
|
||||||
if (payloads.isEmpty()) {
|
if (payloads.isEmpty()) {
|
||||||
tvName.text = item.name
|
tvName.text = item.name
|
||||||
ivCover.load(item.getDisplayCover(), item.name, item.author, false, item.origin)
|
ivCover.load(item.getDisplayCover(), item.name, item.author, false, item.origin)
|
||||||
|
|||||||
-1
@@ -23,7 +23,6 @@ class BooksAdapterGridCompact(context: Context, private val callBack: CallBack)
|
|||||||
item: Book,
|
item: Book,
|
||||||
payloads: MutableList<Any>
|
payloads: MutableList<Any>
|
||||||
) = binding.run {
|
) = binding.run {
|
||||||
binding.cvContent.transitionName = "book_${item.bookUrl}"
|
|
||||||
if (payloads.isEmpty()) {
|
if (payloads.isEmpty()) {
|
||||||
tvName.text = item.name
|
tvName.text = item.name
|
||||||
ivCover.load(item.getDisplayCover(), item.name, item.author, false, item.origin)
|
ivCover.load(item.getDisplayCover(), item.name, item.author, false, item.origin)
|
||||||
|
|||||||
-1
@@ -24,7 +24,6 @@ class BooksAdapterGridCover(context: Context, private val callBack: CallBack) :
|
|||||||
item: Book,
|
item: Book,
|
||||||
payloads: MutableList<Any>
|
payloads: MutableList<Any>
|
||||||
) = binding.run {
|
) = binding.run {
|
||||||
binding.cvContent.transitionName = "book_${item.bookUrl}"
|
|
||||||
if (payloads.isEmpty()) {
|
if (payloads.isEmpty()) {
|
||||||
tvName.gone()
|
tvName.gone()
|
||||||
ivCover.load(item.getDisplayCover(), item.name, item.author, false, item.origin)
|
ivCover.load(item.getDisplayCover(), item.name, item.author, false, item.origin)
|
||||||
|
|||||||
-1
@@ -33,7 +33,6 @@ class BooksAdapterList(
|
|||||||
item: Book,
|
item: Book,
|
||||||
payloads: MutableList<Any>
|
payloads: MutableList<Any>
|
||||||
) = binding.run {
|
) = binding.run {
|
||||||
binding.cdCover.transitionName = "book_${item.bookUrl}"
|
|
||||||
if (payloads.isEmpty()) {
|
if (payloads.isEmpty()) {
|
||||||
tvName.text = item.name
|
tvName.text = item.name
|
||||||
tvAuthor.text = item.author
|
tvAuthor.text = item.author
|
||||||
|
|||||||
-1
@@ -34,7 +34,6 @@ class BooksAdapterListCompact(
|
|||||||
item: Book,
|
item: Book,
|
||||||
payloads: MutableList<Any>
|
payloads: MutableList<Any>
|
||||||
) = binding.run {
|
) = binding.run {
|
||||||
binding.cdCover.transitionName = "book_${item.bookUrl}"
|
|
||||||
if (payloads.isEmpty()) {
|
if (payloads.isEmpty()) {
|
||||||
tvName.text = item.name
|
tvName.text = item.name
|
||||||
tvAuthor.text =
|
tvAuthor.text =
|
||||||
|
|||||||
Reference in new issue
Block a user