SpinnerHelper update
This commit is contained in:
parent
3c7a8225c0
commit
e01f6f6cb0
|
@ -100,25 +100,17 @@ class SpinnerHelper(val spinner: Spinner) : AdapterView.OnItemSelectedListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onItemSelected(parent: AdapterView<*>?, view: View, position: Int, id: Long) {
|
override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) {
|
||||||
if (position != lastPosition && userTouched) {
|
if (position != lastPosition && userTouched) {
|
||||||
lastPosition = position
|
lastPosition = position
|
||||||
if (proxiedItemSelectedListener != null) {
|
proxiedItemSelectedListener?.onItemSelected(parent, view, position, id)
|
||||||
proxiedItemSelectedListener!!.onItemSelected(
|
|
||||||
parent, view, position, id
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onNothingSelected(parent: AdapterView<*>?) {
|
override fun onNothingSelected(parent: AdapterView<*>?) {
|
||||||
if (-1 != lastPosition) {
|
if (lastPosition != -1) {
|
||||||
lastPosition = -1
|
lastPosition = -1
|
||||||
if (proxiedItemSelectedListener != null) {
|
proxiedItemSelectedListener?.onNothingSelected(parent)
|
||||||
proxiedItemSelectedListener!!.onNothingSelected(
|
|
||||||
parent
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,7 +131,11 @@ class SpinnerHelper(val spinner: Spinner) : AdapterView.OnItemSelectedListener {
|
||||||
fun getItemIdAtPosition(position: Int): Long = spinner.getItemIdAtPosition(position)
|
fun getItemIdAtPosition(position: Int): Long = spinner.getItemIdAtPosition(position)
|
||||||
|
|
||||||
val selectedItem: Any
|
val selectedItem: Any
|
||||||
get() = spinner.selectedItem
|
get() = try {
|
||||||
|
spinner.selectedItem
|
||||||
|
} catch (e: IndexOutOfBoundsException) {
|
||||||
|
adapter.getItem(adapter.count - 1)
|
||||||
|
}
|
||||||
val selectedItemId: Long
|
val selectedItemId: Long
|
||||||
get() = spinner.selectedItemId
|
get() = spinner.selectedItemId
|
||||||
val selectedItemPosition: Int
|
val selectedItemPosition: Int
|
||||||
|
|
Loading…
Reference in a new issue