Skip to content

Commit e898e05

Browse files
authored
NPE (#472)
* check map has been created before resetting listener * Update other sample apps to check for mapzenMap nullability
1 parent e5a5e3d commit e898e05

File tree

9 files changed

+28
-10
lines changed

9 files changed

+28
-10
lines changed

samples/mapzen-android-sdk-sample/src/main/java/com/mapzen/android/sdk/sample/BasicMapzenActivity.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,9 @@ private void configureMap(boolean enabled) {
8989

9090
@Override protected void onDestroy() {
9191
super.onDestroy();
92-
map.setFindMeOnClickListener(null);
92+
if (map != null) {
93+
map.setFindMeOnClickListener(null);
94+
}
9395
}
9496

9597
@Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {

samples/mapzen-android-sdk-sample/src/main/java/com/mapzen/android/sdk/sample/MapzenSearchViewActivity.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.mapzen.android.sdk.sample;
1+
package com.mapzen.android.sdk.sample;
22

33
import com.mapzen.android.graphics.MapView;
44
import com.mapzen.android.graphics.MapzenMap;
@@ -99,6 +99,8 @@ private void setupPeliasSearchView(PeliasSearchView searchView) {
9999

100100
@Override protected void onDestroy() {
101101
super.onDestroy();
102-
mapzenMap.setPersistMapData(false);
102+
if (mapzenMap != null) {
103+
mapzenMap.setPersistMapData(false);
104+
}
103105
}
104106
}

samples/mapzen-android-sdk-sample/src/main/java/com/mapzen/android/sdk/sample/MarkerMapzenActivity.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ private void configureMap() {
4040
}
4141

4242
@Override protected void onDestroy() {
43-
map.removeMarker();
43+
if (map != null) {
44+
map.removeMarker();
45+
}
4446
super.onDestroy();
4547
}
4648
}

samples/mapzen-android-sdk-sample/src/main/java/com/mapzen/android/sdk/sample/OverlayActivity.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ public void onItemSelected(AdapterView<?> parent, View view, int position, long
5757
}
5858

5959
@Override protected void onDestroy() {
60-
mapzenMap.setMyLocationEnabled(false);
60+
if (mapzenMap != null) {
61+
mapzenMap.setMyLocationEnabled(false);
62+
}
6163
super.onDestroy();
6264
}
6365

samples/mapzen-android-sdk-sample/src/main/java/com/mapzen/android/sdk/sample/PolygonMapzenActivity.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ private void configureMap() {
4343
}
4444

4545
@Override protected void onDestroy() {
46-
map.removePolygon();
46+
if (map != null) {
47+
map.removePolygon();
48+
}
4749
super.onDestroy();
4850
}
4951
}

samples/mapzen-android-sdk-sample/src/main/java/com/mapzen/android/sdk/sample/PolylineMapzenActivity.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ private void configureMap() {
4242
}
4343

4444
@Override protected void onDestroy() {
45-
map.removePolyline();
45+
if (map != null) {
46+
map.removePolyline();
47+
}
4648
super.onDestroy();
4749
}
4850
}

samples/mapzen-android-sdk-sample/src/main/java/com/mapzen/android/sdk/sample/RoutePinsActivity.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ private void drawRoutePins() {
6161
}
6262

6363
@Override protected void onDestroy() {
64-
map.clearRoutePins();
64+
if (map != null) {
65+
map.clearRoutePins();
66+
}
6567
super.onDestroy();
6668
}
6769
}

samples/mapzen-android-sdk-sample/src/main/java/com/mapzen/android/sdk/sample/RouterActivity.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,9 @@ private void addPointToRoute(LngLat lngLat) {
118118
}
119119

120120
@Override protected void onDestroy() {
121-
map.setMyLocationEnabled(false);
121+
if (map != null) {
122+
map.setMyLocationEnabled(false);
123+
}
122124
super.onDestroy();
123125
}
124126
}

samples/mapzen-android-sdk-sample/src/main/java/com/mapzen/android/sdk/sample/SwitchStyleActivity.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@ public class SwitchStyleActivity extends BaseDemoActivity {
8686
@Override protected void onDestroy() {
8787
styleSpinner.setOnItemSelectedListener(null);
8888
updateBtn.setOnClickListener(null);
89-
mapzenMap.setMyLocationEnabled(false);
89+
if (mapzenMap != null) {
90+
mapzenMap.setMyLocationEnabled(false);
91+
}
9092
super.onDestroy();
9193
}
9294

0 commit comments

Comments
 (0)