瀏覽代碼

Merge pull request #1998 from nextcloud/bugfix/1974/fixViewBindingNPE

fix NPE for viewbinding
Andy Scherzinger 3 年之前
父節點
當前提交
bddbf48198
共有 1 個文件被更改,包括 12 次插入5 次删除
  1. 12 5
      app/src/main/java/com/nextcloud/talk/controllers/ServerSelectionController.kt

+ 12 - 5
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()
             }
         }
     }