@Override protected void onDestroy() { app.getSynchronizationManager().detach(this); app.getActivationManager().detach(this); ArrayList<Task> tasks = app.getTasksManager().getAllTasksFromHeap(); for (Task task : tasks) { task.detachObserver(TodoListActivity.this); } super.onDestroy(); }
public JSONObject getAllExistingTasksWithGlobalId() { JSONObject existingTasks = new JSONObject(); ArrayList<Task> tasks = tasksManager.getAllTasks(); for (Task task : tasks) { if (task.getGlobalId() != 0) { try { existingTasks.put(Long.toString(task.getGlobalId()), Long.toString(task.getId())); } catch (JSONException e) { Log.e(TAG, "Cannot create JSONObject with existing tasks that have globalId"); e.printStackTrace(); } } } return existingTasks; }