Skip to content

Commit b7d293c

Browse files
authored
Merge pull request #1402 from square/tomm/fix-SQCRASH-1582
Fix PhoneWindow.superDispatchTouchEvent NullPointerException
2 parents a4dae10 + 2d671fb commit b7d293c

File tree

1 file changed

+9
-7
lines changed
  • workflow-ui/core-android/src/main/java/com/squareup/workflow1/ui/navigation

1 file changed

+9
-7
lines changed

workflow-ui/core-android/src/main/java/com/squareup/workflow1/ui/navigation/DialogSession.kt

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,15 @@ internal class DialogSession(
3838
val was = field
3939
field = value
4040
holder.dialog.window?.takeIf { value != was }?.let { window ->
41-
// https://stackoverflow.com/questions/2886407/dealing-with-rapid-tapping-on-buttons
42-
// If any motion events were enqueued on the main thread, cancel them.
43-
dispatchCancelEvent { window.superDispatchTouchEvent(it) }
44-
// When we cancel, have to warn things like RecyclerView that handle streams
45-
// of motion events and eventually dispatch input events (click, key pressed, etc.)
46-
// based on them.
47-
window.peekDecorView()?.cancelPendingInputEvents()
41+
window.peekDecorView()?.let { decorView ->
42+
// https://stackoverflow.com/questions/2886407/dealing-with-rapid-tapping-on-buttons
43+
// If any motion events were enqueued on the main thread, cancel them.
44+
dispatchCancelEvent { window.superDispatchTouchEvent(it) }
45+
// When we cancel, have to warn things like RecyclerView that handle streams
46+
// of motion events and eventually dispatch input events (click, key pressed, etc.)
47+
// based on them.
48+
decorView.cancelPendingInputEvents()
49+
}
4850
}
4951
}
5052

0 commit comments

Comments
 (0)