Catch NPE on Profile view binding

Resolves: #1959

Signed-off-by: Tim Krüger <t@timkrueger.me>
This commit is contained in:
Tim Krüger 2022-05-03 12:06:41 +02:00 committed by Marcel Hibbe
parent ff5f686d7c
commit 5cb36d0801
No known key found for this signature in database
GPG Key ID: C793F8B59F43CE7B

View File

@ -93,7 +93,6 @@ import retrofit2.Response
import java.io.File import java.io.File
import java.io.FileOutputStream import java.io.FileOutputStream
import java.io.IOException import java.io.IOException
import java.util.ArrayList
import java.util.LinkedList import java.util.LinkedList
import java.util.Locale import java.util.Locale
import javax.inject.Inject import javax.inject.Inject
@ -341,13 +340,20 @@ class ProfileController : NewBaseController(R.layout.controller_profile) {
if (activity == null) { if (activity == null) {
return return
} }
binding.emptyList.emptyListViewHeadline.text = headline
binding.emptyList.emptyListViewText.text = message try {
binding.emptyList.emptyListIcon.setImageResource(errorResource) binding.emptyList.emptyListViewHeadline.text = headline
binding.emptyList.emptyListIcon.visibility = View.VISIBLE binding.emptyList.emptyListViewText.text = message
binding.emptyList.emptyListViewText.visibility = View.VISIBLE binding.emptyList.emptyListIcon.setImageResource(errorResource)
binding.userinfoList.visibility = View.GONE binding.emptyList.emptyListIcon.visibility = View.VISIBLE
binding.loadingContent.visibility = View.GONE binding.emptyList.emptyListViewText.visibility = View.VISIBLE
binding.userinfoList.visibility = View.GONE
binding.loadingContent.visibility = View.GONE
} catch (npe: NullPointerException) {
// view binding can be null
// since this is called asynchronously and UI might have been destroyed in the meantime
Log.i(TAG, "UI destroyed - view binding already gone")
}
} }
private fun createUserInfoDetails(userInfo: UserProfileData?): List<UserInfoDetailsItem> { private fun createUserInfoDetails(userInfo: UserProfileData?): List<UserInfoDetailsItem> {