Repository navigation
plumb map notifications through JNI to Android - #2255
Conversation
|
You can easily test this with a patch such as the following: diff --git a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java
index b75aaba..9382bee 100644
--- a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java
+++ b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java
@@ -1829,6 +1829,9 @@ public class MapView extends FrameLayout implements LocationListener {
// Updates the UI to match the current map's position
private void updateMap(MapChange change) {
+
+ Log.d(TAG, "updateMap: " + Integer.toString(change.value));
+
// Using direct access to mIsCompassEnabled instead of isCompassEnabled() for
// small performance boost as this method is called rapidly.
if (mIsCompassEnabled) {Then see the following in the logs as you interact with the map: |
|
The switch is pretty much the accepted way to I think the idea with |
|
Also looking at Google Maps: https://developers.google.com/android/reference/com/google/android/gms/maps/GoogleMap They split each type of map update into separate listeners? Should we do the same? |
|
Ah, that's a nice reference link; better than the stuff I was finding. I'll tune this up to move the switch into the class itself. |
There was a problem hiding this comment.
This will definitely work, but if we don't need to maintain value for any particular reason it can definitely be safely removed.
private enum MapChange {
MapChangeNullChange,
MapChangeRegionWillChange,
MapChangeRegionWillChangeAnimated,
...
}
// Comparison works this way then
MapChange mcEvent;
switch (mcEvent) {
case MapChange.MapChangeNullChange:
break;
case MapChange.MapChangeRegionWillChange:
break;
case MapChange.MapChangeRegionWillChangeAnimated
break;
....
default:
// Shouldn't get here
}It can lead to a bit more verbose switch statements, but also safer ones as it doesn't require values to be copied and stored multiple places.
There was a problem hiding this comment.
if we don't need to maintain value for any particular reason it can definitely be safely removed.
I want to maintain equivalence to this enum on the native side.
eb4a2b3 to
472846e
Compare
472846e to
e78eace
Compare
Passes through
mbgl::MapChangenotification types into native Java.Two review issues:
enumright here — backing with anint value, but since unable to instantiate in the style of classes, using aswitchlater on to deduce the rawintpassed and map to theenumcase. This seems verbose and redundant (i.e. specifying the raw values-1to13two times).updateMap()in places, I added a Java-only caseMapChangeNullChange(-1)for these cases. However I'm confused why/if we need to notify at all in these cases since we're only modifying map properties such as tracking state, compass visibility, and the like and not actually modifying fetch/parse/render properties.Unblocks #894 (comment).
/cc @bleege @ljbade