Skip to content

Commit

Permalink
Update ProgressIndicator.java
Browse files Browse the repository at this point in the history
  • Loading branch information
pbernasconi committed Apr 23, 2015
1 parent 564981c commit 09314e5
Showing 1 changed file with 53 additions and 5 deletions.
58 changes: 53 additions & 5 deletions src/android/ProgressIndicator.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.apache.cordova.plugin;
package org.apache.cordova.progressindicator;

import org.apache.cordova.CallbackContext;
import org.apache.cordova.CordovaPlugin;
Expand All @@ -9,30 +9,78 @@
public class ProgressIndicator extends CordovaPlugin {

private ProgressDialog progressIndicator = null;
private static final String LOG_TAG = "ProgressIndicator";

@Override
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
if (action.equals("show")) {
String text = args.getString(0);
show(text);
show();
callbackContext.success();
return true;
} else if (action.equals("showSimple")) {
show();
callbackContext.success();
return true;
} else if (action.equals("showSimpleWithLabel")) {
String title = args.getString(1);
show(title);
callbackContext.success();
return true;
} else if (action.equals("showSimpleWithLabelDetail")) {
String title = args.getString(1);
String text = args.getString(2);
show(title, text, true);
callbackContext.success();
return true;
} else if (action.equals("showText")) {
String title = args.getString(1);
String text = args.getString(2);
show(title, text, false);
callbackContext.success();
return true;
} else if (action.equals("hide")) {
hide();
callbackContext.success();
return true;
}
} else {
callbackContext.error("Not supported call. On Android we only support show, showSimple, showSimpleWithLabel and showSimpleWithLabelDetail");
}

return false;
}

/**
* This show the ProgressDialog
*
* @param text - Message to display in the Progress Dialog
*/
public void show() {
progressIndicator = new ProgressDialog(cordova.getActivity());
progressIndicator.show();
}

/**
* This show the ProgressDialog
*
* @param text - Message to display in the Progress Dialog
*/
public void show(String text) {
progressIndicator = ProgressDialog.show(this.cordova.getActivity(), "", text);
progressIndicator = new ProgressDialog(cordova.getActivity());
progressIndicator.setTitle(text);
progressIndicator.show();
}

/**
* This show the ProgressDialog
*
* @param text - Message to display in the Progress Dialog
*/
public void show(String title, String detail, Boolean withTitle) {
progressIndicator = new ProgressDialog(cordova.getActivity());
if(withTitle)
progressIndicator.setTitle(title);
progressIndicator.setMessage(detail);
progressIndicator.show();
}

/**
Expand Down

0 comments on commit 09314e5

Please sign in to comment.