Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F33398593
D15414.1768980020.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D15414.1768980020.diff
View Options
diff --git a/native/expo-modules/comm-expo-package/android/src/main/java/app/comm/android/thumbhash/ThumbhashModule.kt b/native/expo-modules/comm-expo-package/android/src/main/java/app/comm/android/thumbhash/ThumbhashModule.kt
--- a/native/expo-modules/comm-expo-package/android/src/main/java/app/comm/android/thumbhash/ThumbhashModule.kt
+++ b/native/expo-modules/comm-expo-package/android/src/main/java/app/comm/android/thumbhash/ThumbhashModule.kt
@@ -31,10 +31,7 @@
private fun generateThumbHash(photoURI: Uri): String {
val bitmap = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
- // For API >= 28 we can use the ImageDecoder API which is more modern
- // and allows to resize bitmap to desired size while loading the file
- val source = ImageDecoder.createSource(this.contentResolver, photoURI)
- ImageDecoder.decodeBitmap(source, this.decoderListener)
+ decodeBitmapApi28(photoURI)
} else {
// For older devices, we use the BitmapFactory thing which is less
// flexible, but at least we can request for the ARGB_8888 to avoid
@@ -59,8 +56,11 @@
// endregion
@RequiresApi(Build.VERSION_CODES.P)
- private val decoderListener =
- ImageDecoder.OnHeaderDecodedListener { imageDecoder, imageInfo, _ ->
+ private fun decodeBitmapApi28(photoURI: Uri): Bitmap {
+ // For API >= 28 we can use the ImageDecoder API which is more modern
+ // and allows to resize bitmap to desired size while loading the file
+ val source = ImageDecoder.createSource(this.contentResolver, photoURI)
+ return ImageDecoder.decodeBitmap(source) { imageDecoder, imageInfo, _ ->
val (w, h) = imageInfo.size
val newWidth = THUMB_SIZE * w / max(w, h)
val newHeight = THUMB_SIZE * h / max(w, h)
@@ -68,6 +68,7 @@
imageDecoder.allocator = ImageDecoder.ALLOCATOR_SOFTWARE
imageDecoder.setTargetSize(newWidth, newHeight)
}
+ }
private val contentResolver: ContentResolver
get() = requireNotNull(this.appContext.reactContext) {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Jan 21, 7:20 AM (3 h, 8 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5955718
Default Alt Text
D15414.1768980020.diff (1 KB)
Attached To
Mode
D15414: [native] Fix ThumbhashModule.kt for Android 8
Attached
Detach File
Event Timeline
Log In to Comment