Java Code Examples for com.getcapacitor.PluginCall#resolve()
The following examples show how to use
com.getcapacitor.PluginCall#resolve() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Geolocation.java From OsmGo with MIT License | 6 votes |
@Override protected void handleRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { super.handleRequestPermissionsResult(requestCode, permissions, grantResults); PluginCall savedCall = getSavedCall(); if (savedCall == null) { return; } for(int result : grantResults) { if (result == PackageManager.PERMISSION_DENIED) { savedCall.error("User denied location permission"); return; } } if (savedCall.getMethodName().equals("getCurrentPosition")) { sendLocation(savedCall); } else if (savedCall.getMethodName().equals("watchPosition")) { startWatch(savedCall); } else { savedCall.resolve(); savedCall.release(bridge); } }
Example 2
Source File: StatusBar.java From OsmGo with MIT License | 6 votes |
@PluginMethod() public void getInfo(final PluginCall call) { View decorView = getActivity().getWindow().getDecorView(); Window window = getActivity().getWindow(); String style; if ((decorView.getSystemUiVisibility() & View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR) == View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR) { style = "LIGHT"; } else { style = "DARK"; } JSObject data = new JSObject(); data.put("visible", (decorView.getSystemUiVisibility() & View.SYSTEM_UI_FLAG_FULLSCREEN) != View.SYSTEM_UI_FLAG_FULLSCREEN); data.put("style", style); data.put("color", String.format("#%06X", (0xFFFFFF & window.getStatusBarColor()))); call.resolve(data); }
Example 3
Source File: OAuth2ClientPlugin.java From capacitor-oauth2 with MIT License | 5 votes |
void createJsObjAndResolve(PluginCall call, String jsonStr) { try { JSObject json = new JSObject(jsonStr); call.resolve(json); } catch (JSONException e) { call.reject(ERR_GENERAL, e); } }
Example 4
Source File: DownloaderPlugin.java From capacitor-downloader with MIT License | 5 votes |
@PluginMethod() public void getPath(PluginCall call) { String id = call.getString("id"); DownloadData data = downloadsData.get(id); JSObject jsObject = new JSObject(); if (data != null) { jsObject.put("value", data.getPath()); } call.resolve(jsObject); }
Example 5
Source File: DownloaderPlugin.java From capacitor-downloader with MIT License | 5 votes |
@PluginMethod() public void getStatus(PluginCall call) { String id = call.getString("id"); DownloadData data = downloadsData.get(id); JSObject jsObject = new JSObject(); if (data != null) { jsObject.put("value", data.getStatus()); } call.resolve(jsObject); }
Example 6
Source File: Permissions.java From OsmGo with MIT License | 5 votes |
private void checkPerm(String perm, PluginCall call) { JSObject ret = new JSObject(); if (ContextCompat.checkSelfPermission(getContext(), perm) == PackageManager.PERMISSION_DENIED) { ret.put("state", "denied"); } else if (ContextCompat.checkSelfPermission(getContext(), perm) == PackageManager.PERMISSION_GRANTED) { ret.put("state", "granted"); } else { ret.put("state", "prompt"); } call.resolve(ret); }
Example 7
Source File: Camera.java From OsmGo with MIT License | 5 votes |
private void returnDataUrl(PluginCall call, ExifWrapper exif, ByteArrayOutputStream bitmapOutputStream) { byte[] byteArray = bitmapOutputStream.toByteArray(); String encoded = Base64.encodeToString(byteArray, Base64.NO_WRAP); JSObject data = new JSObject(); data.put("format", "jpeg"); data.put("dataUrl", "data:image/jpeg;base64," + encoded); data.put("exif", exif.toJson()); call.resolve(data); }
Example 8
Source File: Camera.java From OsmGo with MIT License | 5 votes |
private void returnBase64(PluginCall call, ExifWrapper exif, ByteArrayOutputStream bitmapOutputStream) { byte[] byteArray = bitmapOutputStream.toByteArray(); String encoded = Base64.encodeToString(byteArray, Base64.NO_WRAP); JSObject data = new JSObject(); data.put("format", "jpeg"); data.put("base64String", encoded); data.put("exif", exif.toJson()); call.resolve(data); }
Example 9
Source File: Storage.java From OsmGo with MIT License | 5 votes |
@PluginMethod() public void get(PluginCall call) { String key = call.getString("key"); if (key == null) { call.reject("Must provide key"); return; } String value = prefs.getString(key, null); JSObject ret = new JSObject(); ret.put("value", value == null ? JSObject.NULL : value); call.resolve(ret); }
Example 10
Source File: Storage.java From OsmGo with MIT License | 5 votes |
@PluginMethod() public void set(PluginCall call) { String key = call.getString("key"); if (key == null) { call.reject("Must provide key"); return; } String value = call.getString("value"); editor.putString(key, value); editor.apply(); call.resolve(); }
Example 11
Source File: Storage.java From OsmGo with MIT License | 5 votes |
@PluginMethod() public void remove(PluginCall call) { String key = call.getString("key"); if (key == null) { call.reject("Must provide key"); return; } editor.remove(key); editor.apply(); call.resolve(); }
Example 12
Source File: DownloaderPlugin.java From capacitor-downloader with MIT License | 4 votes |
@PluginMethod() public static void setTimeout(PluginCall call){ timeout = call.getInt("timeout",60); call.resolve(); }
Example 13
Source File: DownloaderPlugin.java From capacitor-downloader with MIT License | 4 votes |
@PluginMethod() public void createDownload(PluginCall call) { Manager manager = Manager.getInstance(); String url = call.getString("url"); String query = call.getString("query"); JSObject headers = call.getObject("headers"); String path = call.getString("path"); String fileName = call.getString("fileName"); Request request = new Request(url); request.setTimeout(timeout); DownloadData data = new DownloadData(); if (query != null) { // TODO } if (headers != null) { HashMap<String, String> map = new HashMap<String, String>(); int len = headers.length(); Iterator<String> keys = headers.keys(); for (int i = 0; i < len; i++) { String key = keys.next(); map.put(key, headers.getString(key)); } request.setHeaders(map); } if (path != null) { request.setFilePath(path); data.setPath(path); } if (fileName != null) { request.setFileName(fileName); } String id = manager.create(request); downloadsRequest.put(id, request); JSObject object = new JSObject(); object.put("value", id); downloadsData.put(id, data); call.resolve(object); }
Example 14
Source File: Permissions.java From OsmGo with MIT License | 4 votes |
private void checkNotifications(PluginCall call) { boolean areEnabled = NotificationManagerCompat.from(getContext()).areNotificationsEnabled(); JSObject ret = new JSObject(); ret.put("state", areEnabled ? "granted" : "denied"); call.resolve(ret); }
Example 15
Source File: Permissions.java From OsmGo with MIT License | 4 votes |
private void checkClipboard(PluginCall call) { JSObject ret = new JSObject(); ret.put("state", "granted"); call.resolve(ret); }
Example 16
Source File: Storage.java From OsmGo with MIT License | 4 votes |
@PluginMethod() public void clear(PluginCall call) { editor.clear(); editor.apply(); call.resolve(); }