frank
02/14/2017, 5:10 PMonNext
.
However when I turn the phone it produces unexpected (as far as I understand it) results. After turning the phone onNext
always produces either two or three values. If the initial value is still selected it produces this twice. If another value has already been selected it produces the original value once and the selected value twice.
I've got the following in my `OnCreateView`:
val adapter = ArrayAdapter.createFromResource(
activity,
R.array.geo_array,
android.R.layout.simple_spinner_item
)
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
spinner?.adapter = adapter
val countries = resources.getStringArray(R.array.geo_array)
RxJavaInterop.toV2Observable(spinner?.itemSelections()?.map { countries[it] }).subscribe { Timber.d("onNext $it") }
So every time I turn the phone a new adapter is set on the spinner (which should replace the old one) and a new subscriber is added.
I've tried storing the disposable
produced by the subscribe method and disposing this in onDestroyView
, however it still happens.
Anyone knows what exactly I'm missing and why it's doing all those onNext calls after turning the phone? Is it just some fundamental understanding of Rx that I lack?