Filtering icons from recylerview based on text in searchview android -


i have followed tutorial , have implemented recylerview searchview in app https://github.com/wrdlbrnft/searchable-recyclerview-demo. however, instead of having text in recylerview have icons representing 2 states user online , offline, want when user types in online in searchview want online icon show , simiarly when type offline want offline icon show up.

to filter text, shown in example have done this;

if (personstatus.contains(query)) {              filteredmodellist.add(model);              } 

this works text based results in recylerview, however, want filter based on icons in recylerview.

the icon can either r.drawable.online or r.drawable.offline. have imageview called icon.

what have tried far;

if(query.tolowercase().equals("online") {                  filteredmodellist.add(model.geticon().getdrawable(r.drawable.online));              } 

this doesn't seem work, error on geticon, says cannot resolve method geticon. have method geticon shown in example above in examplemodel class;

what want is;

if searchview text = "online"    show recylerview items contains icon online 

i hope have explained myself fully, if not please let me know.

the approach using might slow when dealing large data set, because doing search on main thread. if searching not complete in 8ms experience junk.

comparison using query.tolowercase().equals("online") fine. need move logic inside adapter should implement filterable. need toggle online/offline status in model, like: setstatus(status.online) or setstatus(status.offline) iteration find items particular status easy, using condition & constraint searchview, i.e query.tolowercase().equals("online").

take @ answer here. more or less mentioned.


Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

java.lang.NoClassDefFoundError When Creating New Android Project -

Decoding a Python 2 `tempfile` with python-future -