robotoworks / mechanoid

Eclipse plugin providing a set of DSL's for the rapid development of Android apps
58 stars 26 forks source link

MechanoidContentProvider should respect yield points #229

Open elincognito opened 10 years ago

elincognito commented 10 years ago

The code

    public ContentProviderResult[] applyBatch(ArrayList<ContentProviderOperation> operations)
            throws OperationApplicationException {
        final SQLiteDatabase db = getOpenHelper().getWritableDatabase();
        db.beginTransaction();
        try {
            final int numOperations = operations.size();
            final ContentProviderResult[] results = new ContentProviderResult[numOperations];
            for (int i = 0; i < numOperations; i++) {
                results[i] = operations.get(i).apply(this, results, i);
            }
            db.setTransactionSuccessful();
            return results;
        } finally {
            db.endTransaction();
        }````

should respect ContentProviderOperation.withYieldAllowed() by 
checking each operation on the for loop if it allows yield and applying a 
db yieldifContentSafely 
example code can be seen in the android contacts provider src code