From 3d34edf4e64b70bf6a90ee4e9f265b702ff23f82 Mon Sep 17 00:00:00 2001 From: gedoor Date: Sat, 31 Jul 2021 21:24:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/bookshelf/style2/BooksAdapterGrid.kt | 28 +++++++-------- .../main/bookshelf/style2/BooksAdapterList.kt | 34 ++++++++----------- 2 files changed, 27 insertions(+), 35 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/style2/BooksAdapterGrid.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/style2/BooksAdapterGrid.kt index fc78d79cd..fa1957ba5 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/style2/BooksAdapterGrid.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/style2/BooksAdapterGrid.kt @@ -54,27 +54,23 @@ class BooksAdapterGrid(context: Context, callBack: CallBack) : private fun onBindGroup(binding: ItemBookshelfGridGroupBinding, position: Int, bundle: Bundle) { binding.run { - val item = callBack.getItem(position) - if (item is BookGroup) { - tvName.text = item.groupName - } + val item = callBack.getItem(position) as BookGroup + tvName.text = item.groupName } } private fun onBindBook(binding: ItemBookshelfGridBinding, position: Int, bundle: Bundle) { binding.run { - val item = callBack.getItem(position) - if (item is Book) { - bundle.keySet().forEach { - when (it) { - "name" -> tvName.text = item.name - "cover" -> ivCover.load( - item.getDisplayCover(), - item.name, - item.author - ) - "refresh" -> upRefresh(this, item) - } + val item = callBack.getItem(position) as Book + bundle.keySet().forEach { + when (it) { + "name" -> tvName.text = item.name + "cover" -> ivCover.load( + item.getDisplayCover(), + item.name, + item.author + ) + "refresh" -> upRefresh(this, item) } } } diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/style2/BooksAdapterList.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/style2/BooksAdapterList.kt index 461991628..962bfd0e9 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/style2/BooksAdapterList.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/style2/BooksAdapterList.kt @@ -53,30 +53,26 @@ class BooksAdapterList(context: Context, callBack: CallBack) : private fun onBindGroup(binding: ItemBookshelfListGroupBinding, position: Int, bundle: Bundle) { binding.run { - val item = callBack.getItem(position) - if (item is BookGroup) { - tvName.text = item.groupName - } + val item = callBack.getItem(position) as BookGroup + tvName.text = item.groupName } } private fun onBindBook(binding: ItemBookshelfListBinding, position: Int, bundle: Bundle) { binding.run { - val item = callBack.getItem(position) - if (item is Book) { - tvRead.text = item.durChapterTitle - tvLast.text = item.latestChapterTitle - bundle.keySet().forEach { - when (it) { - "name" -> tvName.text = item.name - "author" -> tvAuthor.text = item.author - "cover" -> ivCover.load( - item.getDisplayCover(), - item.name, - item.author - ) - "refresh" -> upRefresh(this, item) - } + val item = callBack.getItem(position) as Book + tvRead.text = item.durChapterTitle + tvLast.text = item.latestChapterTitle + bundle.keySet().forEach { + when (it) { + "name" -> tvName.text = item.name + "author" -> tvAuthor.text = item.author + "cover" -> ivCover.load( + item.getDisplayCover(), + item.name, + item.author + ) + "refresh" -> upRefresh(this, item) } } }