I\'m trying to replace Picasso in my android app with Fresco. However I am unsure of how to simply load a bitmap using Fresco.
With Picasso I would just do the foll
I found this solution using Kotlin's coroutines:
suspend fun getBitmapFromUri(imageUri: Uri): Bitmap = withContext(Dispatchers.Default) {
val imageRequest = ImageRequestBuilder.newBuilderWithSource(imageUri).build()
val dataSource = Fresco.getImagePipeline().fetchDecodedImage(imageRequest, this)
val result = DataSources.waitForFinalResult(dataSource) as CloseableReference
val bitmap = result.get().underlyingBitmap
CloseableReference.closeSafely(result)
dataSource.close()
return@withContext bitmap
}