Open ahmednabeel1991 opened 3 years ago
Hello There, I am using this library which is really helpful, but I am stuck on one thing. How to implement Search functionality in this library.
Right now I am trying and it is not giving me correct position when filterable is active other than this it is giving correct
Filter code is here bwllow
` @Override public Filter getFilter() { return new Filter() { @SuppressWarnings("unchecked") @Override protected void publishResults(CharSequence constraint, FilterResults results) { dummyList = (List) results.values; notifyDataSetChanged(); }
@Override protected FilterResults performFiltering(CharSequence constraint) { List<GetByModel> filteredResults = null; if (constraint.length() == 0) { filtered = groupList; filteredResults = groupList; } else { filteredResults = getFilteredResults(constraint.toString().toLowerCase()); } FilterResults results = new FilterResults(); results.values = filteredResults; return results; } }; } protected List<GetByModel> getFilteredResults(String constraint) { List<GetByModel> results = new ArrayList<>(); for (GetByModel item : dummyList) { for (GenericModelFilterSelection genericModelFilterSelection : item.getGenericModels()) { if (genericModelFilterSelection.getName().toLowerCase().contains(constraint)) { if (!results.contains(item)) { results.add(item); } } } } return results; }
`
Hello There, I am using this library which is really helpful, but I am stuck on one thing. How to implement Search functionality in this library.
Right now I am trying and it is not giving me correct position when filterable is active other than this it is giving correct
Filter code is here bwllow
` @Override public Filter getFilter() { return new Filter() { @SuppressWarnings("unchecked") @Override protected void publishResults(CharSequence constraint, FilterResults results) { dummyList = (List) results.values;
notifyDataSetChanged();
}
`