0

If there is not remoteMediator, does this mean that refresh is the same to source.refresh?

It looks consistent from the logs, can someone give me an affirmative answer?

onCreateView: source.Refresh=NotLoading(endOfPaginationReached=false)
onCreateView: source.Append=Loading(endOfPaginationReached=false)
onCreateView: source.Prepend=NotLoading(endOfPaginationReached=true)
onCreateView: Prepend=NotLoading(endOfPaginationReached=true)
onCreateView: Refresh=NotLoading(endOfPaginationReached=false)
onCreateView: Append=Loading(endOfPaginationReached=false)
onCreateView: source.Refresh=NotLoading(endOfPaginationReached=false)
onCreateView: source.Append=NotLoading(endOfPaginationReached=false)
onCreateView: source.Prepend=NotLoading(endOfPaginationReached=true)
onCreateView: Prepend=NotLoading(endOfPaginationReached=true)
onCreateView: Refresh=NotLoading(endOfPaginationReached=false)
onCreateView: Append=NotLoading(endOfPaginationReached=false)
Michael
  • 1
  • 2

1 Answers1

0

I have found the answer, which is consistent with my conjecture.

private fun computeHelperState(
    previousState: LoadState,
    sourceRefreshState: LoadState,
    sourceState: LoadState,
    remoteState: LoadState?
): LoadState {
    
    if (remoteState == null) return sourceState // if the remoteState is null, return sourceState directly.
    
    return when (previousState) {
        is Loading -> when {
            sourceRefreshState is NotLoading && remoteState is NotLoading -> remoteState
            remoteState is Error -> remoteState
            else -> previousState
        }
        else -> remoteState
    }
}
Michael
  • 1
  • 2