Skip to content

Commit

Permalink
Fix image upload cancel crash (#671)
Browse files Browse the repository at this point in the history
* Fix image upload cancel crash

* 💄 revert formatting changes
  • Loading branch information
noloman authored Jun 15, 2023
1 parent f680226 commit 19c79b5
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions app/src/main/java/com/jerboa/ui/components/common/PictrsImage.kt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
package com.jerboa.ui.components.common

import android.graphics.Bitmap
import android.net.Uri
import android.util.Log
Expand Down Expand Up @@ -188,11 +189,13 @@ fun PickImage(
val launcher = rememberLauncherForActivityResult(
ActivityResultContracts.GetContent(),
) { uri ->
imageUri = uri
bitmap.value = decodeUriToBitmap(ctx, imageUri!!)
Log.d("jerboa", "Uploading image...")
Log.d("jerboa", imageUri.toString())
onPickedImage(uri!!)
uri?.let {
imageUri = it
bitmap.value = decodeUriToBitmap(ctx, it)
Log.d("jerboa", "Uploading image...")
Log.d("jerboa", imageUri.toString())
onPickedImage(it)
}
}
Column(
modifier = modifier,
Expand All @@ -209,14 +212,11 @@ fun PickImage(

if (showImage) {
Spacer(modifier = Modifier.height(SMALL_PADDING))

imageUri?.let {
bitmap.value?.let { btm ->
Image(
bitmap = btm.asImageBitmap(),
contentDescription = stringResource(R.string.pickImage_imagePreview),
)
}
bitmap.value?.let { btm ->
Image(
bitmap = btm.asImageBitmap(),
contentDescription = stringResource(R.string.pickImage_imagePreview),
)
}
}
}
Expand Down

0 comments on commit 19c79b5

Please sign in to comment.