Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PartialTextChanged stops firing on MvxAutoCompleteTextView after Item selection

I am using MVVMCross's wrapper around the Xamarin Android AutoCompleteTextView.

I use the PartialTextChanged changed event to signal that I need to call the ViewModel, from the View, to get some more suggestions.

This works fine up to the point the user selects an item from the list. After that point no changes to the text will cause the PartialTextChanged event to fire. It is as if filtering is turned off once a selection has been made.

There is a SetText method on the AutoCompleteTextView that seems to turn filtering on\off but I am unsure of the best way to use that.

The TextChangedEvent still fires on the control as does AfterTextChanged just not PartialTextChanged and it is that which drives the updates.

I have debugged through the MVVMCross source and cannot see a solution. Any have any ideas?

Where can I browse them mondroid\xamarin android code?

Thanks

like image 773
Pat Long - Munkii Yebee Avatar asked Oct 24 '14 08:10

Pat Long - Munkii Yebee


1 Answers

After attaching the MVVMCross Source Code and debugging all the events I found that under certain circumstances I was not updating the ItemsSource after the PartialText property was being changed

The FilteringAdapter uses a ManualResetEvent around the change to PartialText and that is only signalled\set by the NotifyDataSetChanged method.

After finding this I also found that @slodge also mentions this in this answer, AutoComplete MVVM and Java Castings without using Java.Lang.Object on ViewModel. A constraint that until now had passed me by.

Note that because of the Android threading model it is essential that every change in PartialText is met by an eventual signalled change in ItemsSource - and this should be a single change in object collection rather than lots of small changes.

Thanks

like image 121
Pat Long - Munkii Yebee Avatar answered Nov 07 '22 01:11

Pat Long - Munkii Yebee