summaryrefslogtreecommitdiff
path: root/android
diff options
context:
space:
mode:
Diffstat (limited to 'android')
-rw-r--r--android/cpp/native_map_view.cpp4
-rw-r--r--android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/http/HTTPContext.java4
2 files changed, 6 insertions, 2 deletions
diff --git a/android/cpp/native_map_view.cpp b/android/cpp/native_map_view.cpp
index 02228d85b6..6c1cd87bb2 100644
--- a/android/cpp/native_map_view.cpp
+++ b/android/cpp/native_map_view.cpp
@@ -73,7 +73,7 @@ NativeMapView::NativeMapView(JNIEnv *env, jobject obj_, float pixelRatio_, int a
return;
}
- obj = env->NewGlobalRef(obj_);
+ obj = env->NewWeakGlobalRef(obj_);
if (obj == nullptr) {
env->ExceptionDescribe();
return;
@@ -93,7 +93,7 @@ NativeMapView::~NativeMapView() {
JNIEnv *env = nullptr;
ret = vm->GetEnv(reinterpret_cast<void **>(&env), JNI_VERSION_1_6);
if (ret == JNI_OK) {
- env->DeleteGlobalRef(obj);
+ env->DeleteWeakGlobalRef(obj);
} else {
mbgl::Log::Error(mbgl::Event::JNI, "GetEnv() failed with %i", ret);
throw new std::runtime_error("GetEnv() failed");
diff --git a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/http/HTTPContext.java b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/http/HTTPContext.java
index 4558bbfe34..775daaafdd 100644
--- a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/http/HTTPContext.java
+++ b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/http/HTTPContext.java
@@ -20,6 +20,7 @@ class HTTPContext {
private static final int CONNECTION_ERROR = 0;
private static final int TEMPORARY_ERROR = 1;
private static final int PERMANENT_ERROR = 2;
+ private static final int CANCELED_ERROR = 3;
private static HTTPContext mInstance = null;
@@ -78,7 +79,10 @@ class HTTPContext {
type = CONNECTION_ERROR;
} else if ((e instanceof InterruptedIOException)) {
type = TEMPORARY_ERROR;
+ } else if (mCall.isCanceled()) {
+ type = CANCELED_ERROR;
}
+
nativeOnFailure(mNativePtr, type, e.getMessage());
}