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

[Question] How to keep some items after canceling filter or search text returns empty? #198

Closed
mdtuyen opened this issue Oct 13, 2016 · 7 comments

Comments

@mdtuyen
Copy link

mdtuyen commented Oct 13, 2016

I custom some AbstractModelItem to make Header same your LayoutItem or ULSItem and put to recyclerview.

When search these item not filter so that them will disappear but I want to show them when I cancel search or clear search.

Please help me make it.
Thanks,

@mdtuyen mdtuyen closed this as completed Oct 13, 2016
@mdtuyen mdtuyen reopened this Oct 15, 2016
@mdtuyen
Copy link
Author

mdtuyen commented Oct 15, 2016

Hi @davideas , I saw that when I cancel search filterItems on Item not call, data will restore but not include header so that have no these header.

@davideas davideas added support and removed invalid labels Oct 15, 2016
@kasterlod
Copy link

Just use it in header item to have effect you want:

@OverRide
public boolean filter(String constraint) {
return false;
}

@mdtuyen
Copy link
Author

mdtuyen commented Oct 17, 2016

I understand when item filter() function return false it will not apear (but when constraint is empty this function not call). because adapter.filterItem(data, delay), data not include header. why header will appear when constaint is empty ?

@kasterlod
Copy link

data should contains headers and items , new Array, if you write empty constraint or clear search then
onQueryTextChange(String newText) should call

@mdtuyen
Copy link
Author

mdtuyen commented Oct 17, 2016

there are some special header need add not same other element as ULSItem, LayoutItem (NO HeaderItem) in demo, it not filter and restore when cancel filter.

@davideas
Copy link
Owner

davideas commented Oct 17, 2016

@mdtuyen, I executed some tests. So, if I understood well, you want some items added when the filter is reset, after a search is cleared out?

Currently the filter is asynchronously, it means that, it is executed after the caller method is completed. Indeed, if you add items or modify the adapter list, this is executed before the filter. The thread for the filter, with the unfiltered list, will overwrite any modification to the main list!
In the old version of the demo app, I added some new items like ULSItem, LayoutItem after the search is cleared. Now having the filter asynchronous those items are not present anymore due to the above behavior.

Now some ideas:

  • Filter has to remain asynchronous.
  • I can add 2 new methods onPostFilter and onPostUpdate so User can override them and correctly modify the list after the async execution.

I will restore this feature, I consider this as an enhancement.
You will need to wait until next snapshot version.

davideas added a commit that referenced this issue Oct 18, 2016
… modify the list just after the Asynchronous filter and update.
@davideas davideas changed the title [Question] How to keep some Item not filter after cancel filter or text filter is empty ? [Question] How to keep some items after canceling filter or search text returns empty? Oct 18, 2016
@davideas
Copy link
Owner

@mdtuyen, I published a new Snapshot with these 2 methods, can you try now?
I don't know if it's better to override these 2 methods (by extending FlexibleAdapter) or maybe having new listeners to implement inside the Activity/Fragment.

@davideas davideas added this to the 5.0.0-rc1 milestone Nov 22, 2016
@mdtuyen mdtuyen closed this as completed Nov 25, 2016
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

3 participants