at com.***.frodo.group.util.ActivityListDataSource.load(ActivityListDataSource.kt:11) at androidx.paging.PageFetcherSnapshot.doInitialLoad(PageFetcherSnapshot.kt:306) at androidx.paging.PageFetcherSnapshot$pageEventFlow$1.invokeSuspend(PageFetcherSnapshot.kt:149)
privatesuspendfundoInitialLoad(scope: CoroutineScope, state: PagerState<Key, Value>) { stateLock.withLock { state.setLoading(REFRESH, false) } val params = loadParams(REFRESH, initialKey) when (val result = pagingSource.load(params)) { is Page<Key, Value> -> { val insertApplied = stateLock.withLock { state.insert(0, REFRESH, result) } // Update loadStates which are sent along with this load's Insert PageEvent. stateLock.withLock { state.loadStates.set(REFRESH, false, NotLoading.Incomplete) if (result.prevKey == null) { state.loadStates.set( type = PREPEND, remote = false, state = when (remoteMediatorAccessor) { null -> NotLoading.Complete else -> NotLoading.Incomplete } ) } if (result.nextKey == null) { state.loadStates.set( type = APPEND, remote = false, state = when (remoteMediatorAccessor) { null -> NotLoading.Complete else -> NotLoading.Incomplete } ) } } // Send insert event after load state updates, so that endOfPaginationReached is // correctly reflected in the insert event. Note that we only send the event if the // insert was successfully applied in the case of cancellation due to page dropping. if (insertApplied) { stateLock.withLock { with(state) { pageEventCh.send(result.toPageEvent(REFRESH, config.enablePlaceholders)) } } } // Launch any RemoteMediator boundary calls after applying initial insert. if (remoteMediatorAccessor != null) { if (result.prevKey == null || result.nextKey == null) { val pagingState = stateLock.withLock { state.currentPagingState(lastHint) } if (result.prevKey == null) { remoteMediatorAccessor.doBoundaryCall(scope, PREPEND, pagingState) } if (result.nextKey == null) { remoteMediatorAccessor.doBoundaryCall(scope, APPEND, pagingState) } } } } is LoadResult.Error -> stateLock.withLock { val loadState = Error(result.throwable) if (state.loadStates.set(REFRESH, false, loadState)) { pageEventCh.send(LoadStateUpdate(REFRESH, false, loadState)) } } } }