From 3876a0d2561820ca7c380e0b9baef2c2f302bc18 Mon Sep 17 00:00:00 2001 From: mueller-ma Date: Sun, 27 Oct 2024 14:20:31 +0100 Subject: [PATCH] SelectionBottomSheet: send command when clicking on the selected value (#3820) Signed-off-by: mueller-ma --- .../habdroid/ui/WidgetDetailBottomSheets.kt | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/mobile/src/main/java/org/openhab/habdroid/ui/WidgetDetailBottomSheets.kt b/mobile/src/main/java/org/openhab/habdroid/ui/WidgetDetailBottomSheets.kt index 19d7ee85db..26d4f9520d 100644 --- a/mobile/src/main/java/org/openhab/habdroid/ui/WidgetDetailBottomSheets.kt +++ b/mobile/src/main/java/org/openhab/habdroid/ui/WidgetDetailBottomSheets.kt @@ -98,7 +98,7 @@ class SliderBottomSheet : AbstractWidgetBottomSheet(), WidgetSlider.UpdateListen } } -class SelectionBottomSheet : AbstractWidgetBottomSheet(), RadioGroup.OnCheckedChangeListener { +class SelectionBottomSheet : AbstractWidgetBottomSheet() { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { val view = inflater.inflate(R.layout.bottom_sheet_selection, container, false) val group = view.findViewById(R.id.group) @@ -108,23 +108,18 @@ class SelectionBottomSheet : AbstractWidgetBottomSheet(), RadioGroup.OnCheckedCh radio.id = mapping.hashCode() radio.text = mapping.label radio.isChecked = stateString == mapping.value + radio.setOnClickListener { + connection?.httpClient?.sendItemCommand(widget.item, mapping.value) + dismissAllowingStateLoss() + } group.addView(radio) } - group.setOnCheckedChangeListener(this) view.findViewById(R.id.title).apply { text = widget.label } return view } - - override fun onCheckedChanged(group: RadioGroup?, id: Int) { - val mapping = widget.mappingsOrItemOptions.firstOrNull { mapping -> mapping.hashCode() == id } - if (mapping != null) { - connection?.httpClient?.sendItemCommand(widget.item, mapping.value) - } - dismissAllowingStateLoss() - } } class ColorChooserBottomSheet : AbstractWidgetBottomSheet() {