From d584aa56b94638a28e2b0d462a66f240982cbd54 Mon Sep 17 00:00:00 2001 From: Jays2Kings Date: Wed, 14 Apr 2021 15:50:09 -0400 Subject: [PATCH] Adding a default popup for selectedPosition in spinner view For cases where neither bind no listener is implmented, you can just get the selected position --- .../eu/kanade/tachiyomi/widget/MaterialSpinnerView.kt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/widget/MaterialSpinnerView.kt b/app/src/main/java/eu/kanade/tachiyomi/widget/MaterialSpinnerView.kt index c7c871b7e1..c70cc6400e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/widget/MaterialSpinnerView.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/widget/MaterialSpinnerView.kt @@ -25,7 +25,8 @@ class MaterialSpinnerView @JvmOverloads constructor(context: Context, attrs: Att FrameLayout(context, attrs) { private var entries = emptyList() - private var selectedPosition = 0 + var selectedPosition = 0 + private set private var pref: Preference? = null private var prefOffset = 0 private var popup: PopupMenu? = null @@ -63,6 +64,12 @@ class MaterialSpinnerView @JvmOverloads constructor(context: Context, attrs: Att binding.detailView.text = entries.firstOrNull().orEmpty() + popup = makeSettingsPopup() + setOnTouchListener(popup?.dragToOpenListener) + setOnClickListener { + popup?.show() + } + a.recycle() }