diff options
author | Tobrun <tobrun@mapbox.com> | 2017-05-11 21:00:41 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-11 21:00:41 +0200 |
commit | ad46d67aeb84b258668126dddc00c581f4808f3e (patch) | |
tree | 854e5ec0100a7c8f811be639eae407c0c4bbf098 /platform/android | |
parent | db370a02b13f39ce79b8df11e784b3543f2908cb (diff) | |
download | qtlocation-mapboxgl-ad46d67aeb84b258668126dddc00c581f4808f3e.tar.gz |
[android] - keep observer when timeout occurs, make observer param nullable, fixup log messages (#8919)
Diffstat (limited to 'platform/android')
2 files changed, 16 insertions, 11 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineRegion.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineRegion.java index a55e8dd848..2110e12b36 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineRegion.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineRegion.java @@ -4,6 +4,7 @@ import android.os.Handler; import android.os.Looper; import android.support.annotation.IntDef; import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import com.mapbox.mapboxsdk.storage.FileSource; @@ -205,7 +206,7 @@ public class OfflineRegion { /** * Constructor - * + * <p> * For JNI use only, to create a new offline region, use * {@link OfflineManager#createOfflineRegion} instead. */ @@ -247,7 +248,7 @@ public class OfflineRegion { * * @param observer the observer to be notified */ - public void setObserver(@NonNull final OfflineRegionObserver observer) { + public void setObserver(@Nullable final OfflineRegionObserver observer) { setOfflineRegionObserver(new OfflineRegionObserver() { @Override public void onStatusChanged(final OfflineRegionStatus status) { @@ -255,7 +256,9 @@ public class OfflineRegion { getHandler().post(new Runnable() { @Override public void run() { - observer.onStatusChanged(status); + if (observer != null) { + observer.onStatusChanged(status); + } } }); } @@ -267,7 +270,9 @@ public class OfflineRegion { getHandler().post(new Runnable() { @Override public void run() { - observer.onError(error); + if (observer != null) { + observer.onError(error); + } } }); } @@ -279,7 +284,9 @@ public class OfflineRegion { getHandler().post(new Runnable() { @Override public void run() { - observer.mapboxTileCountLimitExceeded(limit); + if (observer != null) { + observer.mapboxTileCountLimitExceeded(limit); + } } }); } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/offline/OfflineActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/offline/OfflineActivity.java index be5d809457..344e9e140a 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/offline/OfflineActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/offline/OfflineActivity.java @@ -274,22 +274,20 @@ public class OfflineActivity extends AppCompatActivity } // Debug - Timber.d(String.format("%s/%s resources; %s bytes downloaded.", + Timber.d("%s/%s resources; %s bytes downloaded.", String.valueOf(status.getCompletedResourceCount()), String.valueOf(status.getRequiredResourceCount()), - String.valueOf(status.getCompletedResourceSize()))); + String.valueOf(status.getCompletedResourceSize())); } @Override public void onError(OfflineRegionError error) { - Timber.e("onError reason: " + error.getReason()); - Timber.e("onError message: " + error.getMessage()); - offlineRegion.setObserver(null); + Timber.e("onError: %s, %s", error.getReason(), error.getMessage()); } @Override public void mapboxTileCountLimitExceeded(long limit) { - Timber.e("Mapbox tile count limit exceeded: " + limit); + Timber.e("Mapbox tile count limit exceeded: %s", limit); } }); |