Skip to content

Commit 4a9baff

Browse files
committed
refactor code
Signed-off-by: sowjanyakch <[email protected]>
1 parent a85d34a commit 4a9baff

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

app/src/main/java/com/nextcloud/talk/utils/BitmapShrinker.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,20 @@ object BitmapShrinker {
2626
return rotateBitmap(path, bitmap)
2727
}
2828

29-
// solution inspired by https://developer.android.com/topic/performance/graphics/load-bitmap
3029
private fun decodeBitmap(path: String, requestedWidth: Int, requestedHeight: Int): Bitmap? =
3130
BitmapFactory.Options().run {
3231
inJustDecodeBounds = true
3332
BitmapFactory.decodeFile(path, this)
3433
inSampleSize = getInSampleSize(this, requestedWidth, requestedHeight)
3534
inJustDecodeBounds = false
36-
BitmapFactory.decodeFile(path, this)?.also { bitmap ->
37-
Log.d(TAG, "Bitmap decoded successfully from path: $path")
38-
return@run bitmap
39-
}
35+
val decodedBitmap = BitmapFactory.decodeFile(path, this)
4036

41-
Log.e(TAG, "Failed to decode bitmap from path: $path")
42-
null
37+
if (decodedBitmap == null) {
38+
Log.e(TAG, "Failed to decode bitmap from path: $path")
39+
// This can occur when the file is empty or corrupted, bitmap is too large.
40+
// function does not throw an exception, but returns null
41+
}
42+
decodedBitmap
4343
}
4444

4545
// solution inspired by https://developer.android.com/topic/performance/graphics/load-bitmap

0 commit comments

Comments
 (0)