diff options
author | Brad Leege <bleege@gmail.com> | 2015-02-25 17:01:13 -0600 |
---|---|---|
committer | Brad Leege <bleege@gmail.com> | 2015-02-25 17:01:13 -0600 |
commit | a4b6067d4f680c42e7ec033b41bc02c63d111e18 (patch) | |
tree | 0b1b86ab1e640019adba6f4c979e107b63c60aec /android | |
parent | 2bfafaddb1a824cbc7ec4315aac40995328cbd7c (diff) | |
download | qtlocation-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')
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)); } } |