Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DialogSession crashes if peekDecorView() is null #914

Open
rjrjr opened this issue Jan 30, 2023 · 0 comments
Open

DialogSession crashes if peekDecorView() is null #914

rjrjr opened this issue Jan 30, 2023 · 0 comments

Comments

@rjrjr
Copy link
Contributor

rjrjr commented Jan 30, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant