Skip to content

Commit 7525c71

Browse files
authored
Fix crash after user removes annotation manager (#2753)
1 parent efa6890 commit 7525c71

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

app/src/main/java/com/mapbox/maps/testapp/examples/markersandcallouts/PointAnnotationActivity.kt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import com.mapbox.maps.extension.style.expressions.generated.Expression.Companio
1818
import com.mapbox.maps.extension.style.expressions.generated.Expression.Companion.get
1919
import com.mapbox.maps.extension.style.expressions.generated.Expression.Companion.literal
2020
import com.mapbox.maps.extension.style.expressions.generated.Expression.Companion.not
21-
import com.mapbox.maps.extension.style.expressions.generated.Expression.Companion.toNumber
2221
import com.mapbox.maps.extension.style.layers.properties.generated.IconAnchor
2322
import com.mapbox.maps.extension.style.layers.properties.generated.SymbolZOrder
2423
import com.mapbox.maps.extension.style.layers.properties.generated.TextAnchor
@@ -239,6 +238,7 @@ class PointAnnotationActivity : AppCompatActivity() {
239238
binding.deleteAll.setOnClickListener {
240239
pointAnnotationManager?.let {
241240
annotationPlugin.removeAnnotationManager(it)
241+
pointAnnotationManager = null
242242
}
243243
}
244244
binding.changeStyle.setOnClickListener {
@@ -275,10 +275,16 @@ class PointAnnotationActivity : AppCompatActivity() {
275275
eq(get(idKey), literal(pointAnnotation!!.id))
276276
val filter = pointAnnotationManager!!.layerFilter
277277
if (filter != null && filter == expression) {
278-
pointAnnotationManager!!.layerFilter = not(eq(toNumber(get(idKey)), literal(-1)))
278+
pointAnnotationManager!!.layerFilter = not(eq(get(idKey), literal("")))
279279
} else {
280280
pointAnnotationManager!!.layerFilter = expression
281281
}
282+
} else {
283+
Toast.makeText(
284+
this@PointAnnotationActivity,
285+
"pointAnnotationManager or pointAnnotation is null.",
286+
Toast.LENGTH_LONG
287+
).show()
282288
}
283289
}
284290

0 commit comments

Comments
 (0)