Browse Source

Merge pull request #1870 from nextcloud/bugfix/1869/crash-avatar

Workaround for crash when loading avatar
Tim Krueger 3 years ago
parent
commit
4ee930f9d5
1 changed files with 11 additions and 6 deletions
  1. 11 6
      app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt

+ 11 - 6
app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt

@@ -424,12 +424,17 @@ class ChatController(args: Bundle) :
                         if (actionBar != null && bitmap != null && resources != null) {
 
                             val avatarSize = (actionBar?.height!! / 1.5).roundToInt()
-                            val bitmapResized = Bitmap.createScaledBitmap(bitmap, avatarSize, avatarSize, false)
-
-                            val roundedBitmapDrawable = RoundedBitmapDrawableFactory.create(resources!!, bitmapResized)
-                            roundedBitmapDrawable.isCircular = true
-                            roundedBitmapDrawable.setAntiAlias(true)
-                            actionBar?.setIcon(roundedBitmapDrawable)
+                            if (avatarSize > 0) {
+                                val bitmapResized = Bitmap.createScaledBitmap(bitmap, avatarSize, avatarSize, false)
+
+                                val roundedBitmapDrawable =
+                                    RoundedBitmapDrawableFactory.create(resources!!, bitmapResized)
+                                roundedBitmapDrawable.isCircular = true
+                                roundedBitmapDrawable.setAntiAlias(true)
+                                actionBar?.setIcon(roundedBitmapDrawable)
+                            } else {
+                                Log.d(TAG, "loadAvatarForStatusBar avatarSize <= 0")
+                            }
                         }
                     }