add logging and toasts if current user was null

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
Marcel Hibbe 2022-12-13 15:24:56 +01:00 committed by Andy Scherzinger
parent e9dbcc554a
commit f73d1c14fc
No known key found for this signature in database
GPG Key ID: 6CADC7E3523C308B
2 changed files with 29 additions and 20 deletions

View File

@ -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) {

View File

@ -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)
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()
)
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()
}
}