Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix image upload cancel crash #671

Merged
merged 3 commits into from
Jun 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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