Search in sources :

Example 1 with JSArray

use of com.getcapacitor.JSArray in project google-maps by capacitor-community.

the class CapacitorGoogleMaps method addPolyline.

@PluginMethod()
public void addPolyline(final PluginCall call) {
    final JSArray points = call.getArray("points", new JSArray());
    getBridge().executeOnMainThread(new Runnable() {

        @Override
        public void run() {
            PolylineOptions polylineOptions = new PolylineOptions();
            for (int i = 0; i < points.length(); i++) {
                try {
                    JSONObject point = points.getJSONObject(i);
                    LatLng latLng = new LatLng(point.getDouble("latitude"), point.getDouble("longitude"));
                    polylineOptions.add(latLng);
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }
            googleMap.addPolyline(polylineOptions);
            call.resolve();
        }
    });
}
Also used : JSONObject(org.json.JSONObject) JSArray(com.getcapacitor.JSArray) JSONException(org.json.JSONException) LatLng(com.google.android.libraries.maps.model.LatLng) PolylineOptions(com.google.android.libraries.maps.model.PolylineOptions) PluginMethod(com.getcapacitor.PluginMethod)

Example 2 with JSArray

use of com.getcapacitor.JSArray in project capacitor-file-picker by robingenz.

the class FilePickerPlugin method pickFiles.

@PluginMethod
public void pickFiles(PluginCall call) {
    JSArray types = call.getArray("types", null);
    boolean multiple = call.getBoolean("multiple", false);
    String[] parsedTypes = parseTypesOption(types);
    Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    intent.setType("*/*");
    intent.addCategory(Intent.CATEGORY_OPENABLE);
    intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, multiple);
    if (multiple == false) {
        if (parsedTypes == null || parsedTypes.length < 1) {
            intent.putExtra(Intent.EXTRA_MIME_TYPES, "*/*");
        } else {
            intent.putExtra(Intent.EXTRA_MIME_TYPES, parsedTypes);
        }
    }
    intent = Intent.createChooser(intent, "Choose a file");
    startActivityForResult(call, intent, "pickFilesResult");
}
Also used : JSArray(com.getcapacitor.JSArray) Intent(android.content.Intent) PluginMethod(com.getcapacitor.PluginMethod)

Example 3 with JSArray

use of com.getcapacitor.JSArray in project capacitor-firebase by robingenz.

the class AppleAuthProviderHandler method applySignInConfig.

private void applySignInConfig(PluginCall call, OAuthProvider.Builder provider) {
    JSArray customParameters = call.getArray("customParameters");
    if (customParameters != null) {
        try {
            List<Object> customParametersList = customParameters.toList();
            for (int i = 0; i < customParametersList.size(); i++) {
                JSObject customParameter = JSObject.fromJSONObject((JSONObject) customParametersList.get(i));
                String key = customParameter.getString("key");
                String value = customParameter.getString("value");
                if (key == null || value == null) {
                    continue;
                }
                provider.addCustomParameter(key, value);
            }
        } catch (JSONException exception) {
            Log.e(FirebaseAuthenticationPlugin.TAG, "applySignInConfig failed.", exception);
        }
    }
}
Also used : JSArray(com.getcapacitor.JSArray) JSObject(com.getcapacitor.JSObject) JSONException(org.json.JSONException) JSONObject(org.json.JSONObject) JSObject(com.getcapacitor.JSObject)

Example 4 with JSArray

use of com.getcapacitor.JSArray in project capacitor-updater by Cap-go.

the class CapacitorUpdaterPlugin method list.

@PluginMethod
public void list(PluginCall call) {
    ArrayList<String> res = implementation.list();
    JSObject ret = new JSObject();
    ret.put("versions", new JSArray(res));
    call.resolve(ret);
}
Also used : JSArray(com.getcapacitor.JSArray) JSObject(com.getcapacitor.JSObject) PluginMethod(com.getcapacitor.PluginMethod)

Example 5 with JSArray

use of com.getcapacitor.JSArray in project capacitor-plugins by ionic-team.

the class LocalNotification method buildLocalNotificationPendingList.

public static JSObject buildLocalNotificationPendingList(List<LocalNotification> notifications) {
    JSObject result = new JSObject();
    JSArray jsArray = new JSArray();
    for (LocalNotification notification : notifications) {
        JSObject jsNotification = new JSObject();
        jsNotification.put("id", notification.getId());
        jsNotification.put("title", notification.getTitle());
        jsNotification.put("body", notification.getBody());
        LocalNotificationSchedule schedule = notification.getSchedule();
        if (schedule != null) {
            JSObject jsSchedule = new JSObject();
            jsSchedule.put("at", schedule.getAt());
            jsSchedule.put("every", schedule.getEvery());
            jsSchedule.put("count", schedule.getCount());
            jsSchedule.put("on", schedule.getOnObj());
            jsSchedule.put("repeats", schedule.isRepeating());
            jsNotification.put("schedule", jsSchedule);
        }
        jsNotification.put("extra", notification.getExtra());
        jsArray.put(jsNotification);
    }
    result.put("notifications", jsArray);
    return result;
}
Also used : JSArray(com.getcapacitor.JSArray) JSObject(com.getcapacitor.JSObject)

Aggregations

JSArray (com.getcapacitor.JSArray)20 JSObject (com.getcapacitor.JSObject)14 PluginMethod (com.getcapacitor.PluginMethod)12 JSONException (org.json.JSONException)10 JSONObject (org.json.JSONObject)7 Intent (android.content.Intent)3 ArrayList (java.util.ArrayList)3 NotificationChannel (android.app.NotificationChannel)2 LatLng (com.google.android.libraries.maps.model.LatLng)2 Notification (android.app.Notification)1 Uri (android.net.Uri)1 Bundle (android.os.Bundle)1 Parcelable (android.os.Parcelable)1 StatusBarNotification (android.service.notification.StatusBarNotification)1 ActivityCallback (com.getcapacitor.annotation.ActivityCallback)1 PolygonOptions (com.google.android.libraries.maps.model.PolygonOptions)1 PolylineOptions (com.google.android.libraries.maps.model.PolylineOptions)1 ParseException (java.text.ParseException)1 Executor (java.util.concurrent.Executor)1 JSONArray (org.json.JSONArray)1