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

[5.0.0-b6 && current SNAPSHOT] filter on restore instance state #111

Closed
francescopedronomnys opened this issue Jun 9, 2016 · 4 comments
Closed

Comments

@francescopedronomnys
Copy link

francescopedronomnys commented Jun 9, 2016

Hi,
on restore instance state in your FlexibleAdapter you are restoring the search text, but items are not filtered after restoration (the problem is present also on items addition).

I'm able to replicate the restore instance state case both on my code and on the sample up currently on the dev branch.
To replicate that on the sample app setup your device with "Don't keep activities" in Android's Developer Options, then in the sample app select a fragment that supports filtering (e.g I'm using "EndlessScrolling"), apply a filter (e.g. I'm using "2" to get items with a "2" in the name), hit device's home button and then reopen the sample app from Android's recent activities.
The result is now that all the items are shown again but items with a "2" in the name will have that character highlighted.

You can replicate that also when using addItems() method simply applying a filter text and scrolling your EndlessScrolling list.

I think that the expected behaviour should be to see only items that are included in the filter.

Let me know if you have any workaround until this is fixed on library level.

Thanks,
Francesco

@davideas davideas added the bug label Jun 9, 2016
@davideas
Copy link
Owner

davideas commented Jun 9, 2016

Hello @francescopedronomnys, I confirm that the searchText is not taken into account when rotating, However, there are 2 bugs:

  1. the current filter is ignored when rotating (i found it the cause)
  2. searchView doesn't remain expanded

Regarding the endlessScrolling with filter, I believe that the active filter must be handled by the user.
The addition of the new items, does simply the addition. Expanded status, filter or anything else cannot be taken into account when adding new items.
Here there are 2 hypothesis of use case:

  • For normal search, when the filter is active, endless should be disabled. User wants to search in the current collection not new items coming from remote. (I can fix the demo by disabling the new endless scrolling feature).
  • If instead, it's a special search that loads more items based on current filter, then the new items are already part of the same filtered collection... In the wrong hypothesis new items arrive and only few are part of the filtered collection, then the items that don't contain the searchText will not be added in any case, therefore those items should not be passed to the adapter at all... In the correct hypothesis user should call the remote resource to pick up only the items that match the current filter.
    (Here I can fix the demo to simulate only the arrival of the items filtered).

You can tell me your considerations.
However, I resolved the first 2 little bugs in the meantime, (rotation with filter was already working in the past, but I included in the library the concept of the old text, that must not be saved in the state). Maybe a JUnit test could intercept it, but it takes too much time to developed automatic unit test.

@francescopedronomnys
Copy link
Author

francescopedronomnys commented Jun 10, 2016

Sorry, closed by mistake, I tought that you implemented also the items filtering restoration, but this is not the case with my app on the latest SNAPSHOT (I'm not using the search text view as you are doing in the sample app, hence my items are not filtered on restoration).

Feel free to close this if you think this is not a bug, I will come back with more info on that for another possible bug on this matter that happens when I call filterItems() right after restoration, but I need to investigate more.

Francesco

@davideas
Copy link
Owner

Ciao @francescopedronomnys, if you mean item restoration after filter and viceversa, this is already done. Thing is bit complicated when there are header and expandable items (hidden by the current filter), but it works.
If not that, what did you mean with "items filtering restoration"?

@francescopedronomnys
Copy link
Author

Ok, sorry, I tought it was already inside the current SNAPSHOT but it is not.

Anyway I've implemented a filter before addItems and I'm restoring filter search text in my onRestoreInstanceState and now I got the correct behaviour.

Thanks,
Francesco

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

2 participants