// TODO: simultaneously search what is filtered and filter what is searched
@Override
        protected FilterResults performFiltering(CharSequence constraint) {
            List<DailyExpenseTagsWithPicsPojo> filteredListHelper = new ArrayList<>();
            List<DailyExpenseTagsWithPicsPojo> filteredList = new ArrayList<>();
            //----------- search = false, filter = false ----------------
            if ((constraint == null || constraint.length() == 0) && (categoriesForFilter == null || categoriesForFilter.size() == 0) && (tagsForFilter == null || tagsForFilter.size() == 0)) {
                filteredList.addAll(searchAllCosts);
                //----------- search = false, filter = true ----------------
            } else if ((constraint == null || constraint.length() == 0) && (categoriesForFilter != null || tagsForFilter != null)) {
                if (categoriesForFilter != null && tagsForFilter == null) {
                    for (DailyExpenseTagsWithPicsPojo item : searchAllCosts) {
                        for (String category : categoriesForFilter) {
                            if (category.equals(item.getCostEntry().getCategory())) {
                                filteredList.add(item);
                            }
                        }
                    }
                } else if (categoriesForFilter == null && tagsForFilter != null) {   //todo bug
                    for (DailyExpenseTagsWithPicsPojo item : searchAllCosts) {
                        for (String tag : tagsForFilter) {
                            if (item.getTagNames().contains(tag)) {
                                if (!filteredList.contains(item)) {
                                    filteredList.add(item);
                                }
                            }
                        }
                    }
                } else if (categoriesForFilter != null && tagsForFilter != null) {
                    for (DailyExpenseTagsWithPicsPojo item : searchAllCosts) {
                        for (String category : categoriesForFilter) {
                            if (category.equals(item.getCostEntry().getCategory())) {
                                filteredListHelper.add(item);
                            }
                        }
                    }
                    for (DailyExpenseTagsWithPicsPojo item : filteredListHelper) {
                        for (String tag : tagsForFilter) {
                            if (item.getTagNames().contains(tag)) {
                                if (!filteredList.contains(item)) {
                                    filteredList.add(item);
                                }
                            }
                        }
                    }
                }
                //----------- search = true, filter = false ----------------
            } else if (constraint.length() != 0) {
                String filterPattern = constraint.toString().toLowerCase().trim();
                for (DailyExpenseTagsWithPicsPojo item : searchAllCosts) {
                    if (item.getCostEntry().getName().toLowerCase().contains(filterPattern)) {
                        filteredList.add(item);
                    }
                }
            }
            // TODO: simultaneously search what is filtered and filter what is searched
            FilterResults results = new FilterResults();
            results.values = filteredList;
            Log.d("kraj metode", "testt");
            return results;
        }
}
}
// TODO: simultaneously search what is filtered and filter what is searched
FilterResults results = new FilterResults();
results.values = filteredList;
}
//----------- search = true, filter = false ----------------
} else if (constraint.length() != 0) {
String filterPattern = constraint.toString().toLowerCase().trim();
for (DailyExpenseTagsWithPicsPojo item : searchAllCosts) {
if (item.getCostEntry().getName().toLowerCase().contains(filterPattern)) {
filteredList.add(item);
}
}
}
// TODO: simultaneously search what is filtered and filter what is searched
FilterResults results = new FilterResults();
results.values = filteredList;
Log.d("kraj metode", "testt");
return results;
}
}
for (DailyExpenseTagsWithPicsPojo item : filteredListHelper) {
for (String tag : tagsForFilter) {
if (item.getTagNames().contains(tag)) {
if (!filteredList.contains(item)) {
filteredList.add(item);
}
}
}
}
}
//----------- search = true, filter = false ----------------
} else if (constraint.length() != 0) {
String filterPattern = constraint.toString().toLowerCase().trim();
for (DailyExpenseTagsWithPicsPojo item : searchAllCosts) {
if (item.getCostEntry().getName().toLowerCase().contains(filterPattern)) {
filteredList.add(item);
}
}
}
// TODO: simultaneously search what is filtered and filter what is searched
FilterResults results = new FilterResults();
results.values = filteredList;
Log.d("kraj metode", "testt");
return results;
}