Browse Source

Fixed some Issues with Uri-parsing
Added more update-options
Revised try/catch blocks

PKnittel 11 years ago
parent
commit
16a38ade65

+ 1 - 1
src/android/notification/Asset.java

@@ -114,7 +114,7 @@ public class Asset {
 		} else if (path.startsWith("http")){
 			return getUriForHTTP(path);
 		}
-		return Uri.parse(path);
+		return Uri.EMPTY;
 	}
     
 

+ 2 - 2
src/android/notification/Manager.java

@@ -281,9 +281,9 @@ public class Manager {
     
     
     /**
-     * Retrieves a list with all currently pending notification JSONObject.
+     * Retrieves a list with all currently pending notification JSONObjects that matches with the given String-Array
      *
-     * @return JSONArray with all notification-JSONObjects
+     * @return JSONArray with notification-JSONObjects 
      */
     public JSONArray getAll(JSONArray ids){
         SharedPreferences settings = getSharedPreferences();

+ 18 - 1
src/android/notification/NotificationWrapper.java

@@ -37,6 +37,7 @@ import android.content.SharedPreferences;
 import android.content.SharedPreferences.Editor;
 import android.os.Build;
 import android.support.v4.app.NotificationCompat.Builder;
+import android.util.Log;
 import android.widget.Toast;
 
 /**
@@ -143,7 +144,7 @@ public class NotificationWrapper {
 		try {
 			arguments = new JSONObject(alarms.get(id).toString());
 		} catch (JSONException e) {
-			e.printStackTrace();
+			Log.e("NotificationWrapper", "Update failed. No Notification available for the given id: " + id );
 			return;
 		}
 		arguments = updateArguments(arguments, updates);
@@ -188,6 +189,7 @@ public class NotificationWrapper {
 				unpersist(notificationId);
 			}
 		} catch (JSONException e) {
+			unpersist(notificationId);
 			e.printStackTrace();
 			return;
 		}
@@ -340,6 +342,21 @@ public class NotificationWrapper {
     		if(!updates.isNull("icon")){
     			arguments.put("icon", updates.get("icon"));
     		}
+    		if(!updates.isNull("date")){
+    			arguments.put("date", updates.get("date"));
+    		}
+    		if(!updates.isNull("repeat")){
+    			arguments.put("repeat", updates.get("repeat"));
+    		}
+    		if(!updates.isNull("json")){
+    			arguments.put("json", updates.get("json"));
+    		}
+    		if(!updates.isNull("autoCancel")){
+    			arguments.put("autoCancel", updates.get("autoCancel"));
+    		}
+    		if(!updates.isNull("ongoing")){
+    			arguments.put("ongoing", updates.get("ongoing"));
+    		}
     	} catch (JSONException jse){
     		jse.printStackTrace();
     	}

+ 6 - 20
src/android/notification/Options.java

@@ -164,18 +164,10 @@ public class Options {
         Uri iconUri = null;
         try{
         	iconUri = Uri.parse(options.optString("iconUri"));
-        } catch (Exception e){
-        	e.printStackTrace();
-        }
-        
-        if (iconUri != null) {
             bmp = getIconFromUri(iconUri);
+        } catch (Exception e){
+        	bmp = getIconFromRes(icon);
         }
-
-        if (bmp == null) {
-            bmp = getIconFromRes(icon);
-        }
-
         return bmp;
     }
 
@@ -317,23 +309,17 @@ public class Options {
      * @return
      *      The corresponding bitmap
      */
-    private Bitmap getIconFromUri (Uri uri) {
+    private Bitmap getIconFromUri (Uri uri) throws IOException {
         Bitmap bmp = null;
-
-        try {           
-            InputStream input = context.getContentResolver().openInputStream(uri);
-            bmp = BitmapFactory.decodeStream(input);
-        } catch (IOException e) {
-            e.printStackTrace();
-        }
+          
+        InputStream input = context.getContentResolver().openInputStream(uri);
+        bmp = BitmapFactory.decodeStream(input);
 
         return bmp;
     }
     
     /**
      * Function to set the value of "initialDate" in the JSONArray
-     * @param args The given JSONArray
-     * @return A new JSONArray with the parameter "initialDate" set.
      */
     public void setInitDate(){
     	long initialDate = options.optLong("date", 0) * 1000;