List of usage examples for org.apache.cordova LOG d
public static void d(String tag, String s, Object... args)
From source file:com.capriza.plugins.Notification.java
License:Apache License
/** * Builds and shows a native Android prompt dialog with given title, message, buttons. * This dialog only shows up to 3 buttons. Any labels after that will be ignored. * The following results are returned to the JavaScript callback identified by callbackId: * buttonIndex Index number of the button selected * input1 The text entered in the prompt dialog box * * @param message The message the dialog should display * @param title The title of the dialog * @param buttonLabels A comma separated list of button labels (Up to 3 buttons) * @param callbackContext The callback context. *///w w w . ja v a 2 s .c o m public synchronized void prompt(final String message, final String title, final JSONArray buttonLabels, final String defaultText, final CallbackContext callbackContext) { final CordovaInterface cordova = this.cordova; Runnable runnable = new Runnable() { public void run() { final EditText promptInput = new EditText(cordova.getActivity()); promptInput.setHint(defaultText); AlertDialog.Builder dlg = createDialog(cordova); // new AlertDialog.Builder(cordova.getActivity(), AlertDialog.THEME_DEVICE_DEFAULT_LIGHT); dlg.setMessage(message); dlg.setTitle(title); dlg.setCancelable(true); dlg.setView(promptInput); final JSONObject result = new JSONObject(); // First button if (buttonLabels.length() > 0) { try { dlg.setNegativeButton(buttonLabels.getString(0), new AlertDialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); try { result.put("buttonIndex", 1); result.put("input1", promptInput.getText().toString().trim().length() == 0 ? defaultText : promptInput.getText()); } catch (JSONException e) { LOG.d(LOG_TAG, "JSONException on first button.", e); } callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, result)); } }); } catch (JSONException e) { LOG.d(LOG_TAG, "JSONException on first button."); } } // Second button if (buttonLabels.length() > 1) { try { dlg.setNeutralButton(buttonLabels.getString(1), new AlertDialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); try { result.put("buttonIndex", 2); result.put("input1", promptInput.getText().toString().trim().length() == 0 ? defaultText : promptInput.getText()); } catch (JSONException e) { LOG.d(LOG_TAG, "JSONException on second button.", e); } callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, result)); } }); } catch (JSONException e) { LOG.d(LOG_TAG, "JSONException on second button."); } } // Third button if (buttonLabels.length() > 2) { try { dlg.setPositiveButton(buttonLabels.getString(2), new AlertDialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); try { result.put("buttonIndex", 3); result.put("input1", promptInput.getText().toString().trim().length() == 0 ? defaultText : promptInput.getText()); } catch (JSONException e) { LOG.d(LOG_TAG, "JSONException on third button.", e); } callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, result)); } }); } catch (JSONException e) { LOG.d(LOG_TAG, "JSONException on third button."); } } dlg.setOnCancelListener(new AlertDialog.OnCancelListener() { public void onCancel(DialogInterface dialog) { dialog.dismiss(); try { result.put("buttonIndex", 0); result.put("input1", promptInput.getText().toString().trim().length() == 0 ? defaultText : promptInput.getText()); } catch (JSONException e) { e.printStackTrace(); } callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, result)); } }); changeTextDirection(dlg); }; }; this.cordova.getActivity().runOnUiThread(runnable); }
From source file:com.example.imageZoom.ActivityPlugin.java
License:Apache License
public void startActivity(String className, String ImageURL) { try {/* ww w . ja va2 s . c o m*/ Intent intent = new Intent().setClass(this.cordova.getActivity(), Class.forName(className)); intent.putExtra("imageURL", ImageURL); LOG.d(TAG, "Starting activity %s", className); this.cordova.getActivity().startActivity(intent); } catch (ClassNotFoundException e) { e.printStackTrace(); LOG.e(TAG, "Error starting activity %s", className); } }
From source file:com.luoteng.folk.plugins.ActivityPlugin.java
License:Apache License
public void startActivity(String className, String startUrl, JSONObject extraPrefs) throws JSONException { try {/*from w w w. j a v a 2 s . co m*/ if (!startUrl.contains(":")) { startUrl = "file:///android_asset/www/" + startUrl; } Intent intent = new Intent(this.cordova.getActivity(), Class.forName(className)); intent.putExtra("testStartUrl", startUrl); Iterator<String> iter = extraPrefs.keys(); while (iter.hasNext()) { String key = iter.next(); intent.putExtra(key, extraPrefs.getString(key)); } LOG.d(TAG, "Starting activity %s", className); this.cordova.getActivity().startActivity(intent); } catch (ClassNotFoundException e) { e.printStackTrace(); LOG.e(TAG, "Error starting activity %s", className); } }
From source file:com.srikanth.phonegap.ActivityPlugin.java
License:Apache License
public void startActivity(String className) { try {/*from w w w . ja va 2s .c om*/ Intent intent = new Intent().setClass(this.cordova.getActivity(), Class.forName(className)); LOG.d(TAG, "Starting activity %s", className); this.cordova.getActivity().startActivity(intent); } catch (ClassNotFoundException e) { e.printStackTrace(); LOG.e(TAG, "Error starting activity %s", className); } }