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