From d89cc71eb4a2152857df6f288f07a699db346359 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Thu, 10 Mar 2022 17:20:29 +0000 Subject: [PATCH] making use of binding api instead of manual findviewbyid --- .../debug/settings/OverrideDropdownView.kt | 17 ++++++++--------- .../debug/res/layout/view_boolean_dropdown.xml | 4 ++-- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/vector/src/debug/java/im/vector/app/features/debug/settings/OverrideDropdownView.kt b/vector/src/debug/java/im/vector/app/features/debug/settings/OverrideDropdownView.kt index 08cbb415e0..48ec44f909 100644 --- a/vector/src/debug/java/im/vector/app/features/debug/settings/OverrideDropdownView.kt +++ b/vector/src/debug/java/im/vector/app/features/debug/settings/OverrideDropdownView.kt @@ -19,34 +19,33 @@ package im.vector.app.features.debug.settings import android.content.Context import android.util.AttributeSet import android.view.Gravity +import android.view.LayoutInflater import android.view.View import android.widget.AdapterView import android.widget.ArrayAdapter import android.widget.LinearLayout -import android.widget.TextView -import androidx.appcompat.widget.AppCompatSpinner import im.vector.app.R +import im.vector.app.databinding.ViewBooleanDropdownBinding class OverrideDropdownView @JvmOverloads constructor( context: Context, attrs: AttributeSet? = null ) : LinearLayout(context, attrs) { - private val labelView: TextView - private val optionsSpinner: AppCompatSpinner + private val binding = ViewBooleanDropdownBinding.inflate( + LayoutInflater.from(context), + this + ) init { orientation = HORIZONTAL gravity = Gravity.CENTER_VERTICAL - inflate(context, R.layout.view_boolean_dropdown, this) - labelView = findViewById(R.id.feature_label) - optionsSpinner = findViewById(R.id.feature_options) } fun bind(feature: OverrideDropdown, listener: Listener) { - labelView.text = feature.label + binding.overrideLabel.text = feature.label - optionsSpinner.apply { + binding.overrideOptions.apply { val arrayAdapter = ArrayAdapter(context, android.R.layout.simple_spinner_dropdown_item) val options = listOf("Inactive") + feature.options.map { it.label } arrayAdapter.addAll(options) diff --git a/vector/src/debug/res/layout/view_boolean_dropdown.xml b/vector/src/debug/res/layout/view_boolean_dropdown.xml index a231980797..5018d61047 100644 --- a/vector/src/debug/res/layout/view_boolean_dropdown.xml +++ b/vector/src/debug/res/layout/view_boolean_dropdown.xml @@ -6,7 +6,7 @@ tools:parentTag="android.widget.LinearLayout">