Skip to content

Commit e853748

Browse files
committed
Don't use runBlocking if async init completed
Change-Id: I641187ce277f434c6fca49a11b3cfccd50ecf5da
1 parent 7c33946 commit e853748

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

app/src/main/java/com/google/samples/apps/nowinandroid/util/ImageLoaderAsyncFactory.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,8 @@ class ImageLoaderAsyncFactory @Inject constructor(
5555
* Most likely this will be already initialized by the time we want to show an image on the screen.
5656
*/
5757
override fun newImageLoader() =
58-
trace("NiaImageLoader.runBlocking") { runBlocking { asyncNewImageLoader.await() } }
58+
trace("NiaImageLoader.runBlocking") {
59+
if (asyncNewImageLoader.isCompleted) asyncNewImageLoader.getCompleted()
60+
else runBlocking { asyncNewImageLoader.await() }
61+
}
5962
}

0 commit comments

Comments
 (0)