-
-
Notifications
You must be signed in to change notification settings - Fork 492
Paged list - selectExtension.getSelectedItems() loads _all_ the placeholders #861
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
Comments
@RobbWatershed the prefetching and everything is done by the The FastAdapter just acts and serves to have the adapter logic split apart from the item (UI) logic. And allows you to have own models different than the items. In addition the FastAdapter provides selection, ... support |
Let me be a little more precise. The interesting part of the call stack is as follows
In Once that loop reaches the part of the list where placeholders are, If I may suggest something, that optional flag I was imagining could be used in The caller already checks if the returned What do you think about that ? |
@RobbWatershed oh I see. that may actually be seen as a bug as it is not anticipated that the FastAdapter results in triggering to load in the whole list. As you pointed out that's quite against the point of a PagedList :D |
@RobbWatershed looking at it I may think that this may actually not be possible. as there are 2 problems: 1.) to get the selected items we have to iterate through the whole list to see what got selected May I ask why you need to ask for Perhaps there may be a better approach for your usecase whereas you keep a set of the identifiers of your selections, so you don't have to ask the whole list for what maybe got selected? (side fact. in the past the FastAdapter kept a separate list of selections, but keeping an additional state served dangerous to keep it in sync with the main data set. and in 99% of the cases the length of the lists don't reach sizes where a single iteration through would be concerning) |
From my point of view, while iterating through the whole list is obviously necessary, iterating through all the
I have successfuly used Sample code long nbPlaceholders = Stream.of(iLibrary.subList(minIndex, maxIndex)).filter(c -> c == null).count();
The use case I rely the most on getSelectedItems is as follows :
Sample code Set<ContentItem> selectedItems = selectExtension.getSelectedItems();
if (!selectedItems.isEmpty()) {
List<Content> selectedContent = Stream.of(selectedItems).map(ContentItem::getContent).toList();
askDeleteItems(selectedContent);
} It's true that I could keep track of selected indexes on a separate list, but this is far from elegant. I'd rather discuss first with you to see if the path is blocked or not. Thanks for your patience and time by the way ! 👍 👍 |
So I tried to bring in an item peeking possibility which hopefully resolves the problem for you. I will provide an alpha and it would be really amazing if you could give it a spin and report back |
…king for the selected item - fix #861
please have a look at v5.0.0-a02 |
Thanks for the quick action. It looks like it doesn't work yet, although the code you commited looks good. At first analysis, I'd say the problem is you simply forgot to override The object I'm using is an instance of |
Currently uploading v5.0.0-a03 for you :D |
Fantastic. My DAO is silent and the side effects are gone. If I could hug you right now, I would definitely do it ! Thanks a lot for your time 👍 👍 👍 https://i.kym-cdn.com/photos/images/newsfeed/001/115/816/936.gif |
I am glad I could help :D |
About this issue
I'm using FastAdapter with
PagedModelAdapter
to display a large list of books.Repro steps
PagedList
on a library with 70 books, usingPagedList.Config.Builder
andenablePlaceholders = true
initialLoadSizeHint = 40
pageSize = 20
View the first 10 items on a
RecyclerView
Call
selectExtension.getSelectedItems()
Expected behaviour
The selected items are returned; the DAO is never called
Only the first 40 items are loaded in the
PagedList
; the 30 others still are placeholdersActual behaviour
As soon as
selectExtension.getSelectedItems()
is called, the DAO loads books 41 to 60 and 61 to 70.All 70 items are loaded in the
PagedList
; no placeholder is left even though theRecyclerView
has never gone beyond position 10.Note
Loading all placeholders has both a performance impact and super weird side effects on my app.
If the current behaviour works as designed, could you at least add an option to avoid loading placeholders when collecting selected items ? Thanks a bunch !
Details
Checklist
The text was updated successfully, but these errors were encountered: