android - Best Practices for Handling Search -


i've got searchview setup, , have loosely decoupled architecture using retrofit , otto.

i wondering best practices search in android, or mobile application in general (meaning applied ios well).

specifically using autocompletetextview handle suggestions in searchview , data coming straight api. don't believe best practice since everytime user changes text in searchview there api call initiated.

i'm thinking storing cache in sqlite , pinging results there, if user wants immediate data? how handle that? pattern employ?

would appreciate thoughts on best architecture or approach search in android.

i think there no sense make api call before user stopped typing. so, can put delay, say, 500ms. when user stops typing, after 500ms make api call , show results.

you can use handler's postdelayed method scheduling search api calls. can use handler control message queue. post delayed runnable each time user types character , cancel previous messages. way:

public void ontextchanged(charsequence s, int start, int before, int count) {     handler.removecallbacks(searchrunnable);     handler.postdelayed(searchrunnable, 500); } 

Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -