Skip to content

Commit

Permalink
Fix spotlessCheck.
Browse files Browse the repository at this point in the history
  • Loading branch information
colinrtwhite committed May 10, 2024
1 parent bacaba0 commit b53f530
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions coil-base/src/main/java/coil/RealImageLoader.kt
Original file line number Diff line number Diff line change
Expand Up @@ -123,25 +123,27 @@ internal class RealImageLoader(
}
}

override suspend fun execute(request: ImageRequest) =
override suspend fun execute(request: ImageRequest): ImageResult {
if (request.target is ViewTarget<*>) {
// We don't use the async call that returns the job for Compose to micro-optimize the performance.
// The job is only needed in case of the Views implementation.
coroutineScope { // Start executing the request on the main thread.
return coroutineScope {
// Start executing the request on the main thread.
val job = async(Dispatchers.Main.immediate) {
executeMain(request, REQUEST_TYPE_EXECUTE)
}

// Update the current request attached to the view and await the result.
request.target.view.requestManager.getDisposable(job)

job.await()
}
} else {
// Start executing the request on the main thread.
withContext(Dispatchers.Main.immediate) {
return withContext(Dispatchers.Main.immediate) {
executeMain(request, REQUEST_TYPE_EXECUTE)
}
}
}

@MainThread
private suspend fun executeMain(initialRequest: ImageRequest, type: Int): ImageResult {
Expand Down

0 comments on commit b53f530

Please sign in to comment.