Skip to content
This repository was archived by the owner on Feb 11, 2022. It is now read-only.

Commit 9e74226

Browse files
author
Andrei Catinean
committed
Extracts method
1 parent b7a20e4 commit 9e74226

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

core/src/main/java/novoda/lib/sqliteprovider/provider/SQLiteContentProviderImpl.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,16 @@ protected SQLiteOpenHelper getDatabaseHelper(Context context) {
6363

6464
@Override
6565
protected Uri insertInTransaction(Uri uri, ContentValues values) {
66-
return insertInTransaction(uri, values, true);
66+
Uri insertUri = insertSilently(uri, values);
67+
notifyUriChange(uri);
68+
return insertUri;
6769
}
6870

6971
@Override
7072
protected int bulkInsertInTransaction(Uri uri, ContentValues[] values) {
7173
int rowsCreated = 0;
7274
for (ContentValues value : values) {
73-
Uri insertUri = insertInTransaction(uri, value, false);
75+
Uri insertUri = insertSilently(uri, value);
7476
if (insertUri != null) {
7577
rowsCreated++;
7678
}
@@ -80,13 +82,9 @@ protected int bulkInsertInTransaction(Uri uri, ContentValues[] values) {
8082
return rowsCreated;
8183
}
8284

83-
private Uri insertInTransaction(Uri uri, ContentValues values, boolean shouldNotifyChange) {
85+
private Uri insertSilently(Uri uri, ContentValues values) {
8486
long rowId = helper.insert(uri, values);
85-
Uri newUri = ContentUris.withAppendedId(uri, rowId);
86-
if (shouldNotifyChange) {
87-
notifyUriChange(newUri);
88-
}
89-
return newUri;
87+
return ContentUris.withAppendedId(uri, rowId);
9088
}
9189

9290
@Override

0 commit comments

Comments
 (0)