android / codelab-android-paging

Jetpack Paging codelab
Apache License 2.0
495 stars 268 forks source link

List divider at start of list #58

Closed fedorenkoalex closed 3 years ago

fedorenkoalex commented 4 years ago

When use Pager with remoteMediator, object "before" in insertSeparators function always not null. So there is on possible to insert divider at first place.

alvindizon commented 4 years ago

Yep it's possible. See this for an example

tunjid commented 3 years ago

@fedorenkoalex much like alvindizon said, using the null check to insert the separator is the way to go.

        insertSeparators(it) { before: MyItem?, after: MyItem? ->
            if (before == null) {
                return@insertSeparators MyHeaderItem()
            }
            ...
        }