android / codelab-android-paging

Jetpack Paging codelab

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

calling adapter.refresh() crashes with illegalstateException

raghunandankavi2010 opened this issue · comments

 java.lang.IllegalStateException: An instance of PagingSource was re-used when Pager expected to create a new
    instance. Ensure that the pagingSourceFactory passed to Pager always returns a
    new instance of PagingSource.

Crashed with above exception. Added only swipe refresh and called adapter.refresh()

Need to create a new paging source when you call refresh. It was a mistake at my end.

@raghunandankavi2010
How could you create new paging source?

Are you created a whole new Pager object? If not, how did you updated paging source in Pager?

Create a new pager object when you refresh. The sample does this already.