I have followed this tutorial and have successfully implemented a recylerview with searchview in my app https://github.com/Wrdlbrnft/Searchable-RecyclerView-Demo. However, now instead of having text in my recylerview I have icons representing two states for a user Online and Offline, what I want to do is when the user types in Online in the searchView I only want the Online icon to show up and simiarly when they type Offline I only want the offline icon to show up.
To filter text, as shown in the example I have done this;
if (personStatus.contains(query)) {
filteredModelList.add(model);
}
This works perfectly for text based results in my recylerview, however, I want to filter based on icons in the recylerView.
The icon can either be R.drawable.Online or R.drawable.Offline. I have a imageView called icon.
What I have tried so far;
if(query.toLowerCase().equals("online") {
filteredModelList.add(model.getIcon().getDrawable(R.drawable.online));
}
This doesn't seem to work, I get a error on getIcon, it says cannot resolve method getIcon. I do have a method getIcon as shown in the example above in the exampleModel class;
what I want to do is;
IF searchView text = "Online" THEN
Only show recylerview items that contains icon Online
I hope I have explained myself fully, if not please let me know.