-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Conversation
b2298c8
to
3847550
Compare
Code has been re-factored (initial implementation was made for backporting that behaviour). |
3847550
to
29cda9c
Compare
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.
Really smart solution, well thought out 👍
Ni details
private boolean isClickHandledForMarker(long markerId) { | ||
boolean handledDefaultClick; | ||
Marker marker = (Marker) getAnnotation(markerId); | ||
if (marker instanceof MarkerView) { |
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.
If we continue evolving AnnotationManager
keeping both Marker
s and MarkerView
s, we should think about implementing an Strategy pattern around Marker
and MarkerView
.
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.
good idea, would love to get in #6912 first as this will changes the whole setup around annotations (this makes 50% of our current java code around annotations obsolete) and would like to avoid doing twice the work.
this.projection = projection; | ||
} | ||
|
||
public long execute(MarkerHit markerHit) { |
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.
We should strive to keeppublic
methods as clean as possible so they read like pseudocode (no conditionals, for
s, etc.). What about extracting some private
methods to make it simpler?
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.
Replaced with
public long execute(MarkerHit markerHit) {
resolveForMarkers(markerHit);
return closestMarkerId;
}
private void resolveForMarkers(MarkerHit markerHit){
for (Marker marker : markerHit.markers) {
if (marker instanceof MarkerView) {
resolveForMarkerView(markerHit, (MarkerView) marker);
} else {
resolveForMarker(markerHit, marker);
}
}
}
bitmap = marker.getIcon().getBitmap(); | ||
hitRectMarker.set(0, 0, bitmap.getWidth(), bitmap.getHeight()); | ||
hitRectMarker.offsetTo( | ||
markerLocation.x - bitmap.getWidth() / 2, |
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.
What about extracting these expressions into explaining variables? E.g. averageXXX
29cda9c
to
aaa5518
Compare
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.
* [android] - hit test Marker and MarkerViews * fixup
* [android] - hit test Marker and MarkerViews * fixup
WIP, Closes #8159.
This PR adds hit testing to Markers and MarkerViews, we first query the map for nearby markers and on that result we perform rectangular hit testing. If we hit multiple annotation (eg. overlapping), we will make an intersection between the touch target and the bounds of the annotation to determine which annotation should be selected. This PR requires some re factoring before merging.