From 78bef607a60d368b670287dfd31fe714882078c4 Mon Sep 17 00:00:00 2001 From: Tobrun Date: Mon, 8 Aug 2016 22:31:45 -0400 Subject: [PATCH] #103 - only remove an offline region if there is are any --- .../offline/SimpleOfflineMapActivity.java | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/MapboxAndroidDemo/src/main/java/com/mapbox/mapboxandroiddemo/examples/offline/SimpleOfflineMapActivity.java b/MapboxAndroidDemo/src/main/java/com/mapbox/mapboxandroiddemo/examples/offline/SimpleOfflineMapActivity.java index bba517f9c..05f243df9 100644 --- a/MapboxAndroidDemo/src/main/java/com/mapbox/mapboxandroiddemo/examples/offline/SimpleOfflineMapActivity.java +++ b/MapboxAndroidDemo/src/main/java/com/mapbox/mapboxandroiddemo/examples/offline/SimpleOfflineMapActivity.java @@ -133,19 +133,20 @@ public void onPause() { offlineManager.listOfflineRegions(new OfflineManager.ListOfflineRegionsCallback() { @Override public void onList(OfflineRegion[] offlineRegions) { + if (offlineRegions.length > 0) { + // delete the last item in the offlineRegions list which will be yosemite offline map + offlineRegions[(offlineRegions.length - 1)].delete(new OfflineRegion.OfflineRegionDeleteCallback() { + @Override + public void onDelete() { + Toast.makeText(SimpleOfflineMapActivity.this, "Yosemite offline map deleted", Toast.LENGTH_LONG).show(); + } - // delete the last item in the offlineRegions list which will be yosemite offline map - offlineRegions[(offlineRegions.length - 1)].delete(new OfflineRegion.OfflineRegionDeleteCallback() { - @Override - public void onDelete() { - Toast.makeText(SimpleOfflineMapActivity.this, "Yosemite offline map deleted", Toast.LENGTH_LONG).show(); - } - - @Override - public void onError(String error) { - Log.e(TAG, "On Delete error: " + error); - } - }); + @Override + public void onError(String error) { + Log.e(TAG, "On Delete error: " + error); + } + }); + } } @Override