From 30f65424a546fd5a8b32177537124a6e4827562c Mon Sep 17 00:00:00 2001 From: Marcel Hibbe Date: Fri, 6 May 2022 14:58:30 +0200 Subject: [PATCH] fix NPE for viewbinding Signed-off-by: Marcel Hibbe --- .../controllers/ServerSelectionController.kt | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/controllers/ServerSelectionController.kt b/app/src/main/java/com/nextcloud/talk/controllers/ServerSelectionController.kt index cf13445ec..39179b357 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/ServerSelectionController.kt +++ b/app/src/main/java/com/nextcloud/talk/controllers/ServerSelectionController.kt @@ -347,15 +347,22 @@ class ServerSelectionController : setCertTextView() } + @SuppressLint("LongLogTag") private fun setCertTextView() { if (activity != null) { activity!!.runOnUiThread { - if (!TextUtils.isEmpty(appPreferences!!.temporaryClientCertAlias)) { - binding.certTextView.setText(R.string.nc_change_cert_auth) - } else { - binding.certTextView.setText(R.string.nc_configure_cert_auth) + try { + if (!TextUtils.isEmpty(appPreferences!!.temporaryClientCertAlias)) { + binding.certTextView.setText(R.string.nc_change_cert_auth) + } else { + binding.certTextView.setText(R.string.nc_configure_cert_auth) + } + hideserverEntryProgressBar() + } catch (npe: java.lang.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") } - hideserverEntryProgressBar() } } }