Преглед изворни кода

add logging and toasts if current user was null

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
Marcel Hibbe пре 2 година
родитељ
комит
f73d1c14fc

+ 3 - 3
app/src/main/java/com/nextcloud/talk/controllers/AccountVerificationController.kt

@@ -324,9 +324,9 @@ class AccountVerificationController(args: Bundle? = null) :
                     }
                     if (!TextUtils.isEmpty(displayName)) {
                         storeProfile(
-                            displayName, userProfileOverall.ocs!!.data!!.userId!!,
-                            capabilities.ocs!!.data!!
-                                .capabilities!!
+                            displayName,
+                            userProfileOverall.ocs!!.data!!.userId!!,
+                            capabilities.ocs!!.data!!.capabilities!!
                         )
                     } else {
                         if (activity != null) {

+ 27 - 18
app/src/main/java/com/nextcloud/talk/controllers/ConversationsListController.kt

@@ -209,26 +209,30 @@ class ConversationsListController(bundle: Bundle) :
     private fun loadUserAvatar(
         target: Target
     ) {
-
         if (activity != null) {
-            val url = ApiUtils.getUrlForAvatar(
-                currentUser!!.baseUrl,
-                currentUser!!.userId,
-                true
-            )
+            if (currentUser != null) {
+                val url = ApiUtils.getUrlForAvatar(
+                    currentUser!!.baseUrl,
+                    currentUser!!.userId,
+                    true
+                )
 
-            val credentials = ApiUtils.getCredentials(currentUser!!.username, currentUser!!.token)
-
-            context.imageLoader.enqueue(
-                ImageRequest.Builder(context)
-                    .data(url)
-                    .addHeader("Authorization", credentials)
-                    .placeholder(R.drawable.ic_user)
-                    .transformations(CircleCropTransformation())
-                    .crossfade(true)
-                    .target(target)
-                    .build()
-            )
+                val credentials = ApiUtils.getCredentials(currentUser!!.username, currentUser!!.token)
+
+                context.imageLoader.enqueue(
+                    ImageRequest.Builder(context)
+                        .data(url)
+                        .addHeader("Authorization", credentials)
+                        .placeholder(R.drawable.ic_user)
+                        .transformations(CircleCropTransformation())
+                        .crossfade(true)
+                        .target(target)
+                        .build()
+                )
+            } else {
+                Log.e(TAG, "currentUser was null in loadUserAvatar")
+                Toast.makeText(context, R.string.nc_common_error_sorry, Toast.LENGTH_LONG).show()
+            }
         }
     }
 
@@ -238,6 +242,7 @@ class ConversationsListController(bundle: Bundle) :
             override fun onStart(placeholder: Drawable?) {
                 button.icon = placeholder
             }
+
             override fun onSuccess(result: Drawable) {
                 button.icon = result
             }
@@ -251,6 +256,7 @@ class ConversationsListController(bundle: Bundle) :
             override fun onStart(placeholder: Drawable?) {
                 menuItem.icon = placeholder
             }
+
             override fun onSuccess(result: Drawable) {
                 menuItem.icon = result
             }
@@ -288,6 +294,9 @@ class ConversationsListController(bundle: Bundle) :
                     .colorMaterialTextButton((activity as MainActivity?)!!.binding.switchAccountButton)
             }
             fetchRooms()
+        } else {
+            Log.e(TAG, "currentUser was null in ConversationsListController.onAttach")
+            Toast.makeText(context, R.string.nc_common_error_sorry, Toast.LENGTH_LONG).show()
         }
     }