avoid NPE when answering call

this could happen very rarely when clicking very fast to accept the call before the conversation was set.

Exception java.lang.NullPointerException:
  at com.nextcloud.talk.activities.CallNotificationActivity.proceedToCall (CallNotificationActivity.kt:156)
  at com.nextcloud.talk.activities.CallNotificationActivity.initClickListeners$lambda$0 (CallNotificationActivity.kt:126)
  at com.nextcloud.talk.activities.CallNotificationActivity.$r8$lambda$0cnB_UmYcTD4PyxIBSZCZs1m_6s
  at com.nextcloud.talk.activities.CallNotificationActivity$$ExternalSyntheticLambda0.onClick
  at android.view.View.performClick (View.java:6612)
  at android.view.View.performClickInternal (View.java:6581)
  at android.view.View.access$3100 (View.java:785)
  at android.view.View$PerformClick.run (View.java:25904)
  at android.os.Handler.handleCallback (Handler.java:873)
  at android.os.Handler.dispatchMessage (Handler.java:99)
  at android.os.Looper.loop (Looper.java:280)
  at android.app.ActivityThread.main (ActivityThread.java:6706)
  at java.lang.reflect.Method.invoke
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:493)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:858)

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
Marcel Hibbe 2023-01-20 09:31:44 +01:00
parent f493c84108
commit 11d089485e
No known key found for this signature in database
GPG key ID: C793F8B59F43CE7B

View file

@ -153,6 +153,7 @@ class CallNotificationActivity : CallBaseActivity() {
} }
private fun proceedToCall() { private fun proceedToCall() {
if (currentConversation != null) {
originalBundle!!.putString(KEY_ROOM_TOKEN, currentConversation!!.token) originalBundle!!.putString(KEY_ROOM_TOKEN, currentConversation!!.token)
originalBundle!!.putString(KEY_CONVERSATION_NAME, currentConversation!!.displayName) originalBundle!!.putString(KEY_CONVERSATION_NAME, currentConversation!!.displayName)
@ -172,6 +173,9 @@ class CallNotificationActivity : CallBaseActivity() {
val intent = Intent(this, CallActivity::class.java) val intent = Intent(this, CallActivity::class.java)
intent.putExtras(originalBundle!!) intent.putExtras(originalBundle!!)
startActivity(intent) startActivity(intent)
} else {
Log.w(TAG, "conversation was still null when clicked to answer call. User has to click another time.")
}
} }
@Suppress("MagicNumber") @Suppress("MagicNumber")