Search in sources :

Example 66 with PluginMethod

use of com.getcapacitor.PluginMethod in project capacitor-calendar by Fir3st.

the class CapacitorCalendar method getAvailableCalendars.

@PluginMethod()
public void getAvailableCalendars(PluginCall call) {
    if (!hasRequiredPermissions()) {
        requestPermissionsCalendar(call);
    } else {
        List<Calendar> availableCalendars = getAvailableCalendarsList();
        JSObject ret = new JSObject();
        ret.put("availableCalendars", new Gson().toJson(availableCalendars));
        call.success(ret);
    }
}
Also used : JSObject(com.getcapacitor.JSObject) Gson(com.google.gson.Gson) PluginMethod(com.getcapacitor.PluginMethod)

Example 67 with PluginMethod

use of com.getcapacitor.PluginMethod in project capacitor-radar by radarlabs.

the class RadarPlugin method startTrackingCustom.

@PluginMethod()
public void startTrackingCustom(PluginCall call) {
    JSObject trackingOptionsObj = call.getObject("options");
    JSONObject trackingOptionsJson = RadarPlugin.jsonObjectForJSObject(trackingOptionsObj);
    RadarTrackingOptions trackingOptions = RadarTrackingOptions.fromJson(trackingOptionsJson);
    Radar.startTracking(trackingOptions);
    call.resolve();
}
Also used : JSONObject(org.json.JSONObject) RadarTrackingOptions(io.radar.sdk.RadarTrackingOptions) JSObject(com.getcapacitor.JSObject) PluginMethod(com.getcapacitor.PluginMethod)

Example 68 with PluginMethod

use of com.getcapacitor.PluginMethod in project capacitor-radar by radarlabs.

the class RadarPlugin method searchGeofences.

@PluginMethod()
public void searchGeofences(final PluginCall call) throws JSONException {
    Radar.RadarSearchGeofencesCallback callback = new Radar.RadarSearchGeofencesCallback() {

        @Override
        public void onComplete(@NotNull Radar.RadarStatus status, @Nullable Location location, @Nullable RadarGeofence[] geofences) {
            if (status == Radar.RadarStatus.SUCCESS && location != null && geofences != null) {
                JSObject ret = new JSObject();
                ret.put("status", status.toString());
                ret.put("location", RadarPlugin.jsObjectForJSONObject(Radar.jsonForLocation(location)));
                ret.put("geofences", RadarPlugin.jsArrayForJSONArray(RadarGeofence.toJson(geofences)));
                call.resolve(ret);
            } else {
                call.reject(status.toString());
            }
        }
    };
    int radius = call.getInt("radius", 1000);
    String[] tags = RadarPlugin.stringArrayForJSArray(call.getArray("tags"));
    int limit = call.getInt("limit", 10);
    if (call.hasOption("near")) {
        JSObject nearObj = call.getObject("near");
        double latitude = nearObj.getDouble("latitude");
        double longitude = nearObj.getDouble("longitude");
        Location near = new Location("RadarSDK");
        near.setLatitude(latitude);
        near.setLongitude(longitude);
        near.setAccuracy(5);
        Radar.searchGeofences(near, radius, tags, null, limit, callback);
    } else {
        Radar.searchGeofences(radius, tags, null, limit, callback);
    }
}
Also used : Radar(io.radar.sdk.Radar) JSObject(com.getcapacitor.JSObject) NotNull(org.jetbrains.annotations.NotNull) Nullable(org.jetbrains.annotations.Nullable) Location(android.location.Location) PluginMethod(com.getcapacitor.PluginMethod)

Example 69 with PluginMethod

use of com.getcapacitor.PluginMethod in project capacitor-radar by radarlabs.

the class RadarPlugin method searchPlaces.

@PluginMethod()
public void searchPlaces(final PluginCall call) throws JSONException {
    Radar.RadarSearchPlacesCallback callback = new Radar.RadarSearchPlacesCallback() {

        @Override
        public void onComplete(@NotNull Radar.RadarStatus status, @Nullable Location location, @Nullable RadarPlace[] places) {
            if (status == Radar.RadarStatus.SUCCESS && location != null && places != null) {
                JSObject ret = new JSObject();
                ret.put("status", status.toString());
                ret.put("location", RadarPlugin.jsObjectForJSONObject(Radar.jsonForLocation(location)));
                ret.put("places", RadarPlugin.jsArrayForJSONArray(RadarPlace.toJson(places)));
                call.resolve(ret);
            } else {
                call.reject(status.toString());
            }
        }
    };
    int radius = call.getInt("radius", 1000);
    String[] chains = RadarPlugin.stringArrayForJSArray(call.getArray("chains"));
    String[] categories = RadarPlugin.stringArrayForJSArray(call.getArray("categories"));
    String[] groups = RadarPlugin.stringArrayForJSArray(call.getArray("groups"));
    int limit = call.getInt("limit", 10);
    if (call.hasOption("near")) {
        JSObject nearObj = call.getObject("near");
        double latitude = nearObj.getDouble("latitude");
        double longitude = nearObj.getDouble("longitude");
        Location near = new Location("RadarSDK");
        near.setLatitude(latitude);
        near.setLongitude(longitude);
        near.setAccuracy(5);
        Radar.searchPlaces(near, radius, chains, categories, groups, limit, callback);
    } else {
        Radar.searchPlaces(radius, chains, categories, groups, limit, callback);
    }
}
Also used : Radar(io.radar.sdk.Radar) JSObject(com.getcapacitor.JSObject) NotNull(org.jetbrains.annotations.NotNull) Nullable(org.jetbrains.annotations.Nullable) Location(android.location.Location) PluginMethod(com.getcapacitor.PluginMethod)

Example 70 with PluginMethod

use of com.getcapacitor.PluginMethod in project capacitor-radar by radarlabs.

the class RadarPlugin method autocomplete.

@PluginMethod()
public void autocomplete(final PluginCall call) throws JSONException {
    if (!call.hasOption("query")) {
        call.reject("query is required");
        return;
    }
    String query = call.getString("query");
    if (!call.hasOption("near")) {
        call.reject("near is required");
        return;
    }
    JSObject nearObj = call.getObject("near");
    double latitude = nearObj.getDouble("latitude");
    double longitude = nearObj.getDouble("longitude");
    Location near = new Location("RadarSDK");
    near.setLatitude(latitude);
    near.setLongitude(longitude);
    near.setAccuracy(5);
    int limit = call.getInt("limit", 10);
    Radar.autocomplete(query, near, limit, new Radar.RadarGeocodeCallback() {

        @Override
        public void onComplete(@NotNull Radar.RadarStatus status, @Nullable RadarAddress[] addresses) {
            if (status == Radar.RadarStatus.SUCCESS && addresses != null) {
                JSObject ret = new JSObject();
                ret.put("status", status.toString());
                ret.put("addresses", RadarPlugin.jsArrayForJSONArray(RadarAddress.toJson(addresses)));
                call.resolve(ret);
            } else {
                call.reject(status.toString());
            }
        }
    });
}
Also used : Radar(io.radar.sdk.Radar) JSObject(com.getcapacitor.JSObject) RadarAddress(io.radar.sdk.model.RadarAddress) Location(android.location.Location) PluginMethod(com.getcapacitor.PluginMethod)

Aggregations

PluginMethod (com.getcapacitor.PluginMethod)120 JSObject (com.getcapacitor.JSObject)93 JSONException (org.json.JSONException)18 MyRunnable (com.jeep.plugin.capacitor.capacitorvideoplayer.Notifications.MyRunnable)13 JSONObject (org.json.JSONObject)13 JSArray (com.getcapacitor.JSArray)12 Radar (io.radar.sdk.Radar)11 Location (android.location.Location)8 Intent (android.content.Intent)7 NotNull (org.jetbrains.annotations.NotNull)6 Nullable (org.jetbrains.annotations.Nullable)6 Uri (android.net.Uri)5 LatLng (com.google.android.libraries.maps.model.LatLng)5 GenericAd (admob.plus.core.GenericAd)4 GoogleSignInAccount (com.google.android.gms.auth.api.signin.GoogleSignInAccount)4 Gson (com.google.gson.Gson)4 PackageManager (android.content.pm.PackageManager)3 AppCompatActivity (androidx.appcompat.app.AppCompatActivity)3 User (io.ionic.demo.ecommerce.data.model.User)3 Context (android.content.Context)2