From 6715796f099eb5cf40b6c8eefe8bc203c6b1590a Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 13 Oct 2022 23:29:40 +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 --- .../app/ui/book/search/SearchScopeDialog.kt | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/search/SearchScopeDialog.kt b/app/src/main/java/io/legado/app/ui/book/search/SearchScopeDialog.kt index 935ce36f7..7c856d9fa 100644 --- a/app/src/main/java/io/legado/app/ui/book/search/SearchScopeDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/search/SearchScopeDialog.kt @@ -24,8 +24,8 @@ class SearchScopeDialog : BaseDialogFragment(R.layout.dialog_search_scope) { private val binding by viewBinding(DialogSearchScopeBinding::bind) val callback: Callback get() = parentFragment as? Callback ?: activity as Callback - var groups: List? = null - var sources: List? = null + var groups: List = arrayListOf() + var sources: List = arrayListOf() val adapter by lazy { RecyclerAdapter() @@ -46,7 +46,7 @@ class SearchScopeDialog : BaseDialogFragment(R.layout.dialog_search_scope) { private fun initOtherView() { - binding.rgScope.setOnCheckedChangeListener { group, checkedId -> + binding.rgScope.setOnCheckedChangeListener { _, _ -> upData() } binding.tvCancel.setOnClickListener { @@ -119,13 +119,13 @@ class SearchScopeDialog : BaseDialogFragment(R.layout.dialog_search_scope) { } else { when (holder.binding) { is ItemCheckBoxBinding -> { - groups?.get(position)?.let { + groups.getOrNull(position)?.let { holder.binding.checkBox.isChecked = selectGroups.contains(it) holder.binding.checkBox.text = it } } is ItemRadioButtonBinding -> { - sources?.get(position)?.let { + sources.getOrNull(position)?.let { holder.binding.radioButton.isChecked = selectSource == it holder.binding.radioButton.text = it.bookSourceName } @@ -137,7 +137,7 @@ class SearchScopeDialog : BaseDialogFragment(R.layout.dialog_search_scope) { override fun onBindViewHolder(holder: ItemViewHolder, position: Int) { when (holder.binding) { is ItemCheckBoxBinding -> { - groups?.get(position)?.let { + groups.getOrNull(position)?.let { holder.binding.checkBox.isChecked = selectGroups.contains(it) holder.binding.checkBox.text = it holder.binding.checkBox.setOnCheckedChangeListener { buttonView, isChecked -> @@ -153,7 +153,7 @@ class SearchScopeDialog : BaseDialogFragment(R.layout.dialog_search_scope) { } } is ItemRadioButtonBinding -> { - sources?.get(position)?.let { + sources.getOrNull(position)?.let { holder.binding.radioButton.isChecked = selectSource == it holder.binding.radioButton.text = it.bookSourceName holder.binding.radioButton.setOnCheckedChangeListener { buttonView, isChecked -> @@ -171,9 +171,9 @@ class SearchScopeDialog : BaseDialogFragment(R.layout.dialog_search_scope) { override fun getItemCount(): Int { return if (binding.rbSource.isChecked) { - sources?.size ?: 0 + sources.size } else { - groups?.size ?: 0 + groups.size } }