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();
}
});
}
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");
}
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);
}
}
}
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);
}
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;
}
Aggregations