androidkotlinandroid-paging-library

Paging library from Architectural components


I have following project in Bitbucket : https://github.com/Ali-Rezaei/TMDb-Paging (You need a Api key from https://www.themoviedb.org/ and paste it to local.properties to run the app such as tmdb_api_key=YOUR_API_KEY)

In PageKeyedMovieDataSource class I have loadInitial method,

With following line :

callback.onResult(items, null, "")

I pass "" for nextPageKey.

And the same story for loadAftermethod. I pass "" for adjacentPageKey:

callback.onResult(items, "")

App works fine but I don't know what is the best approach here. What should I pass?


Solution

  • I Just built an app that uses paging with the TMDB, you can see it here the source contains everything you'll need to create a simple app using best practices and clean architecture but if you just want to see the raw code that what I use

    Code for returning the result on loadInitial()

    callback.onResult(response.movies, 1, response.totalPages, null, 2)
    

    And this code for returning the result on loadAfter()

    callback.onResult(response.movies, params.key + 1)