Skip to content

Commit bc31829

Browse files
committed
fix(android): add setReactSelected and mIsSelected tracking to RNMBXPointAnnotation
1 parent 66b58b2 commit bc31829

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

android/src/main/java/com/rnmapbox/rnmbx/components/annotation/RNMBXPointAnnotation.kt

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class RNMBXPointAnnotation(private val mContext: Context, private val mManager:
3636
private val mTitle: String? = null
3737
private val mSnippet: String? = null
3838
private var mAnchor: Array<Float>? = null
39-
private val mIsSelected = false
39+
private var mIsSelected = false
4040
private var mDraggable = false
4141
private var mChildView: View? = null
4242
private var mChildBitmap: Bitmap? = null
@@ -187,7 +187,19 @@ class RNMBXPointAnnotation(private val mContext: Context, private val mManager:
187187
}
188188
}
189189

190+
fun setReactSelected(selected: Boolean) {
191+
if (selected && !mIsSelected) {
192+
pointAnnotations?.let {
193+
it.deselectSelectedAnnotation()
194+
it.selectAnnotation(this)
195+
}
196+
} else if (!selected && mIsSelected) {
197+
pointAnnotations?.deselectAnnotation(this)
198+
}
199+
}
200+
190201
fun doSelect(shouldSendEvent: Boolean) {
202+
mIsSelected = true
191203
if (calloutView != null) {
192204
makeCallout()
193205
}
@@ -197,6 +209,7 @@ class RNMBXPointAnnotation(private val mContext: Context, private val mManager:
197209
}
198210

199211
fun doDeselect() {
212+
mIsSelected = false
200213
mManager.handleEvent(makeEvent(false))
201214
mCalloutSymbol?.let { mCalloutSymbol ->
202215
pointAnnotations?.delete(mCalloutSymbol)

0 commit comments

Comments
 (0)