Remove AbstractModel.clear()

pull/618/head
Alex Baker 7 years ago
parent 4cdf4c8850
commit d42f062875

@ -128,17 +128,16 @@ class OrderedMetadataListFragmentHelper {
private void setCompletedForItemAndSubtasks(final Task item, final boolean completedState) { private void setCompletedForItemAndSubtasks(final Task item, final boolean completedState) {
final long itemId = item.getId(); final long itemId = item.getId();
final Task model = new Task();
final long completionDate = completedState ? DateUtilities.now() : 0; final long completionDate = completedState ? DateUtilities.now() : 0;
if(!completedState) { if(!completedState) {
ArrayList<Long> chained = chainedCompletions.get(itemId); ArrayList<Long> chained = chainedCompletions.get(itemId);
if(chained != null) { if(chained != null) {
for(Long taskId : chained) { for(Long taskId : chained) {
Task model = new Task();
model.setId(taskId); model.setId(taskId);
model.setCompletionDate(completionDate); model.setCompletionDate(completionDate);
taskDao.save(model); taskDao.save(model);
model.clear();
} }
taskAdapter.notifyDataSetInvalidated(); taskAdapter.notifyDataSetInvalidated();
} }
@ -155,10 +154,10 @@ class OrderedMetadataListFragmentHelper {
googleTaskDao.update(googleTask); googleTaskDao.update(googleTask);
} }
Task model = new Task();
model.setId(node.taskId); model.setId(node.taskId);
model.setCompletionDate(completionDate); model.setCompletionDate(completionDate);
taskDao.save(model); taskDao.save(model);
model.clear();
chained.add(node.taskId); chained.add(node.taskId);
}); });

@ -112,14 +112,6 @@ public abstract class AbstractModel implements Parcelable, Cloneable {
return mergedValues; return mergedValues;
} }
/**
* Clear all data on this model
*/
public void clear() {
values = null;
setValues = null;
}
/** /**
* Transfers all set values into values. This occurs when a task is * Transfers all set values into values. This occurs when a task is
* saved - future saves will not need to write all the data as before. * saved - future saves will not need to write all the data as before.

@ -165,7 +165,7 @@ public class TasksXmlImporter {
private class Format2TaskImporter { private class Format2TaskImporter {
XmlPullParser xpp; XmlPullParser xpp;
final Task currentTask = new Task(); Task currentTask;
public Format2TaskImporter() { } public Format2TaskImporter() { }
public Format2TaskImporter(XmlPullParser xpp) throws XmlPullParserException, IOException { public Format2TaskImporter(XmlPullParser xpp) throws XmlPullParserException, IOException {
@ -198,7 +198,7 @@ public class TasksXmlImporter {
void parseTask() { void parseTask() {
taskCount++; taskCount++;
setProgressMessage(activity.getString(R.string.import_progress_read, taskCount)); setProgressMessage(activity.getString(R.string.import_progress_read, taskCount));
currentTask.clear(); currentTask = new Task();
String title = xpp.getAttributeValue(null, Task.TITLE.name); String title = xpp.getAttributeValue(null, Task.TITLE.name);
String created = xpp.getAttributeValue(null, Task.CREATION_DATE.name); String created = xpp.getAttributeValue(null, Task.CREATION_DATE.name);

@ -124,16 +124,15 @@ class AstridOrderedListFragmentHelper {
private void setCompletedForItemAndSubtasks(final Task item, final boolean completedState) { private void setCompletedForItemAndSubtasks(final Task item, final boolean completedState) {
final String itemId = item.getUuid(); final String itemId = item.getUuid();
final Task model = new Task();
final long completionDate = completedState ? DateUtilities.now() : 0; final long completionDate = completedState ? DateUtilities.now() : 0;
if(!completedState) { if(!completedState) {
ArrayList<String> chained = chainedCompletions.get(itemId); ArrayList<String> chained = chainedCompletions.get(itemId);
if(chained != null) { if(chained != null) {
for(String taskId : chained) { for(String taskId : chained) {
Task model = new Task();
model.setCompletionDate(completionDate); model.setCompletionDate(completionDate);
taskDao.update(Task.UUID.eq(taskId), model); taskDao.update(Task.UUID.eq(taskId), model);
model.clear();
} }
taskAdapter.notifyDataSetInvalidated(); taskAdapter.notifyDataSetInvalidated();
} }
@ -143,9 +142,9 @@ class AstridOrderedListFragmentHelper {
final ArrayList<String> chained = new ArrayList<>(); final ArrayList<String> chained = new ArrayList<>();
updater.applyToDescendants(itemId, node -> { updater.applyToDescendants(itemId, node -> {
String uuid = node.uuid; String uuid = node.uuid;
Task model = new Task();
model.setCompletionDate(completionDate); model.setCompletionDate(completionDate);
taskDao.update(Task.UUID.eq(uuid), model); taskDao.update(Task.UUID.eq(uuid), model);
model.clear();
chained.add(node.uuid); chained.add(node.uuid);
}); });

Loading…
Cancel
Save