summaryrefslogtreecommitdiff
path: root/android
diff options
context:
space:
mode:
authorBrad Leege <bleege@gmail.com>2015-02-25 17:01:13 -0600
committerBrad Leege <bleege@gmail.com>2015-02-25 17:01:13 -0600
commita4b6067d4f680c42e7ec033b41bc02c63d111e18 (patch)
tree0b1b86ab1e640019adba6f4c979e107b63c60aec /android
parent2bfafaddb1a824cbc7ec4315aac40995328cbd7c (diff)
downloadqtlocation-mapboxgl-a4b6067d4f680c42e7ec033b41bc02c63d111e18.tar.gz
#823 - Building cancel method. Refactoring request to not return OkHttp Request object to help keep FileSource self contained.
Diffstat (limited to 'android')
-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.java11
2 files changed, 16 insertions, 5 deletions
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
index f9b1417976..1081657b0b 100644
--- 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
@@ -1,5 +1,6 @@
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;
@@ -34,13 +35,13 @@ public class JavaFileSource {
* Make an HTTP Request
* @param resourceUrl URL to resource
* @param callback Callback class
- * @return Request created
*/
- public Request request(final String resourceUrl, final Callback callback) {
- Request request = new Request.Builder().url(resourceUrl).build();
-
+ 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);
+ }
- return request;
+ public void cancel(final String resourceUrl) {
+ client.cancel(resourceUrl.toLowerCase(MapboxConstants.MAPBOX_LOCALE));
}
}