Skip to content

Commit a3f3d1a

Browse files
refactor: refactor setDestination on Android
1 parent 8942d26 commit a3f3d1a

File tree

1 file changed

+3
-28
lines changed

1 file changed

+3
-28
lines changed

android/src/main/java/com/google/android/react/navsdk/NavModule.java

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -407,34 +407,9 @@ public void setDestination(
407407
ReadableMap waypoint,
408408
@Nullable ReadableMap routingOptions,
409409
@Nullable ReadableMap displayOptions) {
410-
pendingRoute = null; // reset pendingRoute.
411-
mWaypoints.clear(); // reset waypoints
412-
createWaypoint(waypoint.toHashMap());
413-
414-
if (routingOptions != null) {
415-
if (displayOptions != null) {
416-
pendingRoute =
417-
mNavigator.setDestination(
418-
mWaypoints.get(0),
419-
ObjectTranslationUtil.getRoutingOptionsFromMap(routingOptions.toHashMap()),
420-
ObjectTranslationUtil.getDisplayOptionsFromMap(displayOptions.toHashMap()));
421-
} else {
422-
pendingRoute =
423-
mNavigator.setDestination(
424-
mWaypoints.get(0),
425-
ObjectTranslationUtil.getRoutingOptionsFromMap(routingOptions.toHashMap()));
426-
}
427-
} else {
428-
pendingRoute = mNavigator.setDestination(mWaypoints.get(0));
429-
}
430-
431-
setOnResultListener(
432-
new IRouteStatusResult() {
433-
@Override
434-
public void onResult(Navigator.RouteStatus code) {
435-
sendCommandToReactNative("onRouteStatusResult", code.toString());
436-
}
437-
});
410+
WritableArray array = new WritableNativeArray();
411+
array.pushMap(waypoint);
412+
setDestinations(array, routingOptions, displayOptions);
438413
}
439414

440415
@ReactMethod

0 commit comments

Comments
 (0)