Skip to content

Commit

Permalink
Synchronize iteration over controls list
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Su committed May 7, 2011
1 parent d30d9f8 commit 8f520a8
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions astrid/src/com/todoroo/astrid/activity/TaskEditActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,10 @@ public void onClick(View v) {
controls.add(new HideUntilControlSet(R.id.hideUntil));

// re-read all
for(TaskEditControlSet controlSet : controls)
controlSet.readFromTask(model);
synchronized(controls) {
for(TaskEditControlSet controlSet : controls)
controlSet.readFromTask(model);
}
}
});

Expand Down Expand Up @@ -426,17 +428,21 @@ private void populateFields() {
else
setTitle(r.getString(R.string.TEA_view_title, model.getValue(Task.TITLE)));

for(TaskEditControlSet controlSet : controls)
controlSet.readFromTask(model);
synchronized(controls) {
for(TaskEditControlSet controlSet : controls)
controlSet.readFromTask(model);
}
}

/** Save task model from values in UI components */
private void save() {
StringBuilder toast = new StringBuilder();
for(TaskEditControlSet controlSet : controls) {
String toastText = controlSet.writeToModel(model);
if(toastText != null)
toast.append('\n').append(toastText);
synchronized(controls) {
for(TaskEditControlSet controlSet : controls) {
String toastText = controlSet.writeToModel(model);
if(toastText != null)
toast.append('\n').append(toastText);
}
}

if(title.getText().length() > 0)
Expand Down

0 comments on commit 8f520a8

Please sign in to comment.