Skip to content

Commit

Permalink
Fixing slow create post. Fixes #117
Browse files Browse the repository at this point in the history
  • Loading branch information
dessalines committed Mar 13, 2022
1 parent 773964f commit d585412
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions app/src/main/java/com/jerboa/ui/components/common/PictrsImage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,17 @@ fun PickImage(
contract = ActivityResultContracts.GetContent()
) { uri: Uri? ->
imageUri = uri

// Set the bitmap
if (Build.VERSION.SDK_INT < 28) {
bitmap.value = MediaStore.Images
.Media.getBitmap(ctx.contentResolver, imageUri!!)
} else {
val source = ImageDecoder
.createSource(ctx.contentResolver, imageUri!!)
bitmap.value = ImageDecoder.decodeBitmap(source)
}

Log.d("jerboa", imageUri.toString())
onPickedImage(uri!!)
}
Expand All @@ -177,15 +188,6 @@ fun PickImage(
Spacer(modifier = Modifier.height(SMALL_PADDING))

imageUri?.let {
if (Build.VERSION.SDK_INT < 28) {
bitmap.value = MediaStore.Images
.Media.getBitmap(ctx.contentResolver, it)
} else {
val source = ImageDecoder
.createSource(ctx.contentResolver, it)
bitmap.value = ImageDecoder.decodeBitmap(source)
}

bitmap.value?.let { btm ->
Image(
bitmap = btm.asImageBitmap(),
Expand Down

0 comments on commit d585412

Please sign in to comment.