-
-
Notifications
You must be signed in to change notification settings - Fork 847
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
fix(android): requestDisallowInterceptTouchEvent broken #3333
Conversation
@@ -327,7 +327,9 @@ open class RNMBXMapViewManager(context: ReactApplicationContext, val viewTagReso | |||
|
|||
@ReactProp(name = "requestDisallowInterceptTouchEvent") | |||
override fun setRequestDisallowInterceptTouchEvent(mapView: RNMBXMapView, requestDisallowInterceptTouchEvent: Dynamic) { | |||
mapView.requestDisallowInterceptTouchEvent = requestDisallowInterceptTouchEvent.asBoolean() | |||
mapView.withMapView { | |||
it.requestDisallowInterceptTouchEvent = requestDisallowInterceptTouchEvent.asBoolean() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it.requestDisallowInterceptTouchEvent = requestDisallowInterceptTouchEvent.asBoolean() | |
it.requestDisallowInterceptTouchEvent = mapView.requestDisallowInterceptTouchEvent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would that not just be x = x
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variable naming is a bit confusing there. ‘it’ is mapbox’s MapView, mapView is RNMBXMapView
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My bad, I have to admit, that I tried to fix this issue while being on the go. I've now correctly set up the development environment and my new commit seems to be the best solution for me.
@ReactProp(name = "requestDisallowInterceptTouchEvent")
override fun setRequestDisallowInterceptTouchEvent(mapView: RNMBXMapView, requestDisallowInterceptTouchEvent: Dynamic) {
mapView.requestDisallowInterceptTouchEvent = requestDisallowInterceptTouchEvent.asBoolean()
}
Calls
var requestDisallowInterceptTouchEvent: Boolean = false
set(value) {
val oldValue = field
field = value
updateRequestDisallowInterceptTouchEvent(oldValue, value)
}
Which calls
fun RNMBXMapView.updateRequestDisallowInterceptTouchEvent(oldValue: Boolean, value: Boolean) {
if (oldValue == value) {
return
}
if (value) {
mapView.setOnTouchListener { view, event ->
this.requestDisallowInterceptTouchEvent(true)
mapView.onTouchEvent(event)
true
}
} else {
mapView.setOnTouchListener { view, event ->
mapView.onTouchEvent(event)
}
}
}
The issue arises, because mapView
is not initialized then mapView.setOnTouchListener
is first called. By wrapping it with withMapView
, this should be fixed.
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good
Description
Fixes #3326 by waiting until mMapView has been initialized.