workflow-kotlin icon indicating copy to clipboard operation
workflow-kotlin copied to clipboard

DialogSession crashes if peekDecorView() is null

Open rjrjr opened this issue 2 years ago • 0 comments
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.

rjrjr avatar Jan 30 '23 21:01 rjrjr