Search in sources :

Example 31 with PluginMethod

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");
    }
}
Also used : JSObject(com.getcapacitor.JSObject) JSONException(org.json.JSONException) PluginMethod(com.getcapacitor.PluginMethod)

Example 32 with PluginMethod

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();
}
Also used : JSObject(com.getcapacitor.JSObject) PluginMethod(com.getcapacitor.PluginMethod)

Example 33 with PluginMethod

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");
    }
}
Also used : User(io.ionic.demo.ecommerce.data.model.User) JSONObject(org.json.JSONObject) Gson(com.google.gson.Gson) JSObject(com.getcapacitor.JSObject) JSONException(org.json.JSONException) PluginMethod(com.getcapacitor.PluginMethod)

Example 34 with PluginMethod

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");
    }
}
Also used : JSONObject(org.json.JSONObject) Gson(com.google.gson.Gson) JSObject(com.getcapacitor.JSObject) JSONException(org.json.JSONException) Cart(io.ionic.demo.ecommerce.data.model.Cart) ShoppingCart(io.ionic.demo.ecommerce.data.ShoppingCart) PluginMethod(com.getcapacitor.PluginMethod)

Example 35 with PluginMethod

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());
        }
    }
}
Also used : JSObject(com.getcapacitor.JSObject) JSONException(org.json.JSONException) Intent(android.content.Intent) Uri(android.net.Uri) Date(java.util.Date) 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