Group Group Group Group Group Group Group Group Group

Paging Library for Android With Kotlin: Creating Infinite Lists | Ray Wenderlich

#1

In this tutorial, you will build up a simple Reddit Clone that loads pages of information gradually into an infinite list using the Paging library and Room.


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/6948-paging-library-for-android-with-kotlin-creating-infinite-lists
#3

You have an error in this code block when implementing Room:

  private fun initializedPagedListBuilder(config: PagedList.Config):
          LivePagedListBuilder<Int, RedditPost> {

    val livePageListBuilder = LivePagedListBuilder<Int, RedditPost>(
            database.postDao().posts(),
            config)
    return livePageListBuilder
  }

Should contain the line:

    val database = RedditDb.create(this)

I just checked the final code to see this missing bit

#4

@alexsullivan Can you please help with this when you get a chance? Thank you - much appreciated! :]

#5

Good catch! I’ve updated the tutorial accordingly.

#6

A nice feature to add in this tutorial is to keep the recyclerView position after device rotation.

I’m managing this onSaveInstanceState and onResume() methods, but maybe there is a better solution with LiveData that I’m not aware.

#7

@andrezizu That’s a good idea! I think your best bet is going to be exposing the LiveData from a jetpack ViewModel object. The ViewModel will then be saved on rotation and your list should display immediately.