summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobrun <tobrun.van.nuland@gmail.com>2018-01-17 15:54:49 +0100
committerTobrun <tobrun.van.nuland@gmail.com>2018-01-18 13:05:54 +0100
commit24745ff347834d80f8d8d6196001e23b1f67da0d (patch)
treeeb0110b4bc81a2ad49616088c013f3d3ca94534b
parent42bcb4b405a4bdc344c6c3d260cf4521e05943cc (diff)
downloadqtlocation-mapboxgl-upstream/tvn-expose-http-client.tar.gz
[android] - allow setting an OkHttpClientupstream/tvn-expose-http-client
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/http/HTTPRequest.java4
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/http/HttpRequestUtil.java13
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/DebugModeActivity.java4
3 files changed, 18 insertions, 3 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/http/HTTPRequest.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/http/HTTPRequest.java
index 945fb0ba47..da27ee7bb8 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/http/HTTPRequest.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/http/HTTPRequest.java
@@ -234,4 +234,8 @@ class HTTPRequest implements Callback {
static void enablePrintRequestUrlOnFailure(boolean enabled) {
logRequestUrl = enabled;
}
+
+ static void setOKHttpClient(OkHttpClient client) {
+ mClient = client;
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/http/HttpRequestUtil.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/http/HttpRequestUtil.java
index 5afe3b6572..872032867a 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/http/HttpRequestUtil.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/http/HttpRequestUtil.java
@@ -1,5 +1,7 @@
package com.mapbox.mapboxsdk.http;
+import okhttp3.OkHttpClient;
+
/**
* Utility class for setting HttpRequest configurations
*/
@@ -28,8 +30,17 @@ public class HttpRequestUtil {
*
* @param enabled True will print urls, false will disable
*/
- public static void setPrintRequestUrlOnFaillure(boolean enabled) {
+ public static void setPrintRequestUrlOnFailure(boolean enabled) {
HTTPRequest.enablePrintRequestUrlOnFailure(enabled);
}
+ /**
+ * Set the OkHttpClient used for requesting map resources.
+ *
+ * @param client the OkHttpClient
+ */
+ public static void setOkHttpClient(OkHttpClient client) {
+ HTTPRequest.setOKHttpClient(client);
+ }
+
} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/DebugModeActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/DebugModeActivity.java
index ab55834c4f..44d27a41ab 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/DebugModeActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/DebugModeActivity.java
@@ -55,7 +55,7 @@ public class DebugModeActivity extends AppCompatActivity implements OnMapReadyCa
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- HttpRequestUtil.setPrintRequestUrlOnFaillure(true);
+ HttpRequestUtil.setPrintRequestUrlOnFailure(true);
setContentView(R.layout.activity_debug_mode);
setupToolbar();
setupMapView(savedInstanceState);
@@ -206,7 +206,7 @@ public class DebugModeActivity extends AppCompatActivity implements OnMapReadyCa
protected void onDestroy() {
super.onDestroy();
mapView.onDestroy();
- HttpRequestUtil.setPrintRequestUrlOnFaillure(false);
+ HttpRequestUtil.setPrintRequestUrlOnFailure(false);
}
@Override