mirror of
https://github.com/nextcloud/talk-android
synced 2025-07-14 08:15:04 +01:00
hardened view binding interaction
...in case of asynchronous UI interaction with already destroyed UI Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
parent
7b7eaa455d
commit
40a08394bc
@ -267,12 +267,18 @@ class ChatController(args: Bundle) :
|
|||||||
loadAvatarForStatusBar()
|
loadAvatarForStatusBar()
|
||||||
|
|
||||||
setTitle()
|
setTitle()
|
||||||
setupMentionAutocomplete()
|
try {
|
||||||
checkReadOnlyState()
|
setupMentionAutocomplete()
|
||||||
checkLobbyState()
|
checkReadOnlyState()
|
||||||
|
checkLobbyState()
|
||||||
|
|
||||||
if (!inConversation) {
|
if (!inConversation) {
|
||||||
joinRoomWithPassword()
|
joinRoomWithPassword()
|
||||||
|
}
|
||||||
|
} catch (npe: NullPointerException) {
|
||||||
|
// view binding can be null
|
||||||
|
// since this is called asynchrously and UI might have been destroyed in the meantime
|
||||||
|
Log.i(TAG, "UI destroyed - view binding already gone")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -559,7 +565,7 @@ class ChatController(args: Bundle) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun checkReadOnlyState() {
|
private fun checkReadOnlyState() {
|
||||||
if (currentConversation != null) {
|
if (currentConversation != null && isAlive()) {
|
||||||
if (currentConversation?.shouldShowLobby(conversationUser) ?: false ||
|
if (currentConversation?.shouldShowLobby(conversationUser) ?: false ||
|
||||||
currentConversation?.conversationReadOnlyState != null &&
|
currentConversation?.conversationReadOnlyState != null &&
|
||||||
currentConversation?.conversationReadOnlyState ==
|
currentConversation?.conversationReadOnlyState ==
|
||||||
@ -589,7 +595,10 @@ class ChatController(args: Bundle) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun checkLobbyState() {
|
private fun checkLobbyState() {
|
||||||
if (currentConversation != null && currentConversation?.isLobbyViewApplicable(conversationUser) ?: false) {
|
if (currentConversation != null &&
|
||||||
|
currentConversation?.isLobbyViewApplicable(conversationUser) ?: false &&
|
||||||
|
isAlive()
|
||||||
|
) {
|
||||||
|
|
||||||
if (!checkingLobbyStatus) {
|
if (!checkingLobbyStatus) {
|
||||||
getRoomInfo()
|
getRoomInfo()
|
||||||
@ -773,7 +782,7 @@ class ChatController(args: Bundle) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun setupMentionAutocomplete() {
|
private fun setupMentionAutocomplete() {
|
||||||
if (!isDestroyed && !isBeingDestroyed) {
|
if (isAlive()) {
|
||||||
val elevation = 6f
|
val elevation = 6f
|
||||||
resources?.let {
|
resources?.let {
|
||||||
val backgroundDrawable = ColorDrawable(it.getColor(R.color.bg_default))
|
val backgroundDrawable = ColorDrawable(it.getColor(R.color.bg_default))
|
||||||
@ -968,7 +977,14 @@ class ChatController(args: Bundle) :
|
|||||||
currentConversation?.sessionId
|
currentConversation?.sessionId
|
||||||
|
|
||||||
setupWebsocket()
|
setupWebsocket()
|
||||||
checkLobbyState()
|
|
||||||
|
try {
|
||||||
|
checkLobbyState()
|
||||||
|
} catch (npe: NullPointerException) {
|
||||||
|
// view binding can be null
|
||||||
|
// since this is called asynchrously and UI might have been destroyed in the meantime
|
||||||
|
Log.i(TAG, "UI destroyed - view binding already gone")
|
||||||
|
}
|
||||||
|
|
||||||
if (isFirstMessagesProcessing) {
|
if (isFirstMessagesProcessing) {
|
||||||
pullChatMessages(0)
|
pullChatMessages(0)
|
||||||
|
@ -101,6 +101,10 @@ abstract class NewBaseController(@LayoutRes var layoutRes: Int, args: Bundle? =
|
|||||||
cleanTempCertPreference()
|
cleanTempCertPreference()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun isAlive(): Boolean {
|
||||||
|
return !isDestroyed && !isBeingDestroyed
|
||||||
|
}
|
||||||
|
|
||||||
override fun onCreateView(
|
override fun onCreateView(
|
||||||
inflater: LayoutInflater,
|
inflater: LayoutInflater,
|
||||||
container: ViewGroup,
|
container: ViewGroup,
|
||||||
|
Loading…
Reference in New Issue
Block a user