File tree Expand file tree Collapse file tree 1 file changed +7
-7
lines changed
app/src/main/java/com/nextcloud/talk/utils Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments