-
Notifications
You must be signed in to change notification settings - Fork 26
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
chore: enable penalty death on strict mode #2251
Changes from 1 commit
a727964
9f5935e
44574c3
b866f95
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ | |
|
||
package com.wire.android.ui.common.imagepreview | ||
|
||
import android.graphics.Bitmap | ||
import android.net.Uri | ||
import androidx.compose.foundation.Image | ||
import androidx.compose.foundation.background | ||
|
@@ -29,6 +30,9 @@ import androidx.compose.foundation.layout.fillMaxSize | |
import androidx.compose.foundation.layout.height | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.State | ||
import androidx.compose.runtime.produceState | ||
import androidx.compose.runtime.rememberCoroutineScope | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.geometry.Size | ||
import androidx.compose.ui.geometry.toRect | ||
|
@@ -44,6 +48,19 @@ import androidx.constraintlayout.compose.ConstraintLayout | |
import coil.compose.rememberAsyncImagePainter | ||
import com.wire.android.ui.common.dimensions | ||
import com.wire.android.util.toBitmap | ||
import kotlinx.coroutines.Dispatchers | ||
import kotlinx.coroutines.launch | ||
|
||
@Composable | ||
private fun loadBiMap(imageUri: Uri): State<Bitmap?> { | ||
alexandreferris marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we set this as an extension function annotated with stable? @Stable
suspend fun Context.loadBitMap(imageUri: Uri): State<Bitmap?> {
return produceState<Bitmap?>(initialValue = null, imageUri) {
withContext(Dispatchers.IO) {
value = imageUri.toBitmap(this)
}
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It will be hard to pass the returned value from this suspend function to the composable as a param |
||
val coroutineScope = rememberCoroutineScope() | ||
val context = LocalContext.current | ||
return produceState<Bitmap?>(initialValue = null, imageUri) { | ||
coroutineScope.launch(Dispatchers.IO) { | ||
value = imageUri.toBitmap(context) | ||
} | ||
} | ||
} | ||
|
||
@Composable | ||
fun BulletHoleImagePreview( | ||
|
@@ -67,7 +84,7 @@ fun BulletHoleImagePreview( | |
} | ||
) { | ||
Image( | ||
painter = rememberAsyncImagePainter(imageUri.toBitmap(LocalContext.current)), | ||
painter = rememberAsyncImagePainter(loadBiMap(imageUri).value), | ||
saleniuk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
contentScale = ContentScale.Crop, | ||
contentDescription = contentDescription, | ||
modifier = Modifier.fillMaxSize(), | ||
|
@@ -97,7 +114,11 @@ fun BulletHoleImagePreview( | |
@Suppress("MagicNumber") | ||
class BulletHoleShape : Shape { | ||
|
||
override fun createOutline(size: Size, layoutDirection: LayoutDirection, density: Density): Outline { | ||
override fun createOutline( | ||
size: Size, | ||
layoutDirection: LayoutDirection, | ||
density: Density | ||
): Outline { | ||
return Outline.Generic( | ||
drawBulletHolePath(size) | ||
) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just out of curiosity, what's the VM policy for? emulators or images run in CI??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No no nothing related to CI..We are just setting in Virtual Machine what actions should be detected.