airbnb / epoxy

Epoxy is an Android library for building complex screens in a RecyclerView
https://goo.gl/eIK82p
Apache License 2.0
8.52k stars 728 forks source link

Add model to specific position when using PagedListEpoxyController #726

Open bagusxxalam opened 5 years ago

bagusxxalam commented 5 years ago

how to add epoxy model after every 10 items when using PagedListEpoxyController ? is it possible to add model in the middle of the paged list i can add after or before super.addModels(models); on addModels method, but how to add in the middle between the pagedlist item ?

elihart commented 5 years ago

Use addModels in the PagedListEpoxyController

  /**
     * This function adds all built models to the adapter. You can override this method to add extra
     * items into the model list or remove some.
     */
    open fun addModels(models: List<EpoxyModel<*>>) {
        super.add(models)
    }

And create a new list with whatever models you want, and pass that new list to super

bagusxxalam commented 5 years ago

yes thank you i'm new to epoxy @elihart i'm using epoxy so i can use multiple view type when using paging i've another issue though i'm using staggered grid layout manager and when there's new list inserted to the db(the next page list) my current list on recyclerview shifting i guess to adjust space for the new items, i'm trying to increase the pagesize to 120 on pagedlist config but it still happening although it happen less often

i can solve the shifting issue when using epoxy by enabling the placeholder on the pagedlist config but it causing another issue, my boundary callback onItemAtEndLoaded is called when the first page list is not yet rendered to recyclerview causing my load more loading to be added on the recyclerview when there's no list and scroll pos jump to bottom(on the load more view) when the first page list finally rendered, i display load more loading when requesting next page at onItemAtEndLoaded

when i'm using only paging not with epoxy items are not shifting, i'm using staggered grid layout manager to create masonry view like pinterest i'll try to create android studio project to demonstrate this issue, but in the meantime is there any solution for this

bagusxxalam commented 5 years ago

i can solve the issue when using placeholder boundary callback onItemAtEndLoaded called before the first page items rendered on recyclerview, turn out just by increasing the page size on paged list config i make it to 30 and onItemAtEndLoaded is called after items added to recyclerview, before my page size is 12 i didn't try to increase the pagesize when enabling placeholder yesterday :smile: yes so i think i get it to work using sglm epoxy and paging without the item shifting when new items inserted on db, since i'm not experiencing another issue i'll use this setup for now (by enabling placeholder), i read epoxy recommending to disable the placeholder is it still true, what are the cons by enabling it ? @elihart

bagusxxalam commented 5 years ago

i got another question, how to update the epoxy model dynamically simliar to issue #357 but using paging, since using paging we're not storing the list as variable how we update the epoxy model state at onclick ? i got item and state like selected and on the list only one can be selected, when item is clicked we mark it as selected and show foreground color and when another is selected i make the currently selected as not selected, how to update the epoxy model dynamically ? i look on issue #357 i must edit the list and resubmit it,

elihart commented 5 years ago

The suggestion to not use placeholders actually doesn't apply anymore - it referred to an older version of the paging support that didn't work as well with placeholders, but the new version works fine with them. I'll update the wiki

elihart commented 5 years ago

Actually the wiki is already up to date, where did you see that placeholders are not recommended?

bagusxxalam commented 5 years ago

i think i read a comment from an issue related to paging in this repo, anyway i still got moving items when i dynamically change the model by doing this,

bagusxxalam commented 5 years ago

hello @elihart i've created the sample app can i send you through email/any pm ?

elihart commented 5 years ago

you could upload a zip file here

sometimes the bottom item is flashing with the image of other item and then back to the right image if that is the issue it sounds like you don't have proper ids or image recycling - something related to improperly setup models