use of io.radar.sdk.RadarTripOptions in project flutter-radar by radarlabs.
the class RadarFlutterPlugin method startTrip.
public void startTrip(MethodCall call, Result result) throws JSONException {
HashMap tripOptionsMap = (HashMap) call.arguments;
JSONObject tripOptionsJson = jsonForMap(tripOptionsMap);
RadarTripOptions tripOptions = RadarTripOptions.fromJson(tripOptionsJson);
Radar.startTrip(tripOptions);
result.success(true);
}
use of io.radar.sdk.RadarTripOptions in project capacitor-radar by radarlabs.
the class RadarPlugin method updateTrip.
@PluginMethod
public void updateTrip(PluginCall call) {
JSObject optionsObj = call.getObject("options");
JSONObject optionsJson = RadarPlugin.jsonObjectForJSObject(optionsObj);
if (optionsJson == null) {
call.reject("options is required");
return;
}
RadarTripOptions options = RadarTripOptions.fromJson(optionsJson);
RadarTrip.RadarTripStatus status = RadarTrip.RadarTripStatus.UNKNOWN;
if (call.hasOption("status")) {
String statusStr = call.getString("status");
if (statusStr.equals("STARTED") || statusStr.equals("started")) {
status = RadarTrip.RadarTripStatus.STARTED;
} else if (statusStr.equals("APPROACHING") || statusStr.equals("approaching")) {
status = RadarTrip.RadarTripStatus.APPROACHING;
} else if (statusStr.equals("ARRIVED") || statusStr.equals("arrived")) {
status = RadarTrip.RadarTripStatus.ARRIVED;
} else if (statusStr.equals("COMPLETED") || statusStr.equals("completed")) {
status = RadarTrip.RadarTripStatus.COMPLETED;
} else if (statusStr.equals("CANCELED") || statusStr.equals("canceled")) {
status = RadarTrip.RadarTripStatus.CANCELED;
}
}
Radar.updateTrip(options, status, new Radar.RadarTripCallback() {
@Override
public void onComplete(@NonNull Radar.RadarStatus status, @Nullable RadarTrip trip, @Nullable RadarEvent[] events) {
JSObject ret = new JSObject();
ret.put("status", status.toString());
if (trip != null) {
ret.put("trip", RadarPlugin.jsObjectForJSONObject(trip.toJson()));
}
if (events != null) {
ret.put("events", RadarPlugin.jsArrayForArray(events));
}
call.resolve(ret);
}
});
}
use of io.radar.sdk.RadarTripOptions in project capacitor-radar by radarlabs.
the class RadarPlugin method startTrip.
@PluginMethod()
public void startTrip(PluginCall call) {
JSObject optionsObj = call.getObject("options");
JSONObject optionsJson = RadarPlugin.jsonObjectForJSObject(optionsObj);
if (optionsJson == null) {
call.reject("options is required");
return;
}
RadarTripOptions options = RadarTripOptions.fromJson(optionsJson);
Radar.startTrip(options, new Radar.RadarTripCallback() {
@Override
public void onComplete(@NonNull Radar.RadarStatus status, @Nullable RadarTrip trip, @Nullable RadarEvent[] events) {
JSObject ret = new JSObject();
ret.put("status", status.toString());
if (trip != null) {
ret.put("trip", RadarPlugin.jsObjectForJSONObject(trip.toJson()));
}
if (events != null) {
ret.put("events", RadarPlugin.jsArrayForArray(events));
}
call.resolve(ret);
}
});
}
use of io.radar.sdk.RadarTripOptions in project flutter-radar by radarlabs.
the class RadarFlutterPlugin method getTripOptions.
public void getTripOptions(Result result) {
RadarTripOptions tripOptions = Radar.getTripOptions();
HashMap<String, Object> map = new Gson().fromJson(tripOptions.toJson().toString(), HashMap.class);
result.success(map);
}
Aggregations