Don't use arguments to pass list of Addresses between fragments, might crash in a writeToParcel
This commit is contained in:
parent
712852cdce
commit
2131458ac1
6 changed files with 19 additions and 17 deletions
|
@ -348,11 +348,11 @@ internal fun DetailChatRoomFragment.navigateToEphemeralInfo() {
|
|||
}
|
||||
}
|
||||
|
||||
internal fun ChatRoomCreationFragment.navigateToGroupInfo(args: Bundle?) {
|
||||
internal fun ChatRoomCreationFragment.navigateToGroupInfo() {
|
||||
if (findNavController().currentDestination?.id == R.id.chatRoomCreationFragment) {
|
||||
findNavController().navigate(
|
||||
R.id.action_chatRoomCreationFragment_to_groupInfoFragment,
|
||||
args,
|
||||
null,
|
||||
getRightToLeftAnimationNavOptions()
|
||||
)
|
||||
}
|
||||
|
|
|
@ -35,7 +35,6 @@ import org.linphone.activities.main.fragments.SecureFragment
|
|||
import org.linphone.activities.main.navigateToChatRoom
|
||||
import org.linphone.activities.main.navigateToGroupInfo
|
||||
import org.linphone.activities.main.viewmodels.SharedMainViewModel
|
||||
import org.linphone.core.Address
|
||||
import org.linphone.core.tools.Log
|
||||
import org.linphone.databinding.ChatRoomCreationFragmentBinding
|
||||
import org.linphone.utils.PermissionHelper
|
||||
|
@ -128,14 +127,13 @@ class ChatRoomCreationFragment : SecureFragment<ChatRoomCreationFragmentBinding>
|
|||
}
|
||||
})
|
||||
|
||||
addParticipantsFromBundle()
|
||||
addParticipantsFromSharedViewModel()
|
||||
|
||||
// Next button is only used to go to group chat info fragment
|
||||
binding.setNextClickListener {
|
||||
sharedViewModel.createEncryptedChatRoom = viewModel.isEncrypted.value == true
|
||||
val args = Bundle()
|
||||
args.putSerializable("participants", viewModel.selectedAddresses.value)
|
||||
navigateToGroupInfo(args)
|
||||
sharedViewModel.chatRoomParticipants.value = viewModel.selectedAddresses.value
|
||||
navigateToGroupInfo()
|
||||
}
|
||||
|
||||
viewModel.onErrorEvent.observe(viewLifecycleOwner, {
|
||||
|
@ -150,9 +148,8 @@ class ChatRoomCreationFragment : SecureFragment<ChatRoomCreationFragmentBinding>
|
|||
}
|
||||
}
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
private fun addParticipantsFromBundle() {
|
||||
val participants = arguments?.getSerializable("participants") as? ArrayList<Address>
|
||||
private fun addParticipantsFromSharedViewModel() {
|
||||
val participants = sharedViewModel.chatRoomParticipants.value
|
||||
if (participants != null && participants.size > 0) {
|
||||
viewModel.selectedAddresses.value = participants
|
||||
}
|
||||
|
|
|
@ -398,6 +398,7 @@ class DetailChatRoomFragment : MasterFragment<ChatRoomDetailFragmentBinding, Cha
|
|||
|
||||
private fun showGroupInfo(chatRoom: ChatRoom) {
|
||||
sharedViewModel.selectedGroupChatRoom.value = chatRoom
|
||||
sharedViewModel.chatRoomParticipants.value = arrayListOf()
|
||||
navigateToGroupInfo()
|
||||
}
|
||||
|
||||
|
|
|
@ -104,7 +104,7 @@ class GroupInfoFragment : SecureFragment<ChatRoomGroupInfoFragmentBinding>() {
|
|||
}
|
||||
})
|
||||
|
||||
addParticipantsFromBundle()
|
||||
addParticipantsFromSharedViewModel()
|
||||
|
||||
binding.setBackClickListener {
|
||||
findNavController().popBackStack()
|
||||
|
@ -128,13 +128,14 @@ class GroupInfoFragment : SecureFragment<ChatRoomGroupInfoFragmentBinding>() {
|
|||
binding.setParticipantsClickListener {
|
||||
sharedViewModel.createEncryptedChatRoom = viewModel.isEncrypted.value == true
|
||||
|
||||
val args = Bundle()
|
||||
args.putBoolean("createGroup", true)
|
||||
val list = arrayListOf<Address>()
|
||||
for (participant in viewModel.participants.value.orEmpty()) {
|
||||
list.add(participant.address)
|
||||
}
|
||||
args.putSerializable("participants", list)
|
||||
sharedViewModel.chatRoomParticipants.value = list
|
||||
|
||||
val args = Bundle()
|
||||
args.putBoolean("createGroup", true)
|
||||
navigateToChatRoomCreation(args)
|
||||
}
|
||||
|
||||
|
@ -161,9 +162,8 @@ class GroupInfoFragment : SecureFragment<ChatRoomGroupInfoFragmentBinding>() {
|
|||
})
|
||||
}
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
private fun addParticipantsFromBundle() {
|
||||
val participants = arguments?.getSerializable("participants") as? ArrayList<Address>
|
||||
private fun addParticipantsFromSharedViewModel() {
|
||||
val participants = sharedViewModel.chatRoomParticipants.value
|
||||
if (participants != null && participants.size > 0) {
|
||||
val list = arrayListOf<GroupChatRoomMember>()
|
||||
|
||||
|
|
|
@ -157,11 +157,13 @@ class MasterChatRoomsFragment : MasterFragment<ChatRoomMasterFragmentBinding, Ch
|
|||
}
|
||||
|
||||
binding.setNewOneToOneChatRoomClickListener {
|
||||
sharedViewModel.chatRoomParticipants.value = arrayListOf()
|
||||
navigateToChatRoomCreation(false)
|
||||
}
|
||||
|
||||
binding.setNewGroupChatRoomClickListener {
|
||||
sharedViewModel.selectedGroupChatRoom.value = null
|
||||
sharedViewModel.chatRoomParticipants.value = arrayListOf()
|
||||
navigateToChatRoomCreation(true)
|
||||
}
|
||||
|
||||
|
|
|
@ -50,6 +50,8 @@ class SharedMainViewModel : ViewModel() {
|
|||
|
||||
var createEncryptedChatRoom: Boolean = false
|
||||
|
||||
val chatRoomParticipants = MutableLiveData<ArrayList<Address>>()
|
||||
|
||||
/* Contacts */
|
||||
|
||||
val selectedContact = MutableLiveData<Contact>()
|
||||
|
|
Loading…
Reference in a new issue