mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-02-16 20:10:04 +03:00
Merge pull request #4366 from vector-im/feature/adm/emoji-rotation-crash
Fixing timeline crash when rotating emoji picker
This commit is contained in:
commit
d36f01242a
2 changed files with 18 additions and 6 deletions
1
changelog.d/4365.bugfix
Normal file
1
changelog.d/4365.bugfix
Normal file
|
@ -0,0 +1 @@
|
|||
Fixing timeline crash when rotating with the emoji window open
|
|
@ -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…
Add table
Reference in a new issue