drive Android rendering from the main thread via invalidate() calls
This commit is contained in:
committed by
John Firebaugh
parent
84e2ea886d
commit
dca42018d2
@@ -26,6 +26,7 @@ import android.view.SurfaceView;
|
||||
import android.view.View;
|
||||
import android.view.ViewConfiguration;
|
||||
import android.widget.ZoomButtonsController;
|
||||
import android.util.Log;
|
||||
|
||||
import com.almeros.android.multitouch.gesturedetectors.RotateGestureDetector;
|
||||
import com.almeros.android.multitouch.gesturedetectors.TwoFingerGestureDetector;
|
||||
@@ -1168,6 +1169,18 @@ public class MapView extends SurfaceView {
|
||||
// Map events
|
||||
//
|
||||
|
||||
// Called when the map needs to be rerendered
|
||||
// Called via JNI from NativeMapView
|
||||
protected void onInvalidate() {
|
||||
post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mNativeMapView.invalidate();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public interface OnMapChangedListener {
|
||||
void onMapChanged();
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.mapbox.mapboxgl.views;
|
||||
|
||||
import android.graphics.PointF;
|
||||
import android.view.Surface;
|
||||
import android.util.Log;
|
||||
|
||||
import com.mapbox.mapboxgl.geometry.LatLng;
|
||||
import com.mapbox.mapboxgl.geometry.LatLngZoom;
|
||||
@@ -85,6 +86,10 @@ class NativeMapView {
|
||||
nativeUpdate(mNativeMapViewPtr);
|
||||
}
|
||||
|
||||
public void invalidate() {
|
||||
nativeOnInvalidate(mNativeMapViewPtr);
|
||||
}
|
||||
|
||||
public void resize(int width, int height, float ratio, int fbWidth,
|
||||
int fbHeight) {
|
||||
if (width < 0) {
|
||||
@@ -342,6 +347,10 @@ class NativeMapView {
|
||||
// Callbacks
|
||||
//
|
||||
|
||||
protected void onInvalidate() {
|
||||
mMapView.onInvalidate();
|
||||
}
|
||||
|
||||
protected void onMapChanged() {
|
||||
mMapView.onMapChanged();
|
||||
}
|
||||
@@ -384,6 +393,8 @@ class NativeMapView {
|
||||
|
||||
private native void nativeUpdate(long nativeMapViewPtr);
|
||||
|
||||
private native void nativeOnInvalidate(long nativeMapViewPtr);
|
||||
|
||||
private native void nativeResize(long nativeMapViewPtr, int width,
|
||||
int height, float ratio, int fbWidth, int fbHeight);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user