mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-01-24 00:01:23 +01:00
fixing timeline crash when rotating with the emoji window open
- guarding the emoji popup dismiss callback with a started lifecycle state - the emoji popup dismiss callback also triggers onViewDetachedFromWindow which does not always finish before onDestroyView
This commit is contained in:
parent
dd6ac46659
commit
e12d8c30d8
@ -52,6 +52,7 @@ import androidx.core.view.forEach
|
||||
import androidx.core.view.isInvisible
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.fragment.app.setFragmentResultListener
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.recyclerview.widget.ItemTouchHelper
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
@ -639,17 +640,27 @@ class RoomDetailFragment @Inject constructor(
|
||||
setImageResource(R.drawable.ic_keyboard)
|
||||
}
|
||||
}
|
||||
.setOnEmojiPopupDismissListener {
|
||||
if (isAdded) {
|
||||
views.composerLayout.views.composerEmojiButton.apply {
|
||||
contentDescription = getString(R.string.a11y_open_emoji_picker)
|
||||
setImageResource(R.drawable.ic_insert_emoji)
|
||||
}
|
||||
.setOnEmojiPopupDismissListenerLifecycleAware {
|
||||
views.composerLayout.views.composerEmojiButton.apply {
|
||||
contentDescription = getString(R.string.a11y_open_emoji_picker)
|
||||
setImageResource(R.drawable.ic_insert_emoji)
|
||||
}
|
||||
}
|
||||
.build(views.composerLayout.views.composerEditText)
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure dismiss actions only trigger when the fragment is in the started state
|
||||
* EmojiPopup by default dismisses onViewDetachedFromWindow, this can cause race conditions with onDestroyView
|
||||
*/
|
||||
private fun EmojiPopup.Builder.setOnEmojiPopupDismissListenerLifecycleAware(action: () -> Unit): EmojiPopup.Builder {
|
||||
return setOnEmojiPopupDismissListener {
|
||||
if (lifecycle.currentState == Lifecycle.State.STARTED) {
|
||||
action()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private val permissionVoiceMessageLauncher = registerForPermissionsResult { allGranted, deniedPermanently ->
|
||||
if (allGranted) {
|
||||
// In this case, let the user start again the gesture
|
||||
|
Loading…
Reference in New Issue
Block a user