Horis 2 лет назад
Родитель
Сommit
8571542578

+ 12 - 10
app/src/main/java/io/legado/app/ui/book/changesource/ChangeBookSourceAdapter.kt

@@ -53,9 +53,8 @@ class ChangeBookSourceAdapter(
         item: SearchBook,
         payloads: MutableList<Any>
     ) {
-        val bundle = payloads.getOrNull(0) as? Bundle
         binding.apply {
-            if (bundle == null) {
+            if (payloads.isEmpty()) {
                 tvOrigin.text = item.originName
                 tvAuthor.text = item.author
                 tvLast.text = item.getDisplayLastChapterTitle()
@@ -67,14 +66,17 @@ class ChangeBookSourceAdapter(
                     ivChecked.invisible()
                 }
             } else {
-                bundle.keySet().map {
-                    when (it) {
-                        "name" -> tvOrigin.text = item.originName
-                        "latest" -> tvLast.text = item.getDisplayLastChapterTitle()
-                        "upCurSource" -> if (callBack.oldBookUrl == item.bookUrl) {
-                            ivChecked.visible()
-                        } else {
-                            ivChecked.invisible()
+                for (i in payloads.indices) {
+                    val bundle = payloads[i] as Bundle
+                    bundle.keySet().map {
+                        when (it) {
+                            "name" -> tvOrigin.text = item.originName
+                            "latest" -> tvLast.text = item.getDisplayLastChapterTitle()
+                            "upCurSource" -> if (callBack.oldBookUrl == item.bookUrl) {
+                                ivChecked.visible()
+                            } else {
+                                ivChecked.invisible()
+                            }
                         }
                     }
                 }

+ 12 - 10
app/src/main/java/io/legado/app/ui/book/changesource/ChangeChapterSourceAdapter.kt

@@ -50,9 +50,8 @@ class ChangeChapterSourceAdapter(
         item: SearchBook,
         payloads: MutableList<Any>
     ) {
-        val bundle = payloads.getOrNull(0) as? Bundle
         binding.apply {
-            if (bundle == null) {
+            if (payloads.isEmpty()) {
                 tvOrigin.text = item.originName
                 tvAuthor.text = item.author
                 tvLast.text = item.getDisplayLastChapterTitle()
@@ -64,14 +63,17 @@ class ChangeChapterSourceAdapter(
                     ivChecked.invisible()
                 }
             } else {
-                bundle.keySet().map {
-                    when (it) {
-                        "name" -> tvOrigin.text = item.originName
-                        "latest" -> tvLast.text = item.getDisplayLastChapterTitle()
-                        "upCurSource" -> if (callBack.oldBookUrl == item.bookUrl) {
-                            ivChecked.visible()
-                        } else {
-                            ivChecked.invisible()
+                for (i in payloads.indices) {
+                    val bundle = payloads[i] as Bundle
+                    bundle.keySet().map {
+                        when (it) {
+                            "name" -> tvOrigin.text = item.originName
+                            "latest" -> tvLast.text = item.getDisplayLastChapterTitle()
+                            "upCurSource" -> if (callBack.oldBookUrl == item.bookUrl) {
+                                ivChecked.visible()
+                            } else {
+                                ivChecked.invisible()
+                            }
                         }
                     }
                 }

+ 5 - 3
app/src/main/java/io/legado/app/ui/book/explore/ExploreShowAdapter.kt

@@ -28,11 +28,13 @@ class ExploreShowAdapter(context: Context, val callBack: CallBack) :
         item: SearchBook,
         payloads: MutableList<Any>
     ) {
-        val bundle = payloads.getOrNull(0) as? Bundle
-        if (bundle == null) {
+        if (payloads.isEmpty()) {
             bind(binding, item)
         } else {
-            bindChange(binding, item, bundle)
+            for (i in payloads.indices) {
+                val bundle = payloads[i] as Bundle
+                bindChange(binding, item, bundle)
+            }
         }
 
     }

+ 5 - 3
app/src/main/java/io/legado/app/ui/book/search/SearchAdapter.kt

@@ -59,11 +59,13 @@ class SearchAdapter(context: Context, val callBack: CallBack) :
         item: SearchBook,
         payloads: MutableList<Any>
     ) {
-        val bundle = payloads.getOrNull(0) as? Bundle
-        if (bundle == null) {
+        if (payloads.isEmpty()) {
             bind(binding, item)
         } else {
-            bindChange(binding, item, bundle)
+            for (i in payloads.indices) {
+                val bundle = payloads[i] as Bundle
+                bindChange(binding, item, bundle)
+            }
         }
     }
 

+ 11 - 9
app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceAdapter.kt

@@ -89,8 +89,7 @@ class BookSourceAdapter(context: Context, val callBack: CallBack) :
         payloads: MutableList<Any>
     ) {
         binding.run {
-            val payload = payloads.getOrNull(0) as? Bundle
-            if (payload == null) {
+            if (payloads.isEmpty()) {
                 root.setBackgroundColor(ColorUtils.withAlpha(context.backgroundColor, 0.5f))
                 cbBookSource.text = item.getDisPlayNameGroup()
                 swtEnabled.isChecked = item.enabled
@@ -98,13 +97,16 @@ class BookSourceAdapter(context: Context, val callBack: CallBack) :
                 upCheckSourceMessage(binding, item)
                 upShowExplore(ivExplore, item)
             } else {
-                payload.keySet().map {
-                    when (it) {
-                        "enabled" -> swtEnabled.isChecked = payload.getBoolean("enabled")
-                        "upName" -> cbBookSource.text = item.getDisPlayNameGroup()
-                        "upExplore" -> upShowExplore(ivExplore, item)
-                        "selected" -> cbBookSource.isChecked = selected.contains(item)
-                        "checkSourceMessage" -> upCheckSourceMessage(binding, item)
+                for (i in payloads.indices) {
+                    val bundle = payloads[i] as Bundle
+                    bundle.keySet().map {
+                        when (it) {
+                            "enabled" -> swtEnabled.isChecked = bundle.getBoolean("enabled")
+                            "upName" -> cbBookSource.text = item.getDisPlayNameGroup()
+                            "upExplore" -> upShowExplore(ivExplore, item)
+                            "selected" -> cbBookSource.isChecked = selected.contains(item)
+                            "checkSourceMessage" -> upCheckSourceMessage(binding, item)
+                        }
                     }
                 }
             }

+ 10 - 8
app/src/main/java/io/legado/app/ui/book/toc/rule/TxtTocRuleAdapter.kt

@@ -77,20 +77,22 @@ class TxtTocRuleAdapter(context: Context, private val callBack: CallBack) :
         payloads: MutableList<Any>
     ) {
         binding.run {
-            val bundle = payloads.getOrNull(0) as? Bundle
-            if (bundle == null) {
+            if (payloads.isEmpty()) {
                 root.setBackgroundColor(ColorUtils.withAlpha(context.backgroundColor, 0.5f))
                 cbSource.text = item.name
                 swtEnabled.isChecked = item.enable
                 cbSource.isChecked = selected.contains(item)
                 titleExample.text = item.example
             } else {
-                bundle.keySet().map {
-                    when (it) {
-                        "selected" -> cbSource.isChecked = selected.contains(item)
-                        "upName" -> cbSource.text = item.name
-                        "upExample" -> titleExample.text = item.example
-                        "enabled" -> swtEnabled.isChecked = item.enable
+                for (i in payloads.indices) {
+                    val bundle = payloads[i] as Bundle
+                    bundle.keySet().map {
+                        when (it) {
+                            "selected" -> cbSource.isChecked = selected.contains(item)
+                            "upName" -> cbSource.text = item.name
+                            "upExample" -> titleExample.text = item.example
+                            "enabled" -> swtEnabled.isChecked = item.enable
+                        }
                     }
                 }
             }

+ 10 - 8
app/src/main/java/io/legado/app/ui/book/toc/rule/TxtTocRuleDialog.kt

@@ -249,20 +249,22 @@ class TxtTocRuleDialog() : BaseDialogFragment(R.layout.dialog_toc_regex),
             payloads: MutableList<Any>
         ) {
             binding.apply {
-                val bundle = payloads.getOrNull(0) as? Bundle
-                if (bundle == null) {
+                if (payloads.isEmpty()) {
                     root.setBackgroundColor(context.backgroundColor)
                     rbRegexName.text = item.name
                     titleExample.text = item.example
                     rbRegexName.isChecked = item.name == selectedName
                     swtEnabled.isChecked = item.enable
                 } else {
-                    bundle.keySet().map {
-                        when (it) {
-                            "upName" -> rbRegexName.text = item.name
-                            "upExample" -> titleExample.text = item.example
-                            "enabled" -> swtEnabled.isChecked = item.enable
-                            "upSelect" -> rbRegexName.isChecked = item.name == selectedName
+                    for (i in payloads.indices) {
+                        val bundle = payloads[i] as Bundle
+                        bundle.keySet().map {
+                            when (it) {
+                                "upName" -> rbRegexName.text = item.name
+                                "upExample" -> titleExample.text = item.example
+                                "enabled" -> swtEnabled.isChecked = item.enable
+                                "upSelect" -> rbRegexName.isChecked = item.name == selectedName
+                            }
                         }
                     }
                 }

+ 9 - 7
app/src/main/java/io/legado/app/ui/dict/rule/DictRuleAdapter.kt

@@ -95,18 +95,20 @@ class DictRuleAdapter(context: Context, var callBack: CallBack) :
         payloads: MutableList<Any>
     ) {
         binding.run {
-            val bundle = payloads.getOrNull(0) as? Bundle
-            if (bundle == null) {
+            if (payloads.isEmpty()) {
                 root.setBackgroundColor(ColorUtils.withAlpha(context.backgroundColor, 0.5f))
                 cbName.text = item.name
                 swtEnabled.isChecked = item.enabled
                 cbName.isChecked = selected.contains(item)
             } else {
-                bundle.keySet().map {
-                    when (it) {
-                        "selected" -> cbName.isChecked = selected.contains(item)
-                        "upName" -> cbName.text = item.name
-                        "enabled" -> swtEnabled.isChecked = item.enabled
+                for (i in payloads.indices) {
+                    val bundle = payloads[i] as Bundle
+                    bundle.keySet().map {
+                        when (it) {
+                            "selected" -> cbName.isChecked = selected.contains(item)
+                            "upName" -> cbName.text = item.name
+                            "enabled" -> swtEnabled.isChecked = item.enabled
+                        }
                     }
                 }
             }

+ 9 - 7
app/src/main/java/io/legado/app/ui/main/bookshelf/style1/books/BooksAdapterGrid.kt

@@ -24,17 +24,19 @@ class BooksAdapterGrid(context: Context, private val callBack: CallBack) :
         item: Book,
         payloads: MutableList<Any>
     ) = binding.run {
-        val bundle = payloads.getOrNull(0) as? Bundle
-        if (bundle == null) {
+        if (payloads.isEmpty()) {
             tvName.text = item.name
             ivCover.load(item.getDisplayCover(), item.name, item.author, false, item.origin)
             upRefresh(binding, item)
         } else {
-            bundle.keySet().forEach {
-                when (it) {
-                    "name" -> tvName.text = item.name
-                    "cover" -> ivCover.load(item.getDisplayCover(), item.name, item.author, false, item.origin)
-                    "refresh" -> upRefresh(binding, item)
+            for (i in payloads.indices) {
+                val bundle = payloads[i] as Bundle
+                bundle.keySet().forEach {
+                    when (it) {
+                        "name" -> tvName.text = item.name
+                        "cover" -> ivCover.load(item.getDisplayCover(), item.name, item.author, false, item.origin)
+                        "refresh" -> upRefresh(binding, item)
+                    }
                 }
             }
         }

+ 20 - 18
app/src/main/java/io/legado/app/ui/main/bookshelf/style1/books/BooksAdapterList.kt

@@ -30,8 +30,7 @@ class BooksAdapterList(
         item: Book,
         payloads: MutableList<Any>
     ) = binding.run {
-        val bundle = payloads.getOrNull(0) as? Bundle
-        if (bundle == null) {
+        if (payloads.isEmpty()) {
             tvName.text = item.name
             tvAuthor.text = item.author
             tvRead.text = item.durChapterTitle
@@ -40,23 +39,26 @@ class BooksAdapterList(
             upRefresh(binding, item)
             upLastUpdateTime(binding, item)
         } else {
-            bundle.keySet().forEach {
-                when (it) {
-                    "name" -> tvName.text = item.name
-                    "author" -> tvAuthor.text = item.author
-                    "dur" -> tvRead.text = item.durChapterTitle
-                    "last" -> tvLast.text = item.latestChapterTitle
-                    "cover" -> ivCover.load(
-                        item.getDisplayCover(),
-                        item.name,
-                        item.author,
-                        false,
-                        item.origin,
-                        lifecycle
-                    )
+            for (i in payloads.indices) {
+                val bundle = payloads[i] as Bundle
+                bundle.keySet().forEach {
+                    when (it) {
+                        "name" -> tvName.text = item.name
+                        "author" -> tvAuthor.text = item.author
+                        "dur" -> tvRead.text = item.durChapterTitle
+                        "last" -> tvLast.text = item.latestChapterTitle
+                        "cover" -> ivCover.load(
+                            item.getDisplayCover(),
+                            item.name,
+                            item.author,
+                            false,
+                            item.origin,
+                            lifecycle
+                        )
 
-                    "refresh" -> upRefresh(binding, item)
-                    "lastUpdateTime" -> upLastUpdateTime(binding, item)
+                        "refresh" -> upRefresh(binding, item)
+                        "lastUpdateTime" -> upLastUpdateTime(binding, item)
+                    }
                 }
             }
         }

+ 9 - 7
app/src/main/java/io/legado/app/ui/replace/ReplaceRuleAdapter.kt

@@ -103,18 +103,20 @@ class ReplaceRuleAdapter(context: Context, var callBack: CallBack) :
         payloads: MutableList<Any>
     ) {
         binding.run {
-            val bundle = payloads.getOrNull(0) as? Bundle
-            if (bundle == null) {
+            if (payloads.isEmpty()) {
                 root.setBackgroundColor(ColorUtils.withAlpha(context.backgroundColor, 0.5f))
                 cbName.text = item.getDisplayNameGroup()
                 swtEnabled.isChecked = item.isEnabled
                 cbName.isChecked = selected.contains(item)
             } else {
-                bundle.keySet().map {
-                    when (it) {
-                        "selected" -> cbName.isChecked = selected.contains(item)
-                        "upName" -> cbName.text = item.getDisplayNameGroup()
-                        "enabled" -> swtEnabled.isChecked = item.isEnabled
+                for (i in payloads.indices) {
+                    val bundle = payloads[i] as Bundle
+                    bundle.keySet().map {
+                        when (it) {
+                            "selected" -> cbName.isChecked = selected.contains(item)
+                            "upName" -> cbName.text = item.getDisplayNameGroup()
+                            "enabled" -> swtEnabled.isChecked = item.isEnabled
+                        }
                     }
                 }
             }

+ 10 - 8
app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceAdapter.kt

@@ -17,7 +17,7 @@ import io.legado.app.lib.theme.backgroundColor
 import io.legado.app.ui.widget.recycler.DragSelectTouchHelper
 import io.legado.app.ui.widget.recycler.ItemTouchCallback
 import io.legado.app.utils.ColorUtils
-import java.util.*
+import java.util.Collections
 
 
 class RssSourceAdapter(context: Context, val callBack: CallBack) :
@@ -73,18 +73,20 @@ class RssSourceAdapter(context: Context, val callBack: CallBack) :
         payloads: MutableList<Any>
     ) {
         binding.run {
-            val bundle = payloads.getOrNull(0) as? Bundle
-            if (bundle == null) {
+            if (payloads.isEmpty()) {
                 root.setBackgroundColor(ColorUtils.withAlpha(context.backgroundColor, 0.5f))
                 cbSource.text = item.getDisplayNameGroup()
                 swtEnabled.isChecked = item.enabled
                 cbSource.isChecked = selected.contains(item)
             } else {
-                bundle.keySet().map {
-                    when (it) {
-                        "upName" -> cbSource.text = item.getDisplayNameGroup()
-                        "enabled" -> swtEnabled.isChecked = bundle.getBoolean("enabled")
-                        "selected" -> cbSource.isChecked = selected.contains(item)
+                for (i in payloads.indices) {
+                    val bundle = payloads[i] as Bundle
+                    bundle.keySet().map {
+                        when (it) {
+                            "upName" -> cbSource.text = item.getDisplayNameGroup()
+                            "enabled" -> swtEnabled.isChecked = bundle.getBoolean("enabled")
+                            "selected" -> cbSource.isChecked = selected.contains(item)
+                        }
                     }
                 }
             }