Fixed
Status Update
Comments
al...@google.com <al...@google.com>
ap...@google.com <ap...@google.com> #2
- Application get crashed when Recylerview reach at end(last page). Inside GithubRemoteMediator.kt I have set val endOfPaginationReached = page > 2 to allow maximum 2 pages for testing. So, the problem is when I reach at the last page of list, application get crashed as remoteKeys.nextKey is null(as we have set nextKey=null for last page of list).
Do you have a stack trace for the crash you could share?
- Offline cache broken How to support caching when application is open without internet connection. currently it is showing retry button. How to show previously loaded data. I have tried to fix this by removing
This might be due to loadStateFlow / listener logic on the PagingDataAdapter which hides / shows UI elements based on load state. You'll want to modify that logic to only listen to remote errors and not the local ones as well.
pa...@126.com <pa...@126.com> #3
1. stack for remoteKeys.nextKey gets null
06-17 14:48:03.981 18015-18015/com.example.android.codelabs.paging E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.android.codelabs.paging, PID: 18015
java.io.InvalidObjectException: Remote key should not be null for APPEND
at com.example.android.codelabs.paging.data.GithubRemoteMediator.load(GithubRemoteMediator.kt:68)
at com.example.android.codelabs.paging.data.GithubRemoteMediator$load$1.invokeSuspend(GithubRemoteMediator.kt)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:56)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:7325)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
2. I have checked loadStateFlow / listener logic and changed it to listen only remote errors using loadState.mediator.refersh. But still, in offline mode application shows empty list. I have also removed the loadStateFlow / listener but still, it's not working in offline mode. It is not fetching data available in databa.
06-17 14:48:03.981 18015-18015/com.example.android.codelabs.paging E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.android.codelabs.paging, PID: 18015
java.io.InvalidObjectException: Remote key should not be null for APPEND
at com.example.android.codelabs.paging.data.GithubRemoteMediator.load(GithubRemoteMediator.kt:68)
at com.example.android.codelabs.paging.data.GithubRemoteMediator$load$1.invokeSuspend(GithubRemoteMediator.kt)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:56)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:7325)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
2. I have checked loadStateFlow / listener logic and changed it to listen only remote errors using loadState.mediator.refersh. But still, in offline mode application shows empty list. I have also removed the loadStateFlow / listener but still, it's not working in offline mode. It is not fetching data available in databa.
Description
We should replace all of our null checks with the "official"
Objects.requireNonNull
which throws the correct exception.