Search in sources :

Example 6 with PluginMethod

use of com.getcapacitor.PluginMethod in project capacitor-video-player by jepiqueau.

the class CapacitorVideoPlayerPlugin method echo.

@PluginMethod
public void echo(PluginCall call) {
    String value = call.getString("value");
    JSObject ret = new JSObject();
    ret.put("value", implementation.echo(value));
    call.resolve(ret);
}
Also used : JSObject(com.getcapacitor.JSObject) PluginMethod(com.getcapacitor.PluginMethod)

Example 7 with PluginMethod

use of com.getcapacitor.PluginMethod in project capacitor-video-player by jepiqueau.

the class CapacitorVideoPlayerPlugin method play.

@PluginMethod
public void play(final PluginCall call) {
    this.call = call;
    JSObject ret = new JSObject();
    ret.put("method", "play");
    String playerId = call.getString("playerId");
    if (playerId == null) {
        ret.put("result", false);
        ret.put("message", "Must provide a PlayerId");
        call.resolve(ret);
        return;
    }
    if ("fullscreen".equals(mode) && fsPlayerId.equals(playerId)) {
        bridge.getActivity().runOnUiThread(new Runnable() {

            @Override
            public void run() {
                JSObject ret = new JSObject();
                ret.put("method", "play");
                if (fsFragment != null) {
                    fsFragment.play();
                    boolean playing = fsFragment.isPlaying();
                    ret.put("result", true);
                    ret.put("value", true);
                    call.resolve(ret);
                } else {
                    ret.put("result", false);
                    ret.put("message", "Fullscreen fragment is not defined");
                    call.resolve(ret);
                }
            }
        });
    } else {
        ret.put("result", false);
        ret.put("message", "player is not defined");
        call.resolve(ret);
    }
}
Also used : MyRunnable(com.jeep.plugin.capacitor.capacitorvideoplayer.Notifications.MyRunnable) JSObject(com.getcapacitor.JSObject) PluginMethod(com.getcapacitor.PluginMethod)

Example 8 with PluginMethod

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

the class WebView method persistServerBasePath.

@PluginMethod
public void persistServerBasePath(PluginCall call) {
    String path = bridge.getServerBasePath();
    SharedPreferences prefs = getContext().getSharedPreferences(WEBVIEW_PREFS_NAME, Activity.MODE_PRIVATE);
    SharedPreferences.Editor editor = prefs.edit();
    editor.putString(CAP_SERVER_PATH, path);
    editor.apply();
    call.resolve();
}
Also used : SharedPreferences(android.content.SharedPreferences) PluginMethod(com.getcapacitor.PluginMethod)

Example 9 with PluginMethod

use of com.getcapacitor.PluginMethod in project capacitor-app-update by robingenz.

the class AppUpdatePlugin method getAppUpdateInfo.

@PluginMethod
public void getAppUpdateInfo(PluginCall call) {
    Task<AppUpdateInfo> appUpdateInfoTask = this.appUpdateManager.getAppUpdateInfo();
    appUpdateInfoTask.addOnSuccessListener(appUpdateInfo -> {
        this.appUpdateInfo = appUpdateInfo;
        PackageInfo pInfo;
        try {
            pInfo = this.getPackageInfo();
        } catch (PackageManager.NameNotFoundException e) {
            call.reject(ERROR_GET_APP_INFO_FAILED);
            return;
        }
        JSObject ret = new JSObject();
        ret.put("currentVersion", String.valueOf(pInfo.versionCode));
        ret.put("availableVersion", String.valueOf(appUpdateInfo.availableVersionCode()));
        ret.put("updateAvailability", appUpdateInfo.updateAvailability());
        ret.put("updatePriority", appUpdateInfo.updatePriority());
        ret.put("immediateUpdateAllowed", appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.IMMEDIATE));
        ret.put("flexibleUpdateAllowed", appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.FLEXIBLE));
        Integer clientVersionStalenessDays = appUpdateInfo.clientVersionStalenessDays();
        if (clientVersionStalenessDays != null) {
            ret.put("clientVersionStalenessDays", clientVersionStalenessDays);
        }
        ret.put("installStatus", appUpdateInfo.installStatus());
        call.resolve(ret);
    });
    appUpdateInfoTask.addOnFailureListener(failure -> {
        String message = failure.getMessage();
        call.reject(message);
    });
}
Also used : PackageManager(android.content.pm.PackageManager) PackageInfo(android.content.pm.PackageInfo) JSObject(com.getcapacitor.JSObject) AppUpdateInfo(com.google.android.play.core.appupdate.AppUpdateInfo) PluginMethod(com.getcapacitor.PluginMethod)

Example 10 with PluginMethod

use of com.getcapacitor.PluginMethod in project capacitor-app-update by robingenz.

the class AppUpdatePlugin method openAppStore.

@PluginMethod
public void openAppStore(PluginCall call) {
    String packageName = this.getContext().getPackageName();
    Intent launchIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + packageName));
    try {
        this.getBridge().getActivity().startActivity(launchIntent);
    } catch (ActivityNotFoundException ex) {
        launchIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + packageName));
        this.getBridge().getActivity().startActivity(launchIntent);
    }
    call.resolve();
}
Also used : ActivityNotFoundException(android.content.ActivityNotFoundException) Intent(android.content.Intent) 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