feat: 优化代码

pull/103/head
kunfei 5 years ago
parent 87481f12a1
commit 6d4fcd0f18
  1. 4
      app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksAdapterList.kt
  2. 6
      app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksDiffCallBack.kt

@ -38,8 +38,8 @@ class BooksAdapterList(context: Context, private val callBack: CallBack) :
when (it) { when (it) {
"name" -> tv_name.text = item.name "name" -> tv_name.text = item.name
"author" -> tv_author.text = item.author "author" -> tv_author.text = item.author
"durTitle" -> tv_read.text = item.durChapterTitle "dur" -> tv_read.text = item.durChapterTitle
"latestTitle" -> tv_last.text = item.latestChapterTitle "last" -> tv_last.text = item.latestChapterTitle
"cover" -> iv_cover.load(item.getDisplayCover(), item.name, item.author) "cover" -> iv_cover.load(item.getDisplayCover(), item.name, item.author)
"refresh" -> if (item.origin != BookType.local && callBack.isUpdate(item.bookUrl)) { "refresh" -> if (item.origin != BookType.local && callBack.isUpdate(item.bookUrl)) {
bv_unread.invisible() bv_unread.invisible()

@ -48,11 +48,13 @@ class BooksDiffCallBack(private val oldItems: List<Book>, private val newItems:
if (oldItem.author != newItem.author) if (oldItem.author != newItem.author)
bundle.putString("author", null) bundle.putString("author", null)
if (oldItem.durChapterTitle != newItem.durChapterTitle) if (oldItem.durChapterTitle != newItem.durChapterTitle)
bundle.putString("durTitle", null) bundle.putString("dur", null)
if (oldItem.latestChapterTitle != newItem.latestChapterTitle) if (oldItem.latestChapterTitle != newItem.latestChapterTitle)
bundle.putString("latestTitle", null) bundle.putString("last", null)
if (oldItem.getDisplayCover() != newItem.getDisplayCover()) if (oldItem.getDisplayCover() != newItem.getDisplayCover())
bundle.putString("cover", null) bundle.putString("cover", null)
if (oldItem.lastCheckCount != newItem.lastCheckCount)
bundle.putString("refresh", null)
if (oldItem.getUnreadChapterNum() != newItem.getUnreadChapterNum() if (oldItem.getUnreadChapterNum() != newItem.getUnreadChapterNum()
|| oldItem.lastCheckCount != newItem.lastCheckCount || oldItem.lastCheckCount != newItem.lastCheckCount
) { ) {

Loading…
Cancel
Save