mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-11-23 05:25:31 +03:00
avoid NPE when context is not known when creating conversation
NPE without this fix: Exception java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.content.Context.getPackageName()' on a null object reference at android.content.ComponentName.<init> (ComponentName.java:132) at android.content.Intent.<init> (Intent.java:8269) at com.nextcloud.talk.conversation.CreateConversationDialogFragment.initiateConversation (CreateConversationDialogFragment.kt:276) at com.nextcloud.talk.conversation.CreateConversationDialogFragment.access$initiateConversation (CreateConversationDialogFragment.kt:63) at com.nextcloud.talk.conversation.CreateConversationDialogFragment$addParticipants$1.invoke (CreateConversationDialogFragment.kt:257) at com.nextcloud.talk.conversation.CreateConversationDialogFragment$addParticipants$1.invoke (CreateConversationDialogFragment.kt:248) at com.nextcloud.talk.conversation.CreateConversationDialogFragment$sam$androidx_lifecycle_Observer$0.onChanged at androidx.lifecycle.LiveData.considerNotify (LiveData.java:133) at androidx.lifecycle.LiveData.dispatchingValue (LiveData.java:151) at androidx.lifecycle.LiveData.setValue (LiveData.java:309) at androidx.lifecycle.MutableLiveData.setValue (MutableLiveData.java:50) at androidx.lifecycle.LiveData$1.run (LiveData.java:93) at android.os.Handler.handleCallback (Handler.java:958) at android.os.Handler.dispatchMessage (Handler.java:99) at android.os.Looper.loopOnce (Looper.java:230) at android.os.Looper.loop (Looper.java:319) at android.app.ActivityThread.main (ActivityThread.java:8893) at java.lang.reflect.Method.invoke at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:608) at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1103) Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
082ba8d00b
commit
2ce3b2bbd8
1 changed files with 9 additions and 7 deletions
|
@ -222,6 +222,7 @@ class CreateConversationDialogFragment : DialogFragment() {
|
|||
Log.e(TAG, "Failed to create conversation")
|
||||
showError()
|
||||
}
|
||||
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
|
@ -270,13 +271,14 @@ class CreateConversationDialogFragment : DialogFragment() {
|
|||
}
|
||||
|
||||
private fun initiateConversation(roomToken: String) {
|
||||
val bundle = Bundle()
|
||||
bundle.putString(BundleKeys.KEY_ROOM_TOKEN, roomToken)
|
||||
|
||||
val chatIntent = Intent(context, ChatActivity::class.java)
|
||||
chatIntent.putExtras(bundle)
|
||||
chatIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
|
||||
startActivity(chatIntent)
|
||||
activity?.let {
|
||||
val bundle = Bundle()
|
||||
bundle.putString(BundleKeys.KEY_ROOM_TOKEN, roomToken)
|
||||
val chatIntent = Intent(it, ChatActivity::class.java)
|
||||
chatIntent.putExtras(bundle)
|
||||
chatIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
|
||||
startActivity(chatIntent)
|
||||
}
|
||||
|
||||
dismiss()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue