Any autocomplete code?

Hi there!

I want to use autocomplete function for cities in my weather app, in the same way as iPhone weather app do.

I will use wunderground API for this. They have autocomplete data in JSON (http://www.wunderground.com/weather/api/d/documentation.html#auto), so I need to get this data, parse and show it as a standard iPhone list with possibility to scroll it and to select one of the cities.

I just want to know does anybody already done this in his app with Corona and will be so kind to share this code with me and community?

If not, I will appreciate any ideas how to implement this in smart way.

Thanks! [import]uid: 117007 topic_id: 21853 reply_id: 321853[/import]

Did you have a go at implementing this? [import]uid: 44416 topic_id: 21853 reply_id: 108027[/import]

Yes. Actually I’ve finished with Google Weather secret API. And what about autocomplete code, it was not too hard. Just send a query to API, get the data in JSON, parse it and show results. Refreshing results and getting everything works at widget table was the hardest part for me. Another tricky thing was implementing a delay before sending the string to Google. I want to wait until user slow down or stop his typing, so we don’t have to send 2-3 queries per second, while user is typing. This code works for delay in native textbox event listener:

[lua]elseif ( “editing” == event.phase ) then
if string.len(event.text) >= 2 then
if countdown then
timer.cancel (countdown)
countdown = nil
end

countdown = timer.performWithDelay(600, function() query( event.text ) end)[/lua]
So, there was no magic in autocomplete code, but it was a hard work to catch every little bug there. [import]uid: 117007 topic_id: 21853 reply_id: 108365[/import]