workflow-kotlin
workflow-kotlin copied to clipboard
DialogSession crashes if peekDecorView() is null
trafficstars
The call to superDispatchTouchEvent here crashes with an NPE if there is no decorView yet:
holder.dialog.window?.takeIf { value != was }?.let { window ->
// https://stackoverflow.com/questions/2886407/dealing-with-rapid-tapping-on-buttons
// If any motion events were enqueued on the main thread, cancel them.
dispatchCancelEvent { window.superDispatchTouchEvent(it) }
// When we cancel, have to warn things like RecyclerView that handle streams
// of motion events and eventually dispatch input events (click, key pressed, etc.)
// based on them.
window.peekDecorView()?.cancelPendingInputEvents()
}
Obvious fix is obvious. In the meantime, workaround is for a Dialog creator to call window?.decorView before returning it.