Skip to content

Instantly share code, notes, and snippets.

@pyeongho
Created January 17, 2017 05:25
Show Gist options
  • Save pyeongho/fbe79093772cfa1b62fc3f97659bdaed to your computer and use it in GitHub Desktop.
Save pyeongho/fbe79093772cfa1b62fc3f97659bdaed to your computer and use it in GitHub Desktop.
private List<Recent> items= null;
private ArrayList<Recent> arrayList;
public RecyclerAdapter(Context context, List<Recent> items) {
this.mCtx=context;
this.items=items;
arrayList = new ArrayList<Recent>();
arrayList.addAll(items);
}
public void filter(String charText) {
charText = charText.toLowerCase(Locale.getDefault());
items.clear();
if (charText.length() == 0) {
items.addAll(arrayList);
} else {
for (Recent recent : arrayList) {
String name = recent.getAddress();
if (name.toLowerCase().contains(charText)) {
items.add(recent);
}
}
}
notifyDataSetChanged();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment