summaryrefslogtreecommitdiff
path: root/android
diff options
context:
space:
mode:
authorLeith Bade <leith@mapbox.com>2015-02-25 15:30:17 -0800
committerLeith Bade <leith@mapbox.com>2015-02-25 15:30:17 -0800
commitecd7267fdf962c4669bfe38c138ca25d5c619357 (patch)
tree6b0bd4b6a916453a0bef075135aa3c1ee19ddf47 /android
parent74e953cc48ad7213c25d2e658c576724b5f694af (diff)
parent380fd1fbf4c8d148bb231a99007498713a07829f (diff)
downloadqtlocation-mapboxgl-ecd7267fdf962c4669bfe38c138ca25d5c619357.tar.gz
Merge branch 'master' of github.com:mapbox/mapbox-gl-native into android-conversions
Diffstat (limited to 'android')
-rw-r--r--android/java/MapboxGLAndroidSDK/build.gradle1
-rw-r--r--android/java/MapboxGLAndroidSDK/src/main/java/com/almeros/android/multitouch/BaseGestureDetector.java62
-rw-r--r--android/java/MapboxGLAndroidSDK/src/main/java/com/almeros/android/multitouch/TwoFingerGestureDetector.java68
-rw-r--r--android/java/MapboxGLAndroidSDK/src/main/java/com/almeros/android/multitouch/gesturedetectors/BaseGestureDetector.java32
-rw-r--r--android/java/MapboxGLAndroidSDK/src/main/java/com/almeros/android/multitouch/gesturedetectors/TwoFingerGestureDetector.java38
-rw-r--r--android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/lib/constants/MapboxConstants.java10
-rw-r--r--android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/lib/util/JavaFileSource.java51
-rw-r--r--android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java3
8 files changed, 164 insertions, 101 deletions
diff --git a/android/java/MapboxGLAndroidSDK/build.gradle b/android/java/MapboxGLAndroidSDK/build.gradle
index 7209b6d1ec..40287c9536 100644
--- a/android/java/MapboxGLAndroidSDK/build.gradle
+++ b/android/java/MapboxGLAndroidSDK/build.gradle
@@ -31,6 +31,7 @@ dependencies {
compile 'commons-validator:commons-validator:1.4.1'
compile 'com.android.support:support-annotations:21.0.3'
compile 'com.android.support:support-v4:21.0.3'
+ compile 'com.squareup.okhttp:okhttp:2.2.0'
}
android {
diff --git a/android/java/MapboxGLAndroidSDK/src/main/java/com/almeros/android/multitouch/BaseGestureDetector.java b/android/java/MapboxGLAndroidSDK/src/main/java/com/almeros/android/multitouch/BaseGestureDetector.java
index dafac2a1ab..8c0c544983 100644
--- a/android/java/MapboxGLAndroidSDK/src/main/java/com/almeros/android/multitouch/BaseGestureDetector.java
+++ b/android/java/MapboxGLAndroidSDK/src/main/java/com/almeros/android/multitouch/BaseGestureDetector.java
@@ -12,15 +12,15 @@ import android.view.MotionEvent;
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer
+ * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the distribution.
*
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
- * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*/
public abstract class BaseGestureDetector {
@@ -29,12 +29,12 @@ public abstract class BaseGestureDetector {
protected MotionEvent mPrevEvent;
protected MotionEvent mCurrEvent;
-
+
protected float mCurrPressure;
protected float mPrevPressure;
protected long mTimeDelta;
-
-
+
+
/**
* This value is the threshold ratio between the previous combined pressure
* and the current combined pressure. When pressure decreases rapidly
@@ -44,19 +44,19 @@ public abstract class BaseGestureDetector {
*/
protected static final float PRESSURE_THRESHOLD = 0.67f;
-
+
public BaseGestureDetector(Context context) {
- mContext = context;
+ mContext = context;
}
-
+
/**
* All gesture detectors need to be called through this method to be able to
* detect gestures. This method delegates work to handler methods
* (handleStartProgressEvent, handleInProgressEvent) implemented in
* extending classes.
- *
- * @param event
- * @return
+ *
+ * @param event MotionEvent
+ * @return true
*/
public boolean onTouchEvent(MotionEvent event){
final int actionCode = event.getAction() & MotionEvent.ACTION_MASK;
@@ -67,37 +67,37 @@ public abstract class BaseGestureDetector {
}
return true;
}
-
+
/**
* Called when the current event occurred when NO gesture is in progress
* yet. The handling in this implementation may set the gesture in progress
* (via mGestureInProgress) or out of progress
- * @param actionCode
- * @param event
+ * @param actionCode Action Code from MotionEvent
+ * @param event MotionEvent
*/
protected abstract void handleStartProgressEvent(int actionCode, MotionEvent event);
-
+
/**
* Called when the current event occurred when a gesture IS in progress. The
* handling in this implementation may set the gesture out of progress (via
* mGestureInProgress).
- * @param actionCode
- * @param event
+ * @param actionCode Action Code from MotionEvent
+ * @param event MotionEvent
*/
protected abstract void handleInProgressEvent(int actionCode, MotionEvent event);
-
-
+
+
protected void updateStateByEvent(MotionEvent curr){
final MotionEvent prev = mPrevEvent;
-
+
// Reset mCurrEvent
if (mCurrEvent != null) {
mCurrEvent.recycle();
mCurrEvent = null;
}
mCurrEvent = MotionEvent.obtain(curr);
-
-
+
+
// Delta time
mTimeDelta = curr.getEventTime() - prev.getEventTime();
@@ -105,7 +105,7 @@ public abstract class BaseGestureDetector {
mCurrPressure = curr.getPressure(curr.getActionIndex());
mPrevPressure = prev.getPressure(prev.getActionIndex());
}
-
+
protected void resetState() {
if (mPrevEvent != null) {
mPrevEvent.recycle();
@@ -130,7 +130,7 @@ public abstract class BaseGestureDetector {
/**
* Return the time difference in milliseconds between the previous accepted
* GestureDetector event and the current GestureDetector event.
- *
+ *
* @return Time difference since the last move event in milliseconds.
*/
public long getTimeDelta() {
@@ -140,11 +140,11 @@ public abstract class BaseGestureDetector {
/**
* Return the event time of the current GestureDetector event being
* processed.
- *
+ *
* @return Current GestureDetector event time in milliseconds.
*/
public long getEventTime() {
return mCurrEvent.getEventTime();
}
-
+
}
diff --git a/android/java/MapboxGLAndroidSDK/src/main/java/com/almeros/android/multitouch/TwoFingerGestureDetector.java b/android/java/MapboxGLAndroidSDK/src/main/java/com/almeros/android/multitouch/TwoFingerGestureDetector.java
index 57e4e21d2d..6c6a0e4bfa 100644
--- a/android/java/MapboxGLAndroidSDK/src/main/java/com/almeros/android/multitouch/TwoFingerGestureDetector.java
+++ b/android/java/MapboxGLAndroidSDK/src/main/java/com/almeros/android/multitouch/TwoFingerGestureDetector.java
@@ -14,15 +14,15 @@ import android.view.ViewConfiguration;
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer
+ * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the distribution.
*
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
- * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*/
public abstract class TwoFingerGestureDetector extends BaseGestureDetector {
@@ -30,33 +30,33 @@ public abstract class TwoFingerGestureDetector extends BaseGestureDetector {
private final float mEdgeSlop;
private float mRightSlopEdge;
private float mBottomSlopEdge;
-
+
protected float mPrevFingerDiffX;
protected float mPrevFingerDiffY;
protected float mCurrFingerDiffX;
protected float mCurrFingerDiffY;
-
+
private float mCurrLen;
private float mPrevLen;
-
+
public TwoFingerGestureDetector(Context context) {
super(context);
-
+
ViewConfiguration config = ViewConfiguration.get(context);
- mEdgeSlop = config.getScaledEdgeSlop();
+ mEdgeSlop = config.getScaledEdgeSlop();
}
-
+
@Override
protected abstract void handleStartProgressEvent(int actionCode, MotionEvent event);
@Override
protected abstract void handleInProgressEvent(int actionCode, MotionEvent event);
-
+
protected void updateStateByEvent(MotionEvent curr){
super.updateStateByEvent(curr);
-
+
final MotionEvent prev = mPrevEvent;
-
+
mCurrLen = -1;
mPrevLen = -1;
@@ -69,7 +69,7 @@ public abstract class TwoFingerGestureDetector extends BaseGestureDetector {
final float pvy = py1 - py0;
mPrevFingerDiffX = pvx;
mPrevFingerDiffY = pvy;
-
+
// Current
final float cx0 = curr.getX(0);
final float cy0 = curr.getY(0);
@@ -80,11 +80,11 @@ public abstract class TwoFingerGestureDetector extends BaseGestureDetector {
mCurrFingerDiffX = cvx;
mCurrFingerDiffY = cvy;
}
-
+
/**
* Return the current distance between the two pointers forming the
* gesture in progress.
- *
+ *
* @return Distance between pointers in pixels.
*/
public float getCurrentSpan() {
@@ -99,7 +99,7 @@ public abstract class TwoFingerGestureDetector extends BaseGestureDetector {
/**
* Return the previous distance between the two pointers forming the
* gesture in progress.
- *
+ *
* @return Previous distance between pointers in pixels.
*/
public float getPreviousSpan() {
@@ -110,52 +110,52 @@ public abstract class TwoFingerGestureDetector extends BaseGestureDetector {
}
return mPrevLen;
}
-
+
/**
- * MotionEvent has no getRawX(int) method; simulate it pending future API approval.
+ * MotionEvent has no getRawX(int) method; simulate it pending future API approval.
* @param event
* @param pointerIndex
- * @return
+ * @return Raw X value or 0
*/
protected static float getRawX(MotionEvent event, int pointerIndex) {
float offset = event.getX() - event.getRawX();
if(pointerIndex < event.getPointerCount()){
return event.getX(pointerIndex) + offset;
- }
+ }
return 0f;
}
/**
- * MotionEvent has no getRawY(int) method; simulate it pending future API approval.
+ * MotionEvent has no getRawY(int) method; simulate it pending future API approval.
* @param event
* @param pointerIndex
- * @return
+ * @return Raw Y value or 0
*/
protected static float getRawY(MotionEvent event, int pointerIndex) {
float offset = event.getY() - event.getRawY();
if(pointerIndex < event.getPointerCount()){
return event.getY(pointerIndex) + offset;
- }
+ }
return 0f;
}
/**
* Check if we have a sloppy gesture. Sloppy gestures can happen if the edge
* of the user's hand is touching the screen, for example.
- *
- * @param event
- * @return
+ *
+ * @param event MotionEvent
+ * @return {@code true} if is a sloppy gesture, {@code false} if not
*/
protected boolean isSloppyGesture(MotionEvent event){
// As orientation can change, query the metrics in touch down
DisplayMetrics metrics = mContext.getResources().getDisplayMetrics();
mRightSlopEdge = metrics.widthPixels - mEdgeSlop;
mBottomSlopEdge = metrics.heightPixels - mEdgeSlop;
-
+
final float edgeSlop = mEdgeSlop;
final float rightSlop = mRightSlopEdge;
final float bottomSlop = mBottomSlopEdge;
-
+
final float x0 = event.getRawX();
final float y0 = event.getRawY();
final float x1 = getRawX(event, 1);
@@ -172,8 +172,8 @@ public abstract class TwoFingerGestureDetector extends BaseGestureDetector {
return true;
} else if (p1sloppy) {
return true;
- }
+ }
return false;
- }
+ }
}
diff --git a/android/java/MapboxGLAndroidSDK/src/main/java/com/almeros/android/multitouch/gesturedetectors/BaseGestureDetector.java b/android/java/MapboxGLAndroidSDK/src/main/java/com/almeros/android/multitouch/gesturedetectors/BaseGestureDetector.java
index 720a1f541b..622e8f759c 100644
--- a/android/java/MapboxGLAndroidSDK/src/main/java/com/almeros/android/multitouch/gesturedetectors/BaseGestureDetector.java
+++ b/android/java/MapboxGLAndroidSDK/src/main/java/com/almeros/android/multitouch/gesturedetectors/BaseGestureDetector.java
@@ -6,19 +6,19 @@ import android.view.MotionEvent;
/**
* @author Almer Thie (code.almeros.com) Copyright (c) 2013, Almer Thie
* (code.almeros.com)
- *
+ *
* All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
- *
+ *
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
@@ -61,9 +61,9 @@ public abstract class BaseGestureDetector {
* detect gestures. This method delegates work to handler methods
* (handleStartProgressEvent, handleInProgressEvent) implemented in
* extending classes.
- *
- * @param event
- * @return
+ *
+ * @param event MotionEvent
+ * @return {@code true} as handled
*/
public boolean onTouchEvent(MotionEvent event) {
final int actionCode = event.getAction() & MotionEvent.ACTION_MASK;
@@ -79,9 +79,9 @@ public abstract class BaseGestureDetector {
* Called when the current event occurred when NO gesture is in progress
* yet. The handling in this implementation may set the gesture in progress
* (via mGestureInProgress) or out of progress
- *
- * @param actionCode
- * @param event
+ *
+ * @param actionCode Action Code from MotionEvent
+ * @param event MotionEvent
*/
protected abstract void handleStartProgressEvent(int actionCode,
MotionEvent event);
@@ -90,10 +90,10 @@ public abstract class BaseGestureDetector {
* Called when the current event occurred when a gesture IS in progress. The
* handling in this implementation may set the gesture out of progress (via
* mGestureInProgress).
- *
*
- * @param actionCode
- * @param event
+ *
+ * @param actionCode Action Code from MotionEvent
+ * @param event MotionEvent
*/
protected abstract void handleInProgressEvent(int actionCode,
MotionEvent event);
@@ -130,7 +130,7 @@ public abstract class BaseGestureDetector {
/**
* Returns {@code true} if a gesture is currently in progress.
- *
+ *
* @return {@code true} if a gesture is currently in progress, {@code false}
* otherwise.
*/
@@ -141,7 +141,7 @@ public abstract class BaseGestureDetector {
/**
* Return the time difference in milliseconds between the previous accepted
* GestureDetector event and the current GestureDetector event.
- *
+ *
* @return Time difference since the last move event in milliseconds.
*/
public long getTimeDelta() {
@@ -151,7 +151,7 @@ public abstract class BaseGestureDetector {
/**
* Return the event time of the current GestureDetector event being
* processed.
- *
+ *
* @return Current GestureDetector event time in milliseconds.
*/
public long getEventTime() {
diff --git a/android/java/MapboxGLAndroidSDK/src/main/java/com/almeros/android/multitouch/gesturedetectors/TwoFingerGestureDetector.java b/android/java/MapboxGLAndroidSDK/src/main/java/com/almeros/android/multitouch/gesturedetectors/TwoFingerGestureDetector.java
index e26d6b5ae4..91e5ef13c8 100644
--- a/android/java/MapboxGLAndroidSDK/src/main/java/com/almeros/android/multitouch/gesturedetectors/TwoFingerGestureDetector.java
+++ b/android/java/MapboxGLAndroidSDK/src/main/java/com/almeros/android/multitouch/gesturedetectors/TwoFingerGestureDetector.java
@@ -9,19 +9,19 @@ import android.view.ViewConfiguration;
/**
* @author Almer Thie (code.almeros.com) Copyright (c) 2013, Almer Thie
* (code.almeros.com)
- *
+ *
* All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
- *
+ *
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
@@ -97,7 +97,7 @@ public abstract class TwoFingerGestureDetector extends BaseGestureDetector {
/**
* Return the current distance between the two pointers forming the gesture
* in progress.
- *
+ *
* @return Distance between pointers in pixels.
*/
public float getCurrentSpan() {
@@ -112,7 +112,7 @@ public abstract class TwoFingerGestureDetector extends BaseGestureDetector {
/**
* Return the previous distance between the two pointers forming the gesture
* in progress.
- *
+ *
* @return Previous distance between pointers in pixels.
*/
public float getPreviousSpan() {
@@ -127,10 +127,10 @@ public abstract class TwoFingerGestureDetector extends BaseGestureDetector {
/**
* MotionEvent has no getRawX(int) method; simulate it pending future API
* approval.
- *
- * @param event
- * @param pointerIndex
- * @return
+ *
+ * @param event Motion Event
+ * @param pointerIndex Pointer Index
+ * @return Raw x value or 0
*/
protected static float getRawX(MotionEvent event, int pointerIndex) {
float offset = event.getX() - event.getRawX();
@@ -143,10 +143,10 @@ public abstract class TwoFingerGestureDetector extends BaseGestureDetector {
/**
* MotionEvent has no getRawY(int) method; simulate it pending future API
* approval.
- *
- * @param event
- * @param pointerIndex
- * @return
+ *
+ * @param event Motion Event
+ * @param pointerIndex Pointer Index
+ * @return Raw y value or 0
*/
protected static float getRawY(MotionEvent event, int pointerIndex) {
float offset = event.getY() - event.getRawY();
@@ -159,9 +159,9 @@ public abstract class TwoFingerGestureDetector extends BaseGestureDetector {
/**
* Check if we have a sloppy gesture. Sloppy gestures can happen if the edge
* of the user's hand is touching the screen, for example.
- *
- * @param event
- * @return
+ *
+ * @param event Motion Event
+ * @return {@code true} if is sloppy gesture, {@code false} if not
*/
protected boolean isSloppyGesture(MotionEvent event) {
// As orientation can change, query the metrics in touch down
@@ -194,8 +194,8 @@ public abstract class TwoFingerGestureDetector extends BaseGestureDetector {
/**
* Determine (multi)finger focal point (a.k.a. center point between all
* fingers)
- *
- * @param e
+ *
+ * @param e Motion Event
* @return PointF focal point
*/
public static PointF determineFocalPoint(MotionEvent e) {
diff --git a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/lib/constants/MapboxConstants.java b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/lib/constants/MapboxConstants.java
new file mode 100644
index 0000000000..4816dbf4d7
--- /dev/null
+++ b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/lib/constants/MapboxConstants.java
@@ -0,0 +1,10 @@
+package com.mapbox.mapboxgl.lib.constants;
+
+import java.util.Locale;
+
+public class MapboxConstants {
+
+ // Default Locale for data processing (ex: String.toLowerCase(MAPBOX_LOCALE, "foo"))
+ public static final Locale MAPBOX_LOCALE = Locale.US;
+
+}
diff --git a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/lib/util/JavaFileSource.java b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/lib/util/JavaFileSource.java
new file mode 100644
index 0000000000..40e7964eb7
--- /dev/null
+++ b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/lib/util/JavaFileSource.java
@@ -0,0 +1,51 @@
+package com.mapbox.mapboxgl.lib.util;
+
+import com.mapbox.mapboxgl.lib.constants.MapboxConstants;
+import com.squareup.okhttp.Callback;
+import com.squareup.okhttp.OkHttpClient;
+import com.squareup.okhttp.Request;
+
+public class JavaFileSource {
+
+ private static JavaFileSource instance = null;
+
+ // Single reference to OkHttp for performance gains
+ private OkHttpClient client;
+
+ /**
+ * Private Constructor to support Singleton pattern
+ */
+ private JavaFileSource() {
+ super();
+ client = new OkHttpClient();
+ }
+
+ /**
+ * Get the singleton instance of JavaFileSource
+ * @return Reference to the Singleton Instance of JavaFileSource
+ */
+ public static JavaFileSource getInstance() {
+ if (instance == null) {
+ instance = new JavaFileSource();
+ }
+ return instance;
+ }
+
+ /**
+ * Make an HTTP Request
+ * @param resourceUrl URL to resource
+ * @param callback Callback class
+ */
+ public void request(final String resourceUrl, final Callback callback) {
+ Request request = new Request.Builder().url(resourceUrl).tag(resourceUrl.toLowerCase(MapboxConstants.MAPBOX_LOCALE)).build();
+ client.newCall(request).enqueue(callback);
+ }
+
+ /**
+ * Attempt to cancel HTTP Request made
+ * @param resourceUrl URL of request to cancel
+ */
+ public void cancel(final String resourceUrl) {
+ client.cancel(resourceUrl.toLowerCase(MapboxConstants.MAPBOX_LOCALE));
+ }
+}
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 5161f4c28d..dca9bff10d 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
@@ -10,6 +10,7 @@ import android.content.res.TypedArray;
import android.graphics.PointF;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
+import android.os.Build;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.view.GestureDetectorCompat;
@@ -173,7 +174,7 @@ public class MapView extends SurfaceView {
requestFocus();
// Register the SurfaceHolder callbacks
- if (android.os.Build.VERSION.SDK_INT >= 9) {
+ if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
getHolder().addCallback(new Callbacks2());
} else {
getHolder().addCallback(new Callbacks());