Skip to content
This repository has been archived by the owner on Dec 9, 2024. It is now read-only.

Auto scroll to bottom for initial loading and does not load subsequent page #165

Open
anderscheow opened this issue May 5, 2021 · 2 comments

Comments

@anderscheow
Copy link

Issues:

  1. When loading first page for the first time, recycler view scrolled to very bottom
  2. Sometimes does not load subsequent page after loading first page for the first time

https://drive.google.com/drive/folders/14aOosTqeY747SajXxcgwTrzLwD51NZNP?usp=sharing

@johnjake
Copy link

johnjake commented May 6, 2021

I encounter the same scenario where in subsequent page does not load only page 1, the reason because list table must align to remoteKeys table, take a look on Mediator code the getKeyForLastItem, getKeyForFirstItem, getKeyToCurrentPosition

    `database.remoteKeysDao().remoteKeysRepoId(userDB.id)` 

the paging uses 2 tables to cache the list, your list table and remotekeys table.

example:

UserDB----------------------------------------------- Remotekeys
@PrimaryKey(autoGenerate = true) @PrimaryKey(autoGenerate = true)
val uid: Int ---------------------------------- val repoId: Int
val id: Int ------------------------------------ val prevKey: Int

In above example the UserDB has two Ids uid which is the autogenerated int when you insert a value in UserDB table, and the val id: int which is the list Id from your api endpoint. During loading data to mediator you are using the val id: Int to create or insert RemoteKeys repoId, prevKey and nextKey. Make sure you are using the same Id in remotekeys and userDB. If I change the database.remoteKeysDao().remoteKeysRepoId(userDB.uid) I will only get page 1 with no subsequent pages. As uid is not equal to repoId which is the val id: int of UserDB.

@imSathish
Copy link

@anderscheow Facing the same issue. Any update about the issue

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants