pull/14/head
Sam Bosley 13 years ago
parent 71a14e78fd
commit aa7f992980

@ -297,33 +297,35 @@ public class DatabaseDao<TYPE extends AbstractModel> {
boolean recordOutstanding = shouldRecordOutstanding(item); boolean recordOutstanding = shouldRecordOutstanding(item);
final AtomicBoolean result = new AtomicBoolean(false); final AtomicBoolean result = new AtomicBoolean(false);
if (recordOutstanding) { // begin transaction synchronized(database) {
database.getDatabase().beginTransactionWithListener(new SQLiteTransactionListener() { if (recordOutstanding) { // begin transaction
@Override database.getDatabase().beginTransactionWithListener(new SQLiteTransactionListener() {
public void onRollback() { @Override
Log.e(ERROR_TAG, "Error inserting or updating rows", new Throwable()); //$NON-NLS-1$ public void onRollback() {
result.set(false); Log.e(ERROR_TAG, "Error inserting or updating rows", new Throwable()); //$NON-NLS-1$
result.set(false);
}
@Override
public void onCommit() {/**/}
@Override
public void onBegin() {/**/}
});
}
int numOutstanding = 0;
try {
result.set(op.makeChange());
if(result.get()) {
if (recordOutstanding && ((numOutstanding = createOutstandingEntries(item.getId(), values)) != -1)) // Create entries for setValues in outstanding table
database.getDatabase().setTransactionSuccessful();
} }
@Override } finally {
public void onCommit() {/**/} if (recordOutstanding) // commit transaction
@Override database.getDatabase().endTransaction();
public void onBegin() {/**/} }
}); if (result.get()) {
} onModelUpdated(item, recordOutstanding && numOutstanding > 0);
int numOutstanding = 0; item.markSaved();
try {
result.set(op.makeChange());
if(result.get()) {
if (recordOutstanding && ((numOutstanding = createOutstandingEntries(item.getId(), values)) != -1)) // Create entries for setValues in outstanding table
database.getDatabase().setTransactionSuccessful();
} }
} finally {
if (recordOutstanding) // commit transaction
database.getDatabase().endTransaction();
}
if (result.get()) {
onModelUpdated(item, recordOutstanding && numOutstanding > 0);
item.markSaved();
} }
return result.get(); return result.get();
} }

Loading…
Cancel
Save