mirror of
https://github.com/element-hq/element-android
synced 2024-11-24 18:35:40 +03:00
making use of binding api instead of manual findviewbyid
This commit is contained in:
parent
edee6abafa
commit
d89cc71eb4
2 changed files with 10 additions and 11 deletions
|
@ -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 <T : OverrideOption> bind(feature: OverrideDropdown<T>, listener: Listener<T>) {
|
||||
labelView.text = feature.label
|
||||
binding.overrideLabel.text = feature.label
|
||||
|
||||
optionsSpinner.apply {
|
||||
binding.overrideOptions.apply {
|
||||
val arrayAdapter = ArrayAdapter<String>(context, android.R.layout.simple_spinner_dropdown_item)
|
||||
val options = listOf("Inactive") + feature.options.map { it.label }
|
||||
arrayAdapter.addAll(options)
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
tools:parentTag="android.widget.LinearLayout">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/feature_label"
|
||||
android:id="@+id/overrideLabel"
|
||||
style="@style/Widget.Vector.TextView.Subtitle"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -17,7 +17,7 @@
|
|||
tools:text="Login version" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatSpinner
|
||||
android:id="@+id/feature_options"
|
||||
android:id="@+id/overrideOptions"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1" />
|
||||
|
|
Loading…
Reference in a new issue