Gracefully handle and log when a radio list does not have a default selection.

fork-5.53.8
Alex Hart 2021-10-07 08:49:30 -03:00
rodzic 3cbf0933ff
commit b5cc570363
1 zmienionych plików z 12 dodań i 2 usunięć

Wyświetl plik

@ -11,6 +11,7 @@ import androidx.annotation.CallSuper
import androidx.core.content.ContextCompat
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.google.android.material.switchmaterial.SwitchMaterial
import org.signal.core.util.logging.Log
import org.thoughtcrime.securesms.R
import org.thoughtcrime.securesms.util.CommunicationActions
import org.thoughtcrime.securesms.util.MappingAdapter
@ -97,8 +98,13 @@ class RadioListPreferenceViewHolder(itemView: View) : PreferenceViewHolder<Radio
override fun bind(model: RadioListPreference) {
super.bind(model)
summaryView.visibility = View.VISIBLE
summaryView.text = model.listItems[model.selected]
if (model.selected >= 0) {
summaryView.visibility = View.VISIBLE
summaryView.text = model.listItems[model.selected]
} else {
summaryView.visibility = View.GONE
Log.w(TAG, "Detected a radio list without a default selection: ${model.dialogTitle}")
}
itemView.setOnClickListener {
var selection = -1
@ -128,6 +134,10 @@ class RadioListPreferenceViewHolder(itemView: View) : PreferenceViewHolder<Radio
}
}
}
companion object {
private val TAG = Log.tag(RadioListPreference::class.java)
}
}
class MultiSelectListPreferenceViewHolder(itemView: View) : PreferenceViewHolder<MultiSelectListPreference>(itemView) {