use of com.getcapacitor.PluginMethod in project capacitor-music-controls-plugin-new by gokadzev.
the class CapacitorMusicControls method updateState.
@PluginMethod()
public void updateState(PluginCall call) {
JSObject params = call.getData();
try {
final boolean isPlaying = params.getBoolean("isPlaying");
final long elapsed = params.getLong("elapsed");
this.notification.updateIsPlaying(isPlaying);
if (isPlaying)
this.setMediaPlaybackState(PlaybackStateCompat.STATE_PLAYING, elapsed);
else
this.setMediaPlaybackState(PlaybackStateCompat.STATE_PAUSED, elapsed);
call.resolve();
} catch (JSONException e) {
call.reject("error in updateState");
}
}
use of com.getcapacitor.PluginMethod in project capacitor-music-controls-plugin-new by gokadzev.
the class CapacitorMusicControls method updateMetadata.
@PluginMethod()
public void updateMetadata(PluginCall call) {
JSObject options = call.getData();
this.updateMetadata(options);
call.resolve();
}
use of com.getcapacitor.PluginMethod in project portals-ecommerce-demo by ionic-team.
the class ShopAPIPlugin method getUserDetails.
@PluginMethod
public void getUserDetails(PluginCall call) {
try {
User user = dataService.getUser();
String userJson = new Gson().toJson(user);
JSObject userJSObject = JSObject.fromJSONObject(new JSONObject(userJson));
call.resolve(userJSObject);
} catch (JSONException e) {
call.reject("error decoding user object");
}
}
use of com.getcapacitor.PluginMethod in project portals-ecommerce-demo by ionic-team.
the class ShopAPIPlugin method getCart.
@PluginMethod
public void getCart(PluginCall call) {
try {
Cart cart = EcommerceApp.getInstance().getShoppingCart().getCart();
String cartJson = new Gson().toJson(cart);
JSObject cartJSObject = JSObject.fromJSONObject(new JSONObject(cartJson));
call.resolve(cartJSObject);
} catch (JSONException e) {
call.reject("error decoding cart object");
}
}
use of com.getcapacitor.PluginMethod in project capacitor-calendar by Fir3st.
the class CapacitorCalendar method openCalendar.
@PluginMethod()
public void openCalendar(PluginCall call) {
if (!hasRequiredPermissions()) {
requestPermissionsCalendar(call);
} else {
try {
JSObject data = call.getData();
final Long millis = data.has("date") ? data.getLong("date") : new Date().getTime();
Uri.Builder builder = CalendarContract.CONTENT_URI.buildUpon();
builder.appendPath("time");
ContentUris.appendId(builder, millis);
final Intent intent = new Intent(Intent.ACTION_VIEW).setData(builder.build());
this.startActivityForResult(call, intent, RESULT_CODE_OPENCAL);
call.success();
} catch (JSONException e) {
System.err.println("Exception: " + e.getMessage());
call.error(e.getMessage());
}
}
}
Aggregations