Fixed crash if sharedViewModel has not been initialized when saving fragment instance state
This commit is contained in:
parent
60cc5a31c4
commit
72ae8f2e67
1 changed files with 9 additions and 5 deletions
|
@ -109,11 +109,15 @@ class DetailChatRoomFragment : MasterFragment<ChatRoomDetailFragmentBinding, Cha
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onSaveInstanceState(outState: Bundle) {
|
override fun onSaveInstanceState(outState: Bundle) {
|
||||||
val chatRoom = sharedViewModel.selectedChatRoom.value
|
if (::sharedViewModel.isInitialized) {
|
||||||
if (chatRoom != null) {
|
val chatRoom = sharedViewModel.selectedChatRoom.value
|
||||||
outState.putString("LocalSipUri", chatRoom.localAddress.asStringUriOnly())
|
if (chatRoom != null) {
|
||||||
outState.putString("RemoteSipUri", chatRoom.peerAddress.asStringUriOnly())
|
outState.putString("LocalSipUri", chatRoom.localAddress.asStringUriOnly())
|
||||||
Log.i("[Chat Room] Saving current chat room local & remote addresses in save instance state")
|
outState.putString("RemoteSipUri", chatRoom.peerAddress.asStringUriOnly())
|
||||||
|
Log.i("[Chat Room] Saving current chat room local & remote addresses in save instance state")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Log.w("[Chat Room] Can't save instance state, sharedViewModel hasn't been initialized yet")
|
||||||
}
|
}
|
||||||
super.onSaveInstanceState(outState)
|
super.onSaveInstanceState(outState)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue