diff options
author | Leith Bade <leith@mapbox.com> | 2015-08-13 13:36:41 +1000 |
---|---|---|
committer | Leith Bade <leith@mapbox.com> | 2015-08-13 13:36:41 +1000 |
commit | 5abb18a99cb5723f7b8ca21c5cb674d7214189dc (patch) | |
tree | b81c1a8027de81e20fec943b6e10b5c8a63a7d4f | |
parent | dbaac73e2c362203f6ce34ecafaa3ba4071eee13 (diff) | |
download | qtlocation-mapboxgl-5abb18a99cb5723f7b8ca21c5cb674d7214189dc.tar.gz |
Implement setGestureInProgress on Android
3 files changed, 17 insertions, 1 deletions
diff --git a/android/cpp/jni.cpp b/android/cpp/jni.cpp index f1e9072cbd..d1040d68e6 100644 --- a/android/cpp/jni.cpp +++ b/android/cpp/jni.cpp @@ -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)}, 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 ca0b2526f8..20e7dfe56a 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 @@ -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; } diff --git a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/NativeMapView.java b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/NativeMapView.java index 774c20a054..6257a23622 100644 --- a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/NativeMapView.java +++ b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/NativeMapView.java @@ -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); |