Android Question SearchView question

Tomas Petrus

Active Member
Licensed User
I am implementing SearchView.
Intention is that it will work like google autocomplete for adress input. I didnt get google places API pricing, and I dont want to risk it.

So I choosed some other service with REST API.

I customized the class and got it working - need some more tuning but it works. Just one problem.
As I dont fully understand how exactly some parts of the class works I have problem to implement following logic.

In Czech Language we have special characters as: ě,š,č,ř,ž,ý,á,í,é and some others but when the people write into mobiles sometimes they use it sometimes they just use the original character.

For example adress "Václavské náměstí" can be writen by user like "Vaclavske namesti" or "Václavske namesti" or any other combination of original and enchanced letters...

I am now in state, that when I write it correctly with all special characters then I get the results, when I write it without it like instead "Václa" i write "Vacla" the API return same set of results thats fine, but then the SearchView class hide it (doesnt include it in list) because "Václa" is not in the input string .. because I wrote "Vacla". and therefore this:

B4X:
AddItemsToList(prefixList.Get(str2), str1)
AddItemsToList(substringList.Get(str2), str1)
cant find anything....

Dont know what is the bast way to handle that, make sub to get rid of all special characters ? store the original input ? and then substitued them as needed ? but it seems like overkill ...

any ideas ?
usually the easiest way is the best.

Thanks
 

Tomas Petrus

Active Member
Licensed User
Also the API if cant find the exact matches returns some results, that are similar to user input but doesnt include the exact version of what user wrote but something silimiar.. these results are also excluded by SearchView...
 

Tomas Petrus

Active Member
Licensed User
Other thing is that i call Sub to getSuggest from API in et_changed
B4X:
If New.Length >= 5 Then
        GetHRESuggestions(New)
        Sleep(100)
End If
But that means that even while fast writing when the string is longer then 4 chars with each new letter it send request to the API.
Its possible to optimize it ? like send the request only when stop typing for 10ms ? or something like that ?
 

Erel

Administrator
Staff member
Licensed User
But that means that even while fast writing when the string is longer then 4 chars with each new letter it send request to the API.
Its possible to optimize it ? like send the request only when stop typing for 10ms ? or something like that ?
I don't see how this question is related to SearchView. SearchView, by design, searches in its own small index.

About the characters. The first step is to implement code that normalizes the data and user input by removing the accents. You will then take the user input, normalize it, find results in the normalized items and the last step will be to return the non-normalized item from the normalized item.
 

Tomas Petrus

Active Member
Licensed User
I don't see how this question is related to SearchView. SearchView, by design, searches in its own small index.
I have altered SearchView Class so now with each character above 4 that user write API call is made and the list of relevant adresses is recreated..
 

Tomas Petrus

Active Member
Licensed User
Example seems better then mine :)) I will try to combine it or use yours and change just api request and response parsing.

Problems with the characters normalization seems to be the same, just in your example it seems to be easier to solve because of placedata type is already implemented.

Nothing special about 4. Just eliminating pointless api calls. I am usually setting this to 3-5.
 
Top