react-native-pointr 8.16.1 → 9.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,6 @@
1
1
  package com.pointr
2
2
 
3
3
  import android.annotation.SuppressLint
4
- import android.os.Handler
5
- import android.os.Looper.getMainLooper
6
4
  import android.util.Log
7
5
  import android.view.Choreographer
8
6
  import android.view.View
@@ -15,36 +13,31 @@ import com.facebook.react.bridge.WritableNativeMap
15
13
  import com.facebook.react.uimanager.ThemedReactContext
16
14
  import com.facebook.react.uimanager.ViewGroupManager
17
15
  import com.facebook.react.uimanager.events.RCTEventEmitter
18
- import com.pointrlabs.core.configuration.MutableConfiguration
19
16
  import com.pointrlabs.core.management.DataManager
20
17
  import com.pointrlabs.core.management.Pointr
21
18
  import com.pointrlabs.core.management.interfaces.PointrListener
22
19
  import com.pointrlabs.core.management.models.ErrorMessage
23
20
  import com.pointrlabs.core.management.models.Site
24
- import com.pointrlabs.core.map.handlers.MapWidgetEventsHandler
25
- import com.pointrlabs.core.map.handlers.PathFindingEventsHandler
26
- import com.pointrlabs.core.map.handlers.PathUpdatesEventHandler
27
- import com.pointrlabs.core.map.models.PTRDeepLinkAction
28
- import com.pointrlabs.core.map.models.PTRDeepLinkLocation
29
- import com.pointrlabs.core.map.models.PTRDeepLinkPathfindingAction
30
- import com.pointrlabs.core.map.models.PTRDeepLinkPoiLocation
31
- import com.pointrlabs.core.map.models.PTRError
32
- import com.pointrlabs.core.map.models.PTRMapSymbolLayer
33
- import com.pointrlabs.core.map.models.events_listeners.MapEventsListener
34
- import com.pointrlabs.core.map.models.events_listeners.MarkMyCarDetailsEvent
35
- import com.pointrlabs.core.map.models.events_listeners.MarkMyCarDetailsEventsListener
36
- import com.pointrlabs.core.map.models.events_listeners.PathFindingEventsListener
37
- import com.pointrlabs.core.map.viewmodels.PTRMapWidgetConfiguration
38
- import com.pointrlabs.core.map.views.PTRMapAnimationType
39
- import com.pointrlabs.core.map.views.PTRMapFragment
40
- import com.pointrlabs.core.map.views.PTRMapWidgetFragment
41
- import com.pointrlabs.core.map.views.pathfinding.MarkMyCarBottomSheet
21
+ import com.pointrlabs.core.management.models.deeplink.PTRMapWidgetAction
22
+ import com.pointrlabs.core.management.models.deeplink.PTRMapWidgetBuildingLocation
23
+ import com.pointrlabs.core.management.models.deeplink.PTRMapWidgetFocusAction
24
+ import com.pointrlabs.core.management.models.deeplink.PTRMapWidgetLevelLocation
25
+ import com.pointrlabs.core.management.models.deeplink.PTRMapWidgetMarkMyCarAction
26
+ import com.pointrlabs.core.management.models.deeplink.PTRMapWidgetPoiLocation
27
+ import com.pointrlabs.core.management.models.deeplink.PTRMapWidgetShowMyCarAction
28
+ import com.pointrlabs.core.management.models.deeplink.PTRMapWidgetSiteLocation
29
+ import com.pointrlabs.core.management.models.deeplink.PTRMapWidgetWayfindingAction
42
30
  import com.pointrlabs.core.nativecore.wrappers.Plog
43
- import com.pointrlabs.core.pathfinding.PathManager
44
- import com.pointrlabs.core.pathfinding.session.PathSession
45
- import com.pointrlabs.core.pathfinding.session.PathSessionState
46
- import com.pointrlabs.core.positioning.model.PositioningTypes
47
31
  import com.pointrlabs.core.site.SiteManager
32
+ import com.pointrlabs.core.util.models.error.PTRError
33
+ import com.pointrlabs.core.wayfinding.WayfindingManager
34
+ import com.pointrlabs.ui.map.models.PTRMapSymbolLayer
35
+ import com.pointrlabs.ui.map.models.events_listeners.MapEventsListener
36
+ import com.pointrlabs.ui.map.models.events_listeners.MarkMyCarDetailsEvent
37
+ import com.pointrlabs.ui.map.models.events_listeners.MarkMyCarDetailsEventsListener
38
+ import com.pointrlabs.ui.map.views.PTRMapFragment
39
+ import com.pointrlabs.ui.map.views.PTRMapWidgetFragment
40
+ import com.pointrlabs.ui.map.views.wayfinding.MarkMyCarBottomSheet
48
41
  import java.util.concurrent.Semaphore
49
42
 
50
43
 
@@ -54,36 +47,20 @@ class PTRMapWidgetManager(private val reactContext: ReactApplicationContext) :
54
47
 
55
48
  override fun getName() = REACT_CLASS
56
49
 
57
- private var markMyCarButtonSheet: MarkMyCarBottomSheet? = null
58
50
  private lateinit var frameLayout: FrameLayout
59
51
 
60
- // TODO: Uncomment 1
61
- // private var _ptrMapWidgetFragment: PTRMapWidgetFragment? = null
62
- private val ptrMapWidgetFragment: PTRMapWidgetFragment?
63
- get() {
64
- // TODO: Uncomment 1
65
- // _ptrMapWidgetFragment?.let { return it }
66
- Log.i("PTRMapWidgetManager", "Creating map widget fragment")
67
- // TODO: Uncomment 1
68
- //_ptrMapWidgetFragment = createMapWidgetFragment()
69
- // TODO: Comment 1
70
- val _ptrMapWidgetFragment = createMapWidgetFragment()
71
- Choreographer.getInstance().postFrameCallback(frameCallback)
72
- _ptrMapWidgetFragment?.addListener(this)
73
- return _ptrMapWidgetFragment
74
- }
75
-
76
- private fun createMapWidgetFragment(): PTRMapWidgetFragment {
52
+ private fun getMapWidgetFragment(action: PTRMapWidgetAction): PTRMapWidgetFragment {
53
+ Log.i("PTRMapWidgetManager", "Creating map widget fragment with action: $action")
77
54
  waitForPointrToRun()
78
- // TODO: wait for configuration to be ready
79
- val configuration = PointrMapWidgetActivity.mapWidgetConfiguration
80
- configuration.isExitButtonShown = false
81
- @Suppress("DEPRECATION")
82
- val widget = PTRMapWidgetFragment.newInstance(configuration).show(
55
+ val ptrMapWidgetFragment = PTRMapWidgetFragment.newInstance(
83
56
  (reactContext.currentActivity as FragmentActivity).supportFragmentManager,
84
- frameLayout.id
57
+ frameLayout.id,
58
+ PointrModule.mapWidgetConfiguration,
59
+ action
85
60
  )
86
- return widget
61
+ Choreographer.getInstance().postFrameCallback(frameCallback)
62
+ ptrMapWidgetFragment.addListener(this)
63
+ return ptrMapWidgetFragment
87
64
  }
88
65
 
89
66
  /**
@@ -102,182 +79,118 @@ class PTRMapWidgetManager(private val reactContext: ReactApplicationContext) :
102
79
  ) {
103
80
  super.receiveCommand(root, command, args)
104
81
  val args1 = args ?: return
105
- val ptrMapWidgetFragment = this.ptrMapWidgetFragment ?: run {
106
- Log.e(
107
- "PTRMapWidgetManager",
108
- "PTRMapWidgetFragment is null"
109
- )
110
- return
111
- }
112
- // TODO: Uncomment 1
113
- // clearPath(ptrMapWidgetFragment)
114
- // dismissMarkMyCarDetails(ptrMapWidgetFragment)
115
- executeCommand(ptrMapWidgetFragment, command, args1)
116
- }
117
-
118
- private fun dismissMarkMyCarDetails(ptrMapWidgetFragment: PTRMapWidgetFragment) {
119
- val markMyCarButtonSheet = markMyCarButtonSheet ?: return
120
- val handler = ptrMapWidgetFragment.markMyCarEventsHandler
121
- ?: return Plog.w("Mark my car events handler is null")
122
- Plog.i("Dismissing mark my car details")
123
- handler.onMarkMyCarDetailsEvent(markMyCarButtonSheet, MarkMyCarDetailsEvent.Cancel)
124
- handler.onMarkMyCarDetailsEvent(markMyCarButtonSheet, MarkMyCarDetailsEvent.Close)
125
- }
126
-
127
- private fun clearPath(ptrMapWidgetFragment: PTRMapWidgetFragment) {
128
- ptrMapWidgetFragment.mapFragment?.removeAllFeatures { isSuccess, message ->
129
- if (!isSuccess) {
130
- Log.e(
131
- "PTRMapWidgetManager",
132
- "Error removing features: $message"
133
- )
134
- }
135
- ptrMapWidgetFragment.mapFragment?.removeLayer(LAYER_STATIC_PATH) { b, e ->
136
- if (!b) {
137
- Log.e(
138
- "PTRMapWidgetManager",
139
- "Error removing layer: $e"
140
- )
141
- }
142
- ptrMapWidgetFragment.mapFragment?.currentPath = null
143
- ptrMapWidgetFragment.mapFragment?.currentPathSession?.abort()
144
- }
145
- }
82
+ executeCommand(command, args1)
146
83
  }
147
84
 
148
85
  private fun executeCommand(
149
- ptrMapWidgetFragment: PTRMapWidgetFragment,
150
86
  command: String,
151
- args1: ReadableArray
87
+ args: ReadableArray
152
88
  ) {
153
- when (command) {
154
- PTRMapWidgetCommandType.SITE -> showSite(ptrMapWidgetFragment, args1.getString(0))
155
- PTRMapWidgetCommandType.BUILDING -> showBuilding(
156
- ptrMapWidgetFragment,
157
- args1.getString(0),
158
- args1.getString(1)
159
- )
89
+ val action: PTRMapWidgetAction = when (command) {
90
+ PTRMapWidgetCommandType.SITE -> {
91
+ val siteId = args.getString(0).orEmpty()
92
+ val location = PTRMapWidgetSiteLocation(siteId, isExternalIdentifier = true)
93
+ PTRMapWidgetFocusAction(location)
94
+ }
160
95
 
161
- PTRMapWidgetCommandType.LEVEL -> showLevel(
162
- ptrMapWidgetFragment,
163
- args1.getString(0),
164
- args1.getString(1),
165
- args1.getInt(2)
166
- )
96
+ PTRMapWidgetCommandType.BUILDING -> {
97
+ val siteId = args.getString(0).orEmpty()
98
+ val buildingId = args.getString(1).orEmpty()
99
+ val location =
100
+ PTRMapWidgetBuildingLocation(siteId, buildingId, isExternalIdentifier = true)
101
+ PTRMapWidgetFocusAction(location)
102
+ }
167
103
 
168
- PTRMapWidgetCommandType.POI -> showPoi(
169
- ptrMapWidgetFragment,
170
- args1.getString(0),
171
- args1.getString(1)
172
- )
104
+ PTRMapWidgetCommandType.LEVEL -> {
105
+ val siteId = args.getString(0).orEmpty()
106
+ val buildingId = args.getString(1).orEmpty()
107
+ val location = PTRMapWidgetLevelLocation(
108
+ siteId,
109
+ buildingId,
110
+ args.getInt(2),
111
+ isExternalIdentifier = true
112
+ )
113
+ PTRMapWidgetFocusAction(location)
114
+ }
173
115
 
174
- PTRMapWidgetCommandType.PATH -> showPath(
175
- ptrMapWidgetFragment,
176
- args1.getString(0),
177
- args1.getString(1)
178
- )
116
+ PTRMapWidgetCommandType.POI -> {
117
+ val siteId = args.getString(0).orEmpty()
118
+ val poiId = args.getString(1).orEmpty()
119
+ val location = PTRMapWidgetPoiLocation(siteId, poiId, isExternalIdentifier = true)
120
+ PTRMapWidgetFocusAction(location)
121
+ }
179
122
 
180
- PTRMapWidgetCommandType.STATIC_PATH -> showStaticPath(
181
- ptrMapWidgetFragment,
182
- args1.getString(0),
183
- args1.getString(1),
184
- args1.getString(2)
185
- )
123
+ PTRMapWidgetCommandType.PATH -> {
124
+ val siteId = args.getString(0).orEmpty()
125
+ val poiId = args.getString(1).orEmpty()
126
+ val location = PTRMapWidgetPoiLocation(siteId, poiId, isExternalIdentifier = true)
127
+ PTRMapWidgetWayfindingAction(location)
128
+ }
129
+
130
+ PTRMapWidgetCommandType.STATIC_PATH -> {
131
+ val siteId = args.getString(0).orEmpty()
132
+ val fromPoiId = args.getString(1).orEmpty()
133
+ val toPoiId = args.getString(2).orEmpty()
134
+ val location =
135
+ PTRMapWidgetPoiLocation(siteId, fromPoiId, isExternalIdentifier = true)
136
+ val action1 = PTRMapWidgetFocusAction(location)
137
+ val ptrMapWidgetFragment = getMapWidgetFragment(action1)
138
+ action1.onComplete = onComplete@{ error ->
139
+ if (error != null) {
140
+ mapWidgetDidEndLoading(
141
+ command,
142
+ *args.toArrayList().mapNotNull { it }.toTypedArray(),
143
+ error
144
+ )
145
+ return@onComplete
146
+ }
147
+ Plog.i("Focus action completed, showing static path")
148
+
149
+ showStaticPath(
150
+ ptrMapWidgetFragment,
151
+ siteId,
152
+ fromPoiId,
153
+ toPoiId
154
+ )
155
+ }
156
+ return
157
+ }
186
158
 
187
159
  PTRMapWidgetCommandType.MARK_MY_CAR_SITE -> {
188
- showMarkMyCarDetails(
189
- ptrMapWidgetFragment,
190
- args1.getString(0),
191
- shouldShowPopup = args1.getBoolean(1),
192
- animationType = args1.getInt(2)
193
- )
160
+ val siteId = args.getString(0).orEmpty()
161
+ val location = PTRMapWidgetSiteLocation(siteId, isExternalIdentifier = true)
162
+ PTRMapWidgetMarkMyCarAction(location, shouldShowPopup = args.getBoolean(1))
194
163
  }
195
164
 
196
165
  PTRMapWidgetCommandType.MARK_MY_CAR_LEVEL -> {
197
- showMarkMyCarDetails(
198
- ptrMapWidgetFragment,
199
- args1.getString(0),
200
- args1.getString(1),
201
- args1.getInt(2),
202
- args1.getBoolean(3),
203
- args1.getInt(4)
166
+ val siteId = args.getString(0).orEmpty()
167
+ val location = PTRMapWidgetLevelLocation(
168
+ siteId,
169
+ args.getString(1).orEmpty(),
170
+ args.getInt(2),
171
+ isExternalIdentifier = true
204
172
  )
173
+ PTRMapWidgetMarkMyCarAction(location, shouldShowPopup = args.getBoolean(3))
205
174
  }
206
175
 
207
- PTRMapWidgetCommandType.MY_CAR_SITE -> {
208
- showMyCarDetails(ptrMapWidgetFragment, args1.getString(0), args1.getInt(1))
176
+ PTRMapWidgetCommandType.SHOW_MY_CAR_SITE -> {
177
+ val siteId = args.getString(0).orEmpty()
178
+ val location = PTRMapWidgetSiteLocation(siteId, isExternalIdentifier = true)
179
+ PTRMapWidgetShowMyCarAction(location, shouldShowPopup = args.getBoolean(1))
209
180
  }
210
181
 
211
182
  else -> return
212
183
  }
213
- }
184
+ action.onComplete = { error ->
185
+ val list = args.toArrayList()
186
+ list.add(error ?: "")
214
187
 
215
- private fun showMyCarDetails(
216
- ptrMapWidgetFragment: PTRMapWidgetFragment,
217
- siteExternalIdentifier: String,
218
- animationTypeOrdinal: Int
219
- ) {
220
- val animationType = PTRMapAnimationType.entries[animationTypeOrdinal]
221
- ptrMapWidgetFragment.showMyCarDetails(
222
- siteExternalIdentifier,
223
- shouldShowDialog = false,
224
- animationType = animationType
225
- ) onComplete@{ error ->
226
- this@PTRMapWidgetManager.mapWidgetDidEndLoading(
227
- PTRMapWidgetCommandType.MY_CAR_SITE,
228
- siteExternalIdentifier,
229
- animationType,
230
- error ?: ""
188
+ mapWidgetDidEndLoading(
189
+ command,
190
+ *list.mapNotNull { it }.toTypedArray(),
231
191
  )
232
- error?.let {
233
- Plog.e("Error showing mark my car details: $it")
234
- return@onComplete
235
- }
236
- Plog.i("Mark my car details is shown")
237
- }
238
- }
239
-
240
- private fun showMarkMyCarDetails(
241
- ptrMapWidgetFragment: PTRMapWidgetFragment,
242
- siteExternalIdentifier: String,
243
- buildingExternalIdentifier: String? = null,
244
- levelIndex: Int? = null,
245
- shouldShowPopup: Boolean,
246
- animationType: Int
247
- ) {
248
-
249
- ptrMapWidgetFragment.showMarkMyCarDetails(
250
- siteExternalIdentifier,
251
- buildingExternalIdentifier,
252
- levelIndex,
253
- PTRMapAnimationType.entries[animationType],
254
- shouldShowPopup
255
- ) onComplete@{ error ->
256
- if (buildingExternalIdentifier == null || levelIndex == null || levelIndex == PositioningTypes.INVALID_INTEGER) {
257
- this@PTRMapWidgetManager.mapWidgetDidEndLoading(
258
- PTRMapWidgetCommandType.MARK_MY_CAR_LEVEL,
259
- siteExternalIdentifier,
260
- buildingExternalIdentifier ?: "",
261
- levelIndex ?: PositioningTypes.INVALID_INTEGER,
262
- shouldShowPopup,
263
- animationType,
264
- error ?: ""
265
- )
266
- } else {
267
- this@PTRMapWidgetManager.mapWidgetDidEndLoading(
268
- PTRMapWidgetCommandType.MARK_MY_CAR_SITE,
269
- siteExternalIdentifier,
270
- shouldShowPopup,
271
- animationType,
272
- error ?: ""
273
- )
274
- }
275
- error?.let {
276
- Plog.e("Error showing mark my car details: $it")
277
- return@onComplete
278
- }
279
- Plog.i("Mark my car details is shown")
280
192
  }
193
+ getMapWidgetFragment(action)
281
194
  }
282
195
 
283
196
  private fun mapWidgetDidEndLoading(
@@ -301,7 +214,7 @@ class PTRMapWidgetManager(private val reactContext: ReactApplicationContext) :
301
214
  PTRMapWidgetCommandType.LEVEL -> {
302
215
  event.putString("siteExternalIdentifier", args[0] as String)
303
216
  event.putString("buildingExternalIdentifier", args[1] as String)
304
- event.putInt("levelIndex", args[2] as Int)
217
+ event.putInt("levelIndex", (args[2] as Number).toInt())
305
218
  event.putString("error", args[3] as String)
306
219
  }
307
220
 
@@ -324,6 +237,29 @@ class PTRMapWidgetManager(private val reactContext: ReactApplicationContext) :
324
237
  event.putString("error", args[3] as String)
325
238
  }
326
239
 
240
+ PTRMapWidgetCommandType.MARK_MY_CAR_SITE -> {
241
+ event.putString("siteExternalIdentifier", args[0] as String)
242
+ event.putBoolean("shouldShowPopup", args[1] as Boolean)
243
+ event.putInt("animationType", (args[2] as Number).toInt())
244
+ event.putString("error", args[3] as String)
245
+ }
246
+
247
+ PTRMapWidgetCommandType.MARK_MY_CAR_LEVEL -> {
248
+ event.putString("siteExternalIdentifier", args[0] as String)
249
+ event.putString("buildingExternalIdentifier", args[1] as String)
250
+ event.putInt("levelIndex", (args[2] as Number).toInt())
251
+ event.putBoolean("shouldShowPopup", args[3] as Boolean)
252
+ event.putInt("animationType", (args[4] as Number).toInt())
253
+ event.putString("error", args[5] as String)
254
+ }
255
+
256
+ PTRMapWidgetCommandType.SHOW_MY_CAR_SITE -> {
257
+ event.putString("siteExternalIdentifier", args[0] as String)
258
+ event.putBoolean("shouldShowPopup", args[1] as Boolean)
259
+ event.putInt("animationType", (args[2] as Number).toInt())
260
+ event.putString("error", args[3] as String)
261
+ }
262
+
327
263
  else -> {
328
264
  return
329
265
  }
@@ -404,7 +340,7 @@ class PTRMapWidgetManager(private val reactContext: ReactApplicationContext) :
404
340
  )
405
341
  return
406
342
  }
407
- val pathManager = Pointr.getPointr()?.pathManager ?: run {
343
+ val wayfindingManager = Pointr.getPointr()?.wayfindingManager ?: run {
408
344
  mapWidgetDidEndLoading(
409
345
  PTRMapWidgetCommandType.STATIC_PATH,
410
346
  site,
@@ -414,7 +350,7 @@ class PTRMapWidgetManager(private val reactContext: ReactApplicationContext) :
414
350
  )
415
351
  return
416
352
  }
417
- val path = pathManager.calculatePath(source, listOf(target)) ?: run {
353
+ val route = wayfindingManager.calculateRoute(source, listOf(target)) ?: run {
418
354
  mapWidgetDidEndLoading(
419
355
  PTRMapWidgetCommandType.STATIC_PATH,
420
356
  site,
@@ -424,217 +360,66 @@ class PTRMapWidgetManager(private val reactContext: ReactApplicationContext) :
424
360
  )
425
361
  return
426
362
  }
427
- val onCompleted = { error: String? ->
428
- error?.let {
363
+ val layer = PTRMapSymbolLayer(
364
+ LAYER_STATIC_PATH
365
+ )
366
+ ptrMapWidgetFragment.mapFragment?.addLayer(layer) { isSuccess, message ->
367
+ if (!isSuccess) {
429
368
  mapWidgetDidEndLoading(
430
369
  PTRMapWidgetCommandType.STATIC_PATH,
431
370
  site,
432
371
  fromPoi,
433
372
  toPoi,
434
- "Error loading the map: $it"
373
+ "Failed to add static path layer: $message"
435
374
  )
436
- Plog.e("Error showing level: $it")
437
- return@let
375
+ return@addLayer
438
376
  }
439
- ptrMapWidgetFragment.focusOnCoordinate(
440
- source.location.site?.internalIdentifier ?: PositioningTypes.INVALID_INTEGER,
441
- source.location.building?.internalIdentifier ?: PositioningTypes.INVALID_INTEGER,
442
- source.location.level?.index ?: PositioningTypes.INVALID_INTEGER,
443
- source.location.lat,
444
- source.location.lon
445
- ) {
446
- val layer = PTRMapSymbolLayer(LAYER_STATIC_PATH)
447
- val mapFragment = ptrMapWidgetFragment.mapFragment ?: return@focusOnCoordinate
448
- mapFragment.addLayer(layer) { b1, e1 ->
449
- if (!b1) {
450
- mapWidgetDidEndLoading(
451
- PTRMapWidgetCommandType.STATIC_PATH,
452
- site,
453
- fromPoi,
454
- toPoi,
455
- "Error adding layer: $e1"
456
- )
457
- Plog.e("Error adding layer: $e1")
458
- return@addLayer
459
- }
460
- mapFragment.addFeatures(
461
- listOf(source, target), layer.identifier
462
- ) { b2, e2 ->
463
- if (!b2) {
464
- mapWidgetDidEndLoading(
465
- PTRMapWidgetCommandType.STATIC_PATH,
466
- site,
467
- fromPoi,
468
- toPoi,
469
- "Error adding features: $e2"
470
- )
471
- Plog.e("Error adding features: $e2")
472
- return@addFeatures
473
- }
474
- mapFragment.currentPath = path
475
- mapWidgetDidEndLoading(
476
- PTRMapWidgetCommandType.STATIC_PATH,
477
- site,
478
- fromPoi,
479
- toPoi,
480
- ""
481
- )
482
- Plog.i("Path shown")
483
- }
377
+ Log.i("PTRMapWidgetManager", "Static path layer added successfully")
378
+
379
+ ptrMapWidgetFragment.mapFragment?.addFeatures(
380
+ listOf(source, target),
381
+ LAYER_STATIC_PATH
382
+ ) { isSuccess1, message1 ->
383
+ if (!isSuccess1) {
384
+ mapWidgetDidEndLoading(
385
+ PTRMapWidgetCommandType.STATIC_PATH,
386
+ site,
387
+ fromPoi,
388
+ toPoi,
389
+ "Failed to add POI features: $message1"
390
+ )
391
+ return@addFeatures
484
392
  }
485
- }
486
- }
487
- source.level?.let {
488
- ptrMapWidgetFragment.showLevel(it, onComplete = onCompleted)
489
- } ?: ptrMapWidgetFragment.showSite(
490
- source.location.site?.internalIdentifier ?: 0, onComplete = onCompleted
491
- )
492
-
493
- }
494
-
495
- private fun showPath(ptrMapWidgetFragment: PTRMapWidgetFragment, site: String, toPoi: String) {
496
-
497
-
498
- val siteObject = getSite(site) ?: run {
499
- mapWidgetDidEndLoading(
500
- PTRMapWidgetCommandType.PATH,
501
- site,
502
- toPoi,
503
- "Site not found"
504
- )
505
- return
506
- }
507
- if (!waitForSiteData(siteObject)) {
508
- mapWidgetDidEndLoading(
509
- PTRMapWidgetCommandType.PATH,
510
- site,
511
- toPoi,
512
- "Site data not found"
513
- )
514
- return
515
- }
516
- val target =
517
- Pointr.getPointr()?.poiManager?.getPoiByExternalIdentifier(siteObject, toPoi) ?: run {
393
+ Log.i("PTRMapWidgetManager", "POI features added successfully")
394
+ ptrMapWidgetFragment.mapFragment?.currentRoute = route
518
395
  mapWidgetDidEndLoading(
519
- PTRMapWidgetCommandType.PATH,
396
+ PTRMapWidgetCommandType.STATIC_PATH,
520
397
  site,
398
+ fromPoi,
521
399
  toPoi,
522
- "Target POI not found"
400
+ ""
523
401
  )
524
- return
525
- }
526
-
527
- val action = PTRDeepLinkPathfindingAction(
528
- PTRDeepLinkPoiLocation(
529
- siteObject.internalIdentifier,
530
- target.id
531
- )
532
- )
533
- ptrMapWidgetFragment.performDeepLinkAction(action) { error ->
534
- this@PTRMapWidgetManager.mapWidgetDidEndLoading(
535
- PTRMapWidgetCommandType.PATH,
536
- site,
537
- toPoi,
538
- error ?: ""
539
- )
540
- error?.let {
541
- Plog.e("Error showing path: $it")
542
- return@performDeepLinkAction
543
- }
544
- Plog.i("Path shown")
545
- }
546
- }
547
-
548
- private fun showPoi(ptrMapWidgetFragment: PTRMapWidgetFragment, site: String, poi: String) {
549
- ptrMapWidgetFragment.showPoiDetails(site, poi) { error ->
550
- this@PTRMapWidgetManager.mapWidgetDidEndLoading(
551
- PTRMapWidgetCommandType.POI,
552
- site,
553
- poi,
554
- error ?: ""
555
- )
556
- error?.let {
557
- Plog.e("Error showing poi: $it")
558
- return@showPoiDetails
559
- }
560
- Plog.i("Poi shown")
561
- }
562
- }
563
-
564
- private fun showLevel(
565
- ptrMapWidgetFragment: PTRMapWidgetFragment,
566
- site: String,
567
- building: String,
568
- level: Int
569
- ) {
570
- ptrMapWidgetFragment.showLevel(site, building, level) showLevelInternal@{ error ->
571
- this@PTRMapWidgetManager.mapWidgetDidEndLoading(
572
- PTRMapWidgetCommandType.LEVEL,
573
- site,
574
- building,
575
- level,
576
- error ?: ""
577
- )
578
- error?.let {
579
- Plog.e("Error showing level: $it")
580
- return@showLevelInternal
581
- }
582
- Plog.i("Level shown")
583
- }
584
- }
585
-
586
- private fun showBuilding(
587
- ptrMapWidgetFragment: PTRMapWidgetFragment,
588
- site: String,
589
- building: String
590
- ) {
591
- ptrMapWidgetFragment.showBuilding(site, building) showBuildingInternal@{ error ->
592
- this@PTRMapWidgetManager.mapWidgetDidEndLoading(
593
- PTRMapWidgetCommandType.BUILDING,
594
- site,
595
- building,
596
- error ?: ""
597
- )
598
- error?.let {
599
- Plog.e("Error showing building: $it")
600
- return@showBuildingInternal
601
- }
602
- Plog.i("Building shown")
603
- }
604
- }
605
-
606
- private fun showSite(ptrMapWidgetFragment: PTRMapWidgetFragment, site: String) {
607
- ptrMapWidgetFragment.showSite(site) showSiteInternal@{ error ->
608
- this@PTRMapWidgetManager.mapWidgetDidEndLoading(
609
- PTRMapWidgetCommandType.SITE,
610
- site,
611
- error ?: ""
612
- )
613
- error?.let {
614
- Plog.e("Error showing site: $it")
615
- return@showSiteInternal
616
402
  }
617
- Plog.i("Site shown")
618
403
  }
619
404
  }
620
405
 
621
406
  // region Show path
622
407
 
623
408
  private fun waitForPathManager(theSite: Site): Boolean {
624
- val pathManager = Pointr.getPointr()?.pathManager ?: return false
409
+ val wayfindingManager = Pointr.getPointr()?.wayfindingManager ?: return false
625
410
  val semaphore = Semaphore(0)
626
- val listener = object : PathManager.Listener {
627
- override fun onPathManagerReadyForSite(site: Site) {
411
+ val listener = object : WayfindingManager.Listener {
412
+ override fun onWayfindingManagerReadyForSite(site: Site) {
628
413
  if (site != theSite) return
629
414
  semaphore.release()
630
415
  }
631
416
  }
632
- pathManager.addListener(listener)
633
- if (!pathManager.isReadyForSite(theSite)) {
417
+ wayfindingManager.addListener(listener)
418
+ if (!wayfindingManager.isReadyForSite(theSite)) {
634
419
  semaphore.tryAcquire(15, java.util.concurrent.TimeUnit.SECONDS)
635
420
  }
636
- pathManager.removeListener(listener)
637
- return pathManager.isReadyForSite(theSite)
421
+ wayfindingManager.removeListener(listener)
422
+ return wayfindingManager.isReadyForSite(theSite)
638
423
  }
639
424
 
640
425
  private fun waitForSiteData(theSite: Site): Boolean {
@@ -661,7 +446,7 @@ class PTRMapWidgetManager(private val reactContext: ReactApplicationContext) :
661
446
  return Pointr.getPointr()?.poiManager?.hasContentForSite(theSite) == true
662
447
  }
663
448
 
664
- private fun getSite(site: String): Site? {
449
+ private fun getSite(siteExternalId: String): Site? {
665
450
  val siteManager = Pointr.getPointr()?.siteManager ?: return null
666
451
  val semaphore = Semaphore(0)
667
452
  val listener = object : SiteManager.Listener {
@@ -670,11 +455,11 @@ class PTRMapWidgetManager(private val reactContext: ReactApplicationContext) :
670
455
  }
671
456
  }
672
457
  siteManager.addListener(listener)
673
- if (siteManager.getSites().isEmpty()) {
458
+ if (siteManager.sites.isEmpty()) {
674
459
  semaphore.tryAcquire(10, java.util.concurrent.TimeUnit.SECONDS)
675
460
  }
676
461
  siteManager.removeListener(listener)
677
- return siteManager.getSite(site)
462
+ return siteManager.getSiteByExternalIdentifier(siteExternalId)
678
463
  }
679
464
 
680
465
  // endregion
@@ -748,7 +533,6 @@ class PTRMapWidgetManager(private val reactContext: ReactApplicationContext) :
748
533
  markMyCarDetailsEvent: MarkMyCarDetailsEvent
749
534
  ) {
750
535
  super.onMarkMyCarDetailsEvent(markMyCarSheet, markMyCarDetailsEvent)
751
- this.markMyCarButtonSheet = markMyCarSheet
752
536
  Plog.i("Mark my car details event: $markMyCarDetailsEvent")
753
537
  }
754
538