Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ public static void importJson(String json, Context context) throws JSONException
public static ArrayList<Trigger> createTriggerlist(String content) throws JSONException {
ArrayList<Trigger> result = new ArrayList<>();
JSONObject reader = new JSONObject(content);
JSONArray array = reader.getJSONArray("trigger");
JSONArray array = reader.optJSONArray("trigger");
if (array == null) {
return result;
}
for (int i = 0; i < array.length(); i++) {
JSONObject triggerObject = array.getJSONObject(i);
result.add(Trigger.Companion.fromString(triggerObject.toString()));
Expand All @@ -44,7 +47,10 @@ public static ArrayList<Trigger> createTriggerlist(String content) throws JSONEx
public static ArrayList<Task> createTasklist(String content) throws JSONException {
ArrayList<Task> result = new ArrayList<>();
JSONObject reader = new JSONObject(content);
JSONArray array = reader.getJSONArray("tasks");
JSONArray array = reader.optJSONArray("tasks");
if (array == null) {
return result;
}
for (int i = 0; i < array.length(); i++) {
JSONObject taskObject = array.getJSONObject(i);
result.add(Task.Companion.fromString(taskObject.toString()));
Expand All @@ -54,7 +60,10 @@ public static ArrayList<Task> createTasklist(String content) throws JSONExceptio
public static ArrayList<Filter> createFilterList(String content) throws JSONException {
ArrayList<Filter> result = new ArrayList<>();
JSONObject reader = new JSONObject(content);
JSONArray array = reader.getJSONArray("filters");
JSONArray array = reader.optJSONArray("filters");
if (array == null) {
return result;
}
for (int i = 0; i < array.length(); i++) {
JSONObject filterObject = array.getJSONObject(i);
result.add(Filter.Companion.fromString(filterObject.toString()));
Expand Down