From a3f3d1a475c66022da9bc6bb4fefcdede1b74ed7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20V=C3=A4limaa?= Date: Wed, 4 Dec 2024 13:31:48 +0800 Subject: [PATCH] refactor: refactor setDestination on Android --- .../android/react/navsdk/NavModule.java | 31 ++----------------- 1 file changed, 3 insertions(+), 28 deletions(-) diff --git a/android/src/main/java/com/google/android/react/navsdk/NavModule.java b/android/src/main/java/com/google/android/react/navsdk/NavModule.java index 4515288..875b8f3 100644 --- a/android/src/main/java/com/google/android/react/navsdk/NavModule.java +++ b/android/src/main/java/com/google/android/react/navsdk/NavModule.java @@ -407,34 +407,9 @@ public void setDestination( ReadableMap waypoint, @Nullable ReadableMap routingOptions, @Nullable ReadableMap displayOptions) { - pendingRoute = null; // reset pendingRoute. - mWaypoints.clear(); // reset waypoints - createWaypoint(waypoint.toHashMap()); - - if (routingOptions != null) { - if (displayOptions != null) { - pendingRoute = - mNavigator.setDestination( - mWaypoints.get(0), - ObjectTranslationUtil.getRoutingOptionsFromMap(routingOptions.toHashMap()), - ObjectTranslationUtil.getDisplayOptionsFromMap(displayOptions.toHashMap())); - } else { - pendingRoute = - mNavigator.setDestination( - mWaypoints.get(0), - ObjectTranslationUtil.getRoutingOptionsFromMap(routingOptions.toHashMap())); - } - } else { - pendingRoute = mNavigator.setDestination(mWaypoints.get(0)); - } - - setOnResultListener( - new IRouteStatusResult() { - @Override - public void onResult(Navigator.RouteStatus code) { - sendCommandToReactNative("onRouteStatusResult", code.toString()); - } - }); + WritableArray array = new WritableNativeArray(); + array.pushMap(waypoint); + setDestinations(array, routingOptions, displayOptions); } @ReactMethod