Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep filtering items after adapter.updateDataSet(data) #683

Open
jurisjansons opened this issue Oct 25, 2018 · 7 comments
Open

Keep filtering items after adapter.updateDataSet(data) #683

jurisjansons opened this issue Oct 25, 2018 · 7 comments

Comments

@jurisjansons
Copy link

I have a list with items that I filter. Then I want to load new items from server, before that I call adapter.updateDataSet(null) to clear list. When I receive data from server I am setting them to adapter with 'adapter.updateDataSet(data)' and it is showing all items without filtering. When I call adapter.getFilter(String.class) before and after inserting items it returns my filter string and if I call adapter.filterItems(), after inserting them, nothing happens. How to persist my filter when updating data set?

What am I doing wrong?

@davideas
Copy link
Owner

@jurisjansons, are you trying to update the data set with a new one not filtered and then trying to filter?
Why not providing a data set already filtered?
Currently, the update of a data set does not take into account the filter in memory.
However, the reason you don't see it filtered (by calling filterItems just after the update) could be because the filter string didn't change so it skips the elaboration, but if you clear it, it will try to restore the original list first!!

Could you please describe better your use case?

@davideas
Copy link
Owner

@jurisjansons, it might be margin for an improvement, I need to understand.
Could you please answer at my questions above?
Thanks.

@jurisjansons
Copy link
Author

@davideas Sorry for late response, didn't get first notification about comment. Yes, I am updating data set with new data set and then want to apply filter that is already defined in adapter, so I am not changing it. I guess it skips filtering as you said, because filter hasn't changed. I think calling filterItems should check for both, data set change and filter string change.

Provide already filtered data set? Doesn't it mean that I won't be able to clear filter and show unfiltered data set when changing or clearing filter?

@davideas
Copy link
Owner

It might be part of the same enhancement of #675.
The logic to set or update new items is in common. The improvement should take into account the existing filter when new items or configuration changes occur.

It should be fairly easy: I will analyse it.

@davideas davideas pinned this issue Mar 27, 2019
@davideas davideas unpinned this issue Mar 27, 2019
@c4software
Copy link

Hi,

Have you found a tricks ? I'm trying to do the same things keep my filter applied after a « pull to refresh » without filter my data on the backend side.

@NLLAPPS
Copy link

NLLAPPS commented Oct 18, 2019 via email

@burakremzisenel
Copy link

import library as local module and add just following Function in FlexibleAdapter Class,
public void resetFilter() { mOldFilterEntity = null; mFilterEntity = null; }

if you want update or sort your data set and set previos filter again , the code should be look like as following,
resetFilter(); filterItems(); updateDataSet(sortedData); setFilter(prevFilter); filterItems();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants