Fixed crashes
This commit is contained in:
parent
371d1c21ec
commit
13544e5d39
2 changed files with 19 additions and 6 deletions
|
@ -78,8 +78,10 @@ class DetailChatRoomFragment : MasterFragment<ChatRoomDetailFragmentBinding, Cha
|
|||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
if (_adapter != null) {
|
||||
adapter.unregisterAdapterDataObserver(observer)
|
||||
}
|
||||
binding.chatMessagesList.adapter = null
|
||||
adapter.unregisterAdapterDataObserver(observer)
|
||||
super.onDestroyView()
|
||||
}
|
||||
|
||||
|
@ -325,10 +327,14 @@ class DetailChatRoomFragment : MasterFragment<ChatRoomDetailFragmentBinding, Cha
|
|||
override fun onResume() {
|
||||
super.onResume()
|
||||
|
||||
// Prevent notifications for this chat room to be displayed
|
||||
val peerAddress = viewModel.chatRoom.peerAddress.asStringUriOnly()
|
||||
coreContext.notificationsManager.currentlyDisplayedChatRoomAddress = peerAddress
|
||||
coreContext.notificationsManager.cancelChatNotificationIdForSipUri(peerAddress)
|
||||
if (this::viewModel.isInitialized) {
|
||||
// Prevent notifications for this chat room to be displayed
|
||||
val peerAddress = viewModel.chatRoom.peerAddress.asStringUriOnly()
|
||||
coreContext.notificationsManager.currentlyDisplayedChatRoomAddress = peerAddress
|
||||
coreContext.notificationsManager.cancelChatNotificationIdForSipUri(peerAddress)
|
||||
} else {
|
||||
Log.e("[Chat Room] Fragment resuming but viewModel lateinit property isn't initialized!")
|
||||
}
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
|
|
|
@ -30,6 +30,7 @@ import org.linphone.LinphoneApplication
|
|||
import org.linphone.R
|
||||
import org.linphone.activities.main.viewmodels.DialogViewModel
|
||||
import org.linphone.activities.main.viewmodels.ListTopBarViewModel
|
||||
import org.linphone.core.tools.Log
|
||||
import org.linphone.utils.AppUtils
|
||||
import org.linphone.utils.DialogUtils
|
||||
import org.linphone.utils.SelectionListAdapter
|
||||
|
@ -40,7 +41,13 @@ import org.linphone.utils.SelectionListAdapter
|
|||
*/
|
||||
abstract class MasterFragment<T : ViewDataBinding, U : SelectionListAdapter<*, *>> : SecureFragment<T>() {
|
||||
protected var _adapter: U? = null
|
||||
protected val adapter get() = _adapter!!
|
||||
protected val adapter: U
|
||||
get() {
|
||||
if (_adapter == null) {
|
||||
Log.e("[Master Fragment] Attempting to get a null adapter!")
|
||||
}
|
||||
return _adapter!!
|
||||
}
|
||||
|
||||
protected lateinit var listSelectionViewModel: ListTopBarViewModel
|
||||
protected open val dialogConfirmationMessageBeforeRemoval: Int = R.plurals.dialog_default_delete
|
||||
|
|
Loading…
Reference in a new issue