From 2a6baa739d50c6c1194e3425acb6941ef54eb17d Mon Sep 17 00:00:00 2001 From: mueller-ma Date: Thu, 3 Oct 2024 14:02:59 +0200 Subject: [PATCH] SelectionBottomSheet: send command when clicking on the selected value 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() {