use of com.faltenreich.diaguard.shared.data.database.entity.Tag in project Diaguard by Faltenreich.
the class TagAutoCompleteAdapter method getFilter.
@NonNull
@Override
public Filter getFilter() {
return new Filter() {
@Override
protected FilterResults performFiltering(CharSequence constraint) {
FilterResults filterResults = new FilterResults();
List<Tag> suggestions = new ArrayList<>();
if (!TextUtils.isEmpty(constraint)) {
for (Map.Entry<Tag, Boolean> entry : tags.entrySet()) {
Tag tag = entry.getKey();
if (tag != null && tag.getName().toLowerCase().contains(constraint.toString().toLowerCase())) {
suggestions.add(tag);
}
}
}
filterResults.values = suggestions;
filterResults.count = suggestions.size();
return filterResults;
}
@Override
protected void publishResults(CharSequence constraint, FilterResults filterResults) {
notifyDataSetChanged();
}
};
}
Aggregations