Closed y4n9b0 closed 3 years ago
In the SO post you linked, it clearly states that the suspending call adapter for Retrofit will dispatch on background thread for you. If this were not the case, Android would immediately throw a NetworkOnMainThreadException crashing the app.
To be clear, in a suspending function that makes a suspending network call via retrofit, only the network call is made on the background thread.. so you might end up with:
suspend fun load(..): .. {
doStuff() // This will usually run on main thread by default
retrofitCall() // This is automatically dispatched on Dispatchers.IO
doMoreStuff() // This will usually run on main thread by default
}
A network call on main thread will definitely not produce an ANR, it will immediately crash the app.
redditApi.getTop() was executed in main thread, both in PagingSource and RemoteMediator.
Also same problem here