diff --git a/vector/src/debug/java/im/vector/app/features/debug/features/DebugFeaturesSettingsActivity.kt b/vector/src/debug/java/im/vector/app/features/debug/features/DebugFeaturesSettingsActivity.kt index f4012ffd02..e31f073614 100644 --- a/vector/src/debug/java/im/vector/app/features/debug/features/DebugFeaturesSettingsActivity.kt +++ b/vector/src/debug/java/im/vector/app/features/debug/features/DebugFeaturesSettingsActivity.kt @@ -36,9 +36,8 @@ class DebugFeaturesSettingsActivity : VectorBaseActivity> onOptionSelected(option: Any?, feature: Feature.EnumFeature) { - debugFeatures.overrideEnum(option as? T, feature.type) + override fun > onOptionSelected(option: T?, feature: Feature.EnumFeature) { + debugFeatures.overrideEnum(option, feature.type) } } views.genericRecyclerView.configureWith(controller) diff --git a/vector/src/debug/java/im/vector/app/features/debug/features/EnumFeatureItem.kt b/vector/src/debug/java/im/vector/app/features/debug/features/EnumFeatureItem.kt index 1e2ec56ea8..5dd2f9efa9 100644 --- a/vector/src/debug/java/im/vector/app/features/debug/features/EnumFeatureItem.kt +++ b/vector/src/debug/java/im/vector/app/features/debug/features/EnumFeatureItem.kt @@ -53,10 +53,7 @@ abstract class EnumFeatureItem : VectorEpoxyModel() { override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) { when (position) { 0 -> listener?.onOptionSelected(option = null, feature) - else -> { - val option: Any = feature.options[position - 1] - listener?.onOptionSelected(option, feature) - } + else -> feature.onOptionSelected(position - 1) } } @@ -67,12 +64,16 @@ abstract class EnumFeatureItem : VectorEpoxyModel() { } } + private fun > Feature.EnumFeature.onOptionSelected(selection: Int) { + listener?.onOptionSelected(options[selection], this) + } + class Holder : VectorEpoxyHolder() { val label by bind(im.vector.app.R.id.feature_label) val optionsSpinner by bind(im.vector.app.R.id.feature_options) } interface Listener { - fun > onOptionSelected(option: Any?, feature: Feature.EnumFeature) + fun > onOptionSelected(option: T?, feature: Feature.EnumFeature) } }