Fixed radio button acting up

This commit is contained in:
tom5079
2021-06-08 09:08:24 +09:00
parent dd60a1fdfb
commit ff0df0d9cc

View File

@@ -78,6 +78,15 @@ class DownloadLocationDialogFragment : DialogFragment(), DIAware {
if (key == null) entries[key]!!.locationAvailable.text = downloadFolder
}
}
} else {
val downloadFolder = DownloadManager.getInstance(context ?: return@registerForActivityResult).downloadFolder.canonicalPath
val key = entries.keys.firstOrNull { it?.canonicalPath == downloadFolder }
if (key == null)
entries[key]!!.locationAvailable.text = downloadFolder
else {
entries[null]!!.button.isChecked = false
entries[key]!!.button.isChecked = true
}
}
}
@@ -97,8 +106,8 @@ class DownloadLocationDialogFragment : DialogFragment(), DIAware {
byteToString(dir.freeSpace)
)
root.setOnClickListener {
entries.values.forEach { _ ->
button.isChecked = false
entries.values.forEach { entry ->
entry.button.isChecked = false
}
button.performClick()
Preferences["download_folder"] = dir.toUri().toString()
@@ -110,8 +119,8 @@ class DownloadLocationDialogFragment : DialogFragment(), DIAware {
DownloadLocationItemBinding.inflate(layoutInflater, binding.root, true).apply {
locationType.text = requireContext().getString(R.string.settings_download_folder_custom)
root.setOnClickListener {
entries.values.forEach {
it.button.isChecked = false
entries.values.forEach { entry ->
entry.button.isChecked = false
}
button.performClick()