Skip to content

Commit

Permalink
#3 JSON parse error
Browse files Browse the repository at this point in the history
  • Loading branch information
EddyVerbruggen committed Feb 22, 2015
1 parent 3041a48 commit d3dd9f0
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 38 deletions.
2 changes: 1 addition & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
id="de.appplant.cordova.plugin.local-notification"
version="0.8.0dev2">
version="0.8.0dev3">

<name>LocalNotification</name>

Expand Down
74 changes: 37 additions & 37 deletions src/android/LocalNotification.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public class LocalNotification extends CordovaPlugin {
Asset asset;
Manager manager;
NotificationWrapper nWrapper;

@Override
public void initialize (CordovaInterface cordova, CordovaWebView webView) {
super.initialize(cordova, webView);
Expand All @@ -76,16 +76,16 @@ public void initialize (CordovaInterface cordova, CordovaWebView webView) {
}
@Override
public boolean execute (String action, final JSONArray args, final CallbackContext command) throws JSONException {

if (action.equalsIgnoreCase("add")) {
cordova.getThreadPool().execute( new Runnable() {
public void run() {
public void run() {
add(args);
command.success();
}
});
}

if (action.equalsIgnoreCase("update")) {
cordova.getThreadPool().execute( new Runnable() {
public void run() {
Expand All @@ -94,13 +94,13 @@ public void run() {
}
});
}

if (action.equalsIgnoreCase("cancel")) {
cordova.getThreadPool().execute( new Runnable() {
public void run() {
cancel(args);
command.success();

}
});
}
Expand All @@ -113,7 +113,7 @@ public void run() {
}
});
}

if (action.equalsIgnoreCase("clear")) {
cordova.getThreadPool().execute( new Runnable() {
public void run() {
Expand All @@ -122,7 +122,7 @@ public void run() {
}
});
}

if (action.equalsIgnoreCase("clearAll")) {
cordova.getThreadPool().execute( new Runnable() {
public void run() {
Expand All @@ -134,18 +134,18 @@ public void run() {

if (action.equalsIgnoreCase("isScheduled")) {
String id = args.optString(0);
boolean isScheduled = manager.isScheduled(id);
boolean isScheduled = manager.isScheduled(id);
PluginResult result = new PluginResult(PluginResult.Status.OK, (isScheduled));
command.sendPluginResult(result);
}

if (action.equalsIgnoreCase("isTriggered")) {
String id = args.optString(0);
boolean isTriggered = manager.isTriggered(id);
PluginResult result = new PluginResult(PluginResult.Status.OK, isTriggered);
command.sendPluginResult(result);
}

if (action.equalsIgnoreCase("exist")) {
String id = args.optString(0);
boolean exist = manager.exist(id);
Expand All @@ -162,12 +162,12 @@ public void run() {
JSONArray triggeredIds = manager.getTriggeredIds();
command.success(triggeredIds);
}

if (action.equalsIgnoreCase("getAllIds")) {
JSONArray allIds = manager.getAllIds();
command.success(allIds);
}

if (action.equalsIgnoreCase("getAll")) {
JSONArray ids;
JSONArray all;
Expand All @@ -179,7 +179,7 @@ public void run() {
}
command.success(all);
}

if (action.equalsIgnoreCase("getTriggered")) {
JSONArray ids;
JSONArray triggered;
Expand All @@ -191,7 +191,7 @@ public void run() {
}
command.success(triggered);
}

if (action.equalsIgnoreCase("getScheduled")) {
JSONArray ids;
JSONArray scheduled;
Expand Down Expand Up @@ -222,8 +222,8 @@ public void run() {

return true;
}


//------------------------------------------------exec-Functions-----------------------------------------------
/**
* Schedule notifications contained in the args-Array
Expand All @@ -240,9 +240,9 @@ private void add(JSONArray args){
nWrapper.schedule(options);
JSONArray fireData= new JSONArray().put(options.getJSONObject());
fireEvent("add", options.getId(),options.getJSON(), fireData);
}
}
}

/**
* Update existing notifications
* @param args
Expand All @@ -252,11 +252,11 @@ private void update(JSONArray args){
JSONObject updateContent;
for(int i=0;i<updates.length();i++){
updateContent = args.optJSONObject(i);

nWrapper.update(updateContent);
}
}

/**
* Cancel scheduled Notifications
* @param args
Expand All @@ -272,7 +272,7 @@ private void cancel(JSONArray args){
fireEvent("cancel", id, "",data);
}
}

/**
* Cancel all scheduled notifications
* @param args
Expand All @@ -289,7 +289,7 @@ public void cancelAll(JSONArray args){
fireEvent("cancel", id, "",data);
}
}

/**
* Clear triggered notifications without cancel repeating.
* @param args
Expand All @@ -305,7 +305,7 @@ public void clear(JSONArray args){
fireEvent("clear", id, "",data);
}
}

/**
* Clear all triggered notifications without cancel repeating.
* @param args
Expand All @@ -322,11 +322,11 @@ public void clearAll(JSONArray args){
fireEvent("clear", id, "",data);
}
}









//-------------------------------------------------------------------------------------------------------------
/**
* Calls all pending callbacks after the deviceready event has been fired.
Expand Down Expand Up @@ -431,8 +431,8 @@ public static void fireEvent (String event, JSONArray ids, JSONArray json) {
public static void fireEvent (String event, String id, String json, JSONArray data) {
String state = getApplicationState();
String params = "\"" + id + "\",\"" + state + "\"," + JSONObject.quote(json)+","+ data;
String js = "setTimeout('plugin.notification.local.on" + event + "(" + params + ")',0)";
String js = "plugin.notification.local.on" + event + "(" + params + ")";

// webview may available, but callbacks needs to be executed
// after deviceready
if (deviceready == false) {
Expand All @@ -441,9 +441,9 @@ public static void fireEvent (String event, String id, String json, JSONArray da
sendJavascript(js);
}
}



/**
* Retrieves the application state
*
Expand Down Expand Up @@ -483,8 +483,8 @@ protected static AlarmManager getAlarmManager () {
protected static NotificationManager getNotificationManager () {
return (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
}


/**
* Use this instead of deprecated sendJavascript
*/
Expand All @@ -500,6 +500,6 @@ public void run(){
}
});
}


}

0 comments on commit d3dd9f0

Please sign in to comment.