Change theme
Help
Press space for more information.
Show links for this issue (Shortcut: i, l)
Copy issue ID
Previous Issue (Shortcut: k)
Next Issue (Shortcut: j)
Sign in to use full features.
Vote: I am impacted
Notification menu
Refresh (Shortcut: Shift+r)
Go home (Shortcut: u)
Pending code changes (auto-populated)
View issue level access limits(Press Alt + Right arrow for more information)
Attachment actions
Unintended behavior
View staffing
Description
Version used: 1.2.0
Devices/Android versions reproduced on: Pixel 6 Pro, Samsung S10, etc...
Problem is sometimes an ANR is produced, see tombstone attached.
To reproduce:
Using a custom onBackPressCallback:
val onBackPressedCallback = object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() {
lifecycleScope.launch {
withContext(Dispatchers.Main) {
viewModel.closeSlidingPaneEvent.value = Event(true)
}
}
}
}
In my fragment I observe the event:
viewModel.closeSlidingPaneEvent.observe(
viewLifecycleOwner
) {
it.consume {
binding.slidingPane.closePane()
}
}
Event class is as such:
open class Event<out T>(private val content: T) {
private val handled = AtomicBoolean(false)
fun consume(handleContent: (T) -> Unit) {
if (!handled.get()) {
handled.set(true)
handleContent(content)
}
}
}