Implement setGestureInProgress on Android
This commit is contained in:
@@ -581,6 +581,13 @@ void JNICALL nativeCancelTransitions(JNIEnv *env, jobject obj, jlong nativeMapVi
|
||||
nativeMapView->getMap().cancelTransitions();
|
||||
}
|
||||
|
||||
void JNICALL nativeSetGestureInProgress(JNIEnv *env, jobject obj, jlong nativeMapViewPtr, jboolean inProgress) {
|
||||
mbgl::Log::Debug(mbgl::Event::JNI, "nativeSetGestureInProgress");
|
||||
assert(nativeMapViewPtr != 0);
|
||||
NativeMapView *nativeMapView = reinterpret_cast<NativeMapView *>(nativeMapViewPtr);
|
||||
nativeMapView->getMap().setGestureInProgress(inProgress);
|
||||
}
|
||||
|
||||
void JNICALL nativeMoveBy(JNIEnv *env, jobject obj, jlong nativeMapViewPtr, jdouble dx, jdouble dy,
|
||||
jlong duration) {
|
||||
mbgl::Log::Debug(mbgl::Event::JNI, "nativeMoveBy");
|
||||
@@ -1549,6 +1556,7 @@ extern "C" JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
|
||||
{"nativeGetAccessToken", "(J)Ljava/lang/String;",
|
||||
reinterpret_cast<void *>(&nativeGetAccessToken)},
|
||||
{"nativeCancelTransitions", "(J)V", reinterpret_cast<void *>(&nativeCancelTransitions)},
|
||||
{"nativeSetGestureInProgress", "(JZ)V", reinterpret_cast<void *>(&nativeSetGestureInProgress)},
|
||||
{"nativeMoveBy", "(JDDJ)V", reinterpret_cast<void *>(&nativeMoveBy)},
|
||||
{"nativeSetLatLng", "(JLcom/mapbox/mapboxgl/geometry/LatLng;J)V",
|
||||
reinterpret_cast<void *>(&nativeSetLatLng)},
|
||||
|
||||
@@ -793,6 +793,7 @@ public class MapView extends FrameLayout implements LocationListener {
|
||||
switch (event.getActionMasked()) {
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
// First pointer down
|
||||
mNativeMapView.setGestureInProgress(true);
|
||||
break;
|
||||
|
||||
case MotionEvent.ACTION_POINTER_DOWN:
|
||||
@@ -809,6 +810,7 @@ public class MapView extends FrameLayout implements LocationListener {
|
||||
long tapInterval = event.getEventTime() - event.getDownTime();
|
||||
boolean isTap = tapInterval <= ViewConfiguration.getTapTimeout();
|
||||
boolean inProgress = mRotateGestureDetector.isInProgress() || mScaleGestureDetector.isInProgress();
|
||||
mNativeMapView.setGestureInProgress(false);
|
||||
|
||||
if (mTwoTap && isTap && !inProgress) {
|
||||
PointF focalPoint = TwoFingerGestureDetector.determineFocalPoint(event);
|
||||
@@ -822,6 +824,7 @@ public class MapView extends FrameLayout implements LocationListener {
|
||||
|
||||
case MotionEvent.ACTION_CANCEL:
|
||||
mTwoTap = false;
|
||||
mNativeMapView.setGestureInProgress(false);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -938,7 +941,6 @@ public class MapView extends FrameLayout implements LocationListener {
|
||||
}
|
||||
|
||||
mBeginTime = detector.getEventTime();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -208,6 +208,10 @@ class NativeMapView {
|
||||
nativeCancelTransitions(mNativeMapViewPtr);
|
||||
}
|
||||
|
||||
public void setGestureInProgress(boolean inProgress) {
|
||||
nativeSetGestureInProgress(mNativeMapViewPtr, inProgress);
|
||||
}
|
||||
|
||||
public void moveBy(double dx, double dy) {
|
||||
moveBy(dx, dy, 0);
|
||||
}
|
||||
@@ -498,6 +502,8 @@ class NativeMapView {
|
||||
|
||||
private native void nativeCancelTransitions(long nativeMapViewPtr);
|
||||
|
||||
private native void nativeSetGestureInProgress(long nativeMapViewPtr, boolean inProgress);
|
||||
|
||||
private native void nativeMoveBy(long nativeMapViewPtr, double dx,
|
||||
double dy, long duration);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user