Skip to content

Commit b5d1639

Browse files
aleksprogergithub-actions[bot]
authored andcommitted
Make signal callbacks work similar as regular callbacks in JNI (#8048)
**Reason** - Emitting on the signal generated with bindgen didn't work while scheduling with the scheduler from C++. It happened that on activation we tried to findClass using the `attachedEnv` which had different classLoader due to the fact it was called from C++ context and callback class couldn't be resolved. Which menat that if a schedule emission from different thread JNI silently crashed **Content** - Make signal to generate callback the similar way we generate the callbacks for `callback` type, meaning that instead of retrieving the callback class dynamically when the callback invoked we store the callback objects class as static ref - We statically store this class metadata only one and it's unique per type not per instance, so it's accepatable overhead, following the regular callbacks patter cc @mapbox/nav-core-sdk cc @mapbox/core-sdk cc @mapbox/gl-native cc @mapbox/maps-android GitOrigin-RevId: b8eefe5c0beec056dd3474c628986ff4803803c6
1 parent 7abf366 commit b5d1639

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

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

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,31 +30,30 @@ class IndoorExampleActivity : AppCompatActivity() {
3030
zoom(ZOOM)
3131
bearing(BEARING)
3232
pitch(PITCH)
33-
}
33+
},
34+
styleUri = STYLE_URI
3435
)
3536

3637
val mapView = MapView(this, mapInitOptions)
3738
setContentView(mapView)
3839
val mapboxMap = mapView.mapboxMap
3940

4041
mapboxMap.getStyle {
41-
// Select a specific floor (this ID should match a floor in your indoor data)
42-
// Example floor ID - replace with actual floor ID from your indoor data
43-
mapboxMap.indoor.selectFloor(FLOOR_ID)
44-
45-
// Listen to indoor state updates
4642
mapboxMap.indoor.setOnIndoorUpdatedCallback(object : IndoorManager.OnIndoorUpdatedCallback {
4743
override fun onOnIndoorUpdated(onIndoorUpdated: IndoorState) {
48-
logD(TAG, "Indoor state updated: $onIndoorUpdated")
49-
logD(TAG, "Available floors: ${onIndoorUpdated.floors}")
50-
logD(TAG, "Selected floor: ${onIndoorUpdated.selectedFloorId}")
44+
logD(TAG, "Indoor_Subscriber_0: Indoor state updated: $onIndoorUpdated")
45+
logD(TAG, "Indoor_Subscriber_0: Selected floor: ${onIndoorUpdated.selectedFloorId}")
5146
}
5247
})
48+
49+
logD(TAG, "Indoor: selectFloor: $FLOOR_ID")
50+
mapboxMap.indoor.selectFloor(FLOOR_ID)
5351
}
5452
}
5553

5654
companion object {
5755
private const val TAG = "IndoorExampleActivity"
56+
private const val STYLE_URI = "mapbox://styles/mapbox/streets-v12"
5857

5958
// JFK Airport coordinates
6059
private const val LATITUDE = 40.6441

0 commit comments

Comments
 (0)