Commit 16a38ade by PKnittel

Fixed some Issues with Uri-parsing

Added more update-options
Revised try/catch blocks
parent 992478a2
...@@ -114,7 +114,7 @@ public class Asset { ...@@ -114,7 +114,7 @@ public class Asset {
} else if (path.startsWith("http")){ } else if (path.startsWith("http")){
return getUriForHTTP(path); return getUriForHTTP(path);
} }
return Uri.parse(path); return Uri.EMPTY;
} }
......
...@@ -281,9 +281,9 @@ public class Manager { ...@@ -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){ public JSONArray getAll(JSONArray ids){
SharedPreferences settings = getSharedPreferences(); SharedPreferences settings = getSharedPreferences();
......
...@@ -37,6 +37,7 @@ import android.content.SharedPreferences; ...@@ -37,6 +37,7 @@ import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor; import android.content.SharedPreferences.Editor;
import android.os.Build; import android.os.Build;
import android.support.v4.app.NotificationCompat.Builder; import android.support.v4.app.NotificationCompat.Builder;
import android.util.Log;
import android.widget.Toast; import android.widget.Toast;
/** /**
...@@ -143,7 +144,7 @@ public class NotificationWrapper { ...@@ -143,7 +144,7 @@ public class NotificationWrapper {
try { try {
arguments = new JSONObject(alarms.get(id).toString()); arguments = new JSONObject(alarms.get(id).toString());
} catch (JSONException e) { } catch (JSONException e) {
e.printStackTrace(); Log.e("NotificationWrapper", "Update failed. No Notification available for the given id: " + id );
return; return;
} }
arguments = updateArguments(arguments, updates); arguments = updateArguments(arguments, updates);
...@@ -188,6 +189,7 @@ public class NotificationWrapper { ...@@ -188,6 +189,7 @@ public class NotificationWrapper {
unpersist(notificationId); unpersist(notificationId);
} }
} catch (JSONException e) { } catch (JSONException e) {
unpersist(notificationId);
e.printStackTrace(); e.printStackTrace();
return; return;
} }
...@@ -340,6 +342,21 @@ public class NotificationWrapper { ...@@ -340,6 +342,21 @@ public class NotificationWrapper {
if(!updates.isNull("icon")){ if(!updates.isNull("icon")){
arguments.put("icon", updates.get("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){ } catch (JSONException jse){
jse.printStackTrace(); jse.printStackTrace();
} }
......
...@@ -164,18 +164,10 @@ public class Options { ...@@ -164,18 +164,10 @@ public class Options {
Uri iconUri = null; Uri iconUri = null;
try{ try{
iconUri = Uri.parse(options.optString("iconUri")); iconUri = Uri.parse(options.optString("iconUri"));
} catch (Exception e){
e.printStackTrace();
}
if (iconUri != null) {
bmp = getIconFromUri(iconUri); bmp = getIconFromUri(iconUri);
} } catch (Exception e){
if (bmp == null) {
bmp = getIconFromRes(icon); bmp = getIconFromRes(icon);
} }
return bmp; return bmp;
} }
...@@ -317,23 +309,17 @@ public class Options { ...@@ -317,23 +309,17 @@ public class Options {
* @return * @return
* The corresponding bitmap * The corresponding bitmap
*/ */
private Bitmap getIconFromUri (Uri uri) { private Bitmap getIconFromUri (Uri uri) throws IOException {
Bitmap bmp = null; Bitmap bmp = null;
try {
InputStream input = context.getContentResolver().openInputStream(uri); InputStream input = context.getContentResolver().openInputStream(uri);
bmp = BitmapFactory.decodeStream(input); bmp = BitmapFactory.decodeStream(input);
} catch (IOException e) {
e.printStackTrace();
}
return bmp; return bmp;
} }
/** /**
* Function to set the value of "initialDate" in the JSONArray * 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(){ public void setInitDate(){
long initialDate = options.optLong("date", 0) * 1000; long initialDate = options.optLong("date", 0) * 1000;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment