Skip to content

Commit 966a9ad

Browse files
authored
Merge pull request #1492 from Raizlabs/develop
4.2.0
2 parents fcbad3b + b442620 commit 966a9ad

File tree

12 files changed

+204
-114
lines changed

12 files changed

+204
-114
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
![Image](https://github.com/agrosner/DBFlow/blob/develop/dbflow_banner.png?raw=true)
22

3-
[![JitPack.io](https://img.shields.io/badge/JitPack.io-4.1.2-red.svg?style=flat)](https://jitpack.io/#Raizlabs/DBFlow) [![Android Weekly](http://img.shields.io/badge/Android%20Weekly-%23129-2CB3E5.svg?style=flat)](http://androidweekly.net/issues/issue-129) [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-DBFlow-brightgreen.svg?style=flat)](https://android-arsenal.com/details/1/1134)
3+
[![JitPack.io](https://img.shields.io/badge/JitPack.io-4.2.0-red.svg?style=flat)](https://jitpack.io/#Raizlabs/DBFlow) [![Android Weekly](http://img.shields.io/badge/Android%20Weekly-%23129-2CB3E5.svg?style=flat)](http://androidweekly.net/issues/issue-129) [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-DBFlow-brightgreen.svg?style=flat)](https://android-arsenal.com/details/1/1134)
44

55
A robust, powerful, and very simple ORM android database library with **annotation processing**.
66

@@ -43,8 +43,9 @@ Add the library to the project-level build.gradle, using the apt plugin to enabl
4343
4444
apply plugin: 'kotlin-kapt' // required for kotlin.
4545
46-
def dbflow_version = "4.1.2"
47-
// dbflow_version = 10-digit short-hash of a specific commit. (Useful for bugs fixed in develop, but not in a release yet)
46+
def dbflow_version = "4.2.0"
47+
// or dbflow_version = "develop-SNAPSHOT" for grabbing latest dependency in your project on the develop branch
48+
// or 10-digit short-hash of a specific commit. (Useful for bugs fixed in develop, but not in a release yet)
4849
4950
dependencies {
5051

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ buildscript {
55
google()
66
}
77
dependencies {
8-
classpath 'com.android.tools.build:gradle:3.0.0-rc2'
8+
classpath 'com.android.tools.build:gradle:3.0.1'
99
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
1010
classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.7.3'
1111
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

dbflow-tests/src/androidTest/java/com/raizlabs/android/dbflow/contentobserver/ContentObserverTest.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import com.raizlabs.android.dbflow.sql.language.Delete
1616
import com.raizlabs.android.dbflow.sql.language.SQLOperator
1717
import com.raizlabs.android.dbflow.structure.BaseModel
1818
import org.junit.Assert.assertEquals
19-
import org.junit.Assert.assertTrue
2019
import org.junit.Before
2120
import org.junit.Test
2221
import java.util.concurrent.CountDownLatch
@@ -34,11 +33,12 @@ class ContentObserverTest : BaseInstrumentedUnitTest() {
3433
@Test
3534
fun testSpecificUris() {
3635
val conditionGroup = FlowManager.getModelAdapter(User::class.java)
37-
.getPrimaryConditionClause(user)
38-
val uri = SqlUtils.getNotificationUri(User::class.java, BaseModel.Action.DELETE,
39-
conditionGroup.conditions.toTypedArray())
36+
.getPrimaryConditionClause(user)
37+
val uri = SqlUtils.getNotificationUri(FlowManager.DEFAULT_AUTHORITY,
38+
User::class.java, BaseModel.Action.DELETE,
39+
conditionGroup.conditions.toTypedArray())
4040

41-
assertEquals(uri.authority, FlowManager.getTableName(User::class.java))
41+
assertEquals(uri.authority, FlowManager.DEFAULT_AUTHORITY)
4242
assertEquals(uri.fragment, BaseModel.Action.DELETE.name)
4343
assertEquals(Uri.decode(uri.getQueryParameter(Uri.encode(id.query))), "5")
4444
assertEquals(Uri.decode(uri.getQueryParameter(Uri.encode(name.query))), "Something")
@@ -69,7 +69,7 @@ class ContentObserverTest : BaseInstrumentedUnitTest() {
6969
}
7070

7171
private fun assertProperConditions(action: BaseModel.Action, userFunc: (User) -> Unit) {
72-
val contentObserver = FlowContentObserver()
72+
val contentObserver = FlowContentObserver(FlowManager.DEFAULT_AUTHORITY)
7373
val countDownLatch = CountDownLatch(1)
7474
val mockOnModelStateChangedListener = MockOnModelStateChangedListener(countDownLatch)
7575
contentObserver.addModelChangeListener(mockOnModelStateChangedListener)
@@ -79,7 +79,7 @@ class ContentObserverTest : BaseInstrumentedUnitTest() {
7979
countDownLatch.await()
8080

8181
val ops = mockOnModelStateChangedListener.operators!!
82-
assertTrue(ops.size == 2)
82+
assertEquals(2, ops.size)
8383
assertEquals(ops[0].columnName(), id.query)
8484
assertEquals(ops[1].columnName(), name.query)
8585
assertEquals(ops[1].value(), "Something")

dbflow-tests/src/main/AndroidManifest.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
<category android:name="android.intent.category.LAUNCHER"/>
1414
</intent-filter>
1515
</activity>
16+
17+
<provider
18+
android:name="com.raizlabs.android.dbflow.runtime.StubContentProvider"
19+
android:authorities="com.dbflow.authority"/>
1620
</application>
1721

1822
</manifest>

dbflow/src/main/java/com/raizlabs/android/dbflow/config/DatabaseDefinition.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ public ModelNotifier getModelNotifier() {
263263
DatabaseConfig config = FlowManager.getConfig().databaseConfigMap()
264264
.get(getAssociatedDatabaseClassFile());
265265
if (config == null || config.modelNotifier() == null) {
266-
modelNotifier = new ContentResolverNotifier();
266+
modelNotifier = new ContentResolverNotifier(FlowManager.DEFAULT_AUTHORITY);
267267
} else {
268268
modelNotifier = config.modelNotifier();
269269
}

dbflow/src/main/java/com/raizlabs/android/dbflow/config/FlowManager.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ public boolean isInitialized() {
6565
private static final String DEFAULT_DATABASE_HOLDER_CLASSNAME =
6666
DEFAULT_DATABASE_HOLDER_PACKAGE_NAME + "." + DEFAULT_DATABASE_HOLDER_NAME;
6767

68+
public static final String DEFAULT_AUTHORITY = "com.dbflow.authority";
69+
6870
/**
6971
* Returns the table name for the specific model class
7072
*

dbflow/src/main/java/com/raizlabs/android/dbflow/list/FlowQueryList.java

Lines changed: 67 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
* on the underlying table.
3838
*/
3939
public class FlowQueryList<TModel> extends FlowContentObserver
40-
implements List<TModel>, IFlowCursorIterator<TModel> {
40+
implements List<TModel>, IFlowCursorIterator<TModel> {
4141

4242
private static final Handler REFRESH_HANDLER = new Handler(Looper.myLooper());
4343

@@ -60,16 +60,17 @@ public class FlowQueryList<TModel> extends FlowContentObserver
6060

6161

6262
private FlowQueryList(Builder<TModel> builder) {
63+
super(FlowManager.DEFAULT_AUTHORITY);
6364
transact = builder.transact;
6465
changeInTransaction = builder.changeInTransaction;
6566
successCallback = builder.success;
6667
errorCallback = builder.error;
6768
internalCursorList = new FlowCursorList.Builder<>(builder.table)
68-
.cursor(builder.cursor)
69-
.cacheModels(builder.cacheModels)
70-
.modelQueriable(builder.modelQueriable)
71-
.modelCache(builder.modelCache)
72-
.build();
69+
.cursor(builder.cursor)
70+
.cacheModels(builder.cacheModels)
71+
.modelQueriable(builder.modelQueriable)
72+
.modelCache(builder.modelCache)
73+
.build();
7374
}
7475

7576
/**
@@ -92,8 +93,8 @@ public void removeOnCursorRefreshListener(@NonNull OnCursorRefreshListener<TMode
9293
@Override
9394
public void registerForContentChanges(Context context, Class<?> table) {
9495
throw new RuntimeException(
95-
"This method is not to be used in the FlowQueryList. We should only ever receive" +
96-
" notifications for one class here. Call registerForContentChanges(Context) instead");
96+
"This method is not to be used in the FlowQueryList. We should only ever receive" +
97+
" notifications for one class here. Call registerForContentChanges(Context) instead");
9798
}
9899

99100
@Override
@@ -165,10 +166,10 @@ InstanceAdapter<TModel> getInstanceAdapter() {
165166
@NonNull
166167
public Builder<TModel> newBuilder() {
167168
return new Builder<>(internalCursorList)
168-
.success(successCallback)
169-
.error(errorCallback)
170-
.changeInTransaction(changeInTransaction)
171-
.transact(transact);
169+
.success(successCallback)
170+
.error(errorCallback)
171+
.changeInTransaction(changeInTransaction)
172+
.transact(transact);
172173
}
173174

174175
/**
@@ -223,10 +224,10 @@ public void add(int location, @Nullable TModel model) {
223224
public boolean add(@Nullable TModel model) {
224225
if (model != null) {
225226
Transaction transaction = FlowManager.getDatabaseForTable(internalCursorList.table())
226-
.beginTransactionAsync(new ProcessModelTransaction.Builder<>(saveModel)
227-
.add(model).build())
228-
.error(internalErrorCallback)
229-
.success(internalSuccessCallback).build();
227+
.beginTransactionAsync(new ProcessModelTransaction.Builder<>(saveModel)
228+
.add(model).build())
229+
.error(internalErrorCallback)
230+
.success(internalSuccessCallback).build();
230231

231232
if (transact) {
232233
transaction.execute();
@@ -265,10 +266,10 @@ public boolean addAll(@NonNull Collection<? extends TModel> collection) {
265266
final Collection<TModel> tmpCollection = (Collection<TModel>) collection;
266267

267268
Transaction transaction = FlowManager.getDatabaseForTable(internalCursorList.table())
268-
.beginTransactionAsync(new ProcessModelTransaction.Builder<>(saveModel)
269-
.addAll(tmpCollection).build())
270-
.error(internalErrorCallback)
271-
.success(internalSuccessCallback).build();
269+
.beginTransactionAsync(new ProcessModelTransaction.Builder<>(saveModel)
270+
.addAll(tmpCollection).build())
271+
.error(internalErrorCallback)
272+
.success(internalSuccessCallback).build();
272273

273274
if (transact) {
274275
transaction.execute();
@@ -284,11 +285,11 @@ public boolean addAll(@NonNull Collection<? extends TModel> collection) {
284285
@Override
285286
public void clear() {
286287
Transaction transaction = FlowManager.getDatabaseForTable(internalCursorList.table())
287-
.beginTransactionAsync(new QueryTransaction.Builder<>(
288-
SQLite.delete().from(internalCursorList.table())).build())
289-
.error(internalErrorCallback)
290-
.success(internalSuccessCallback)
291-
.build();
288+
.beginTransactionAsync(new QueryTransaction.Builder<>(
289+
SQLite.delete().from(internalCursorList.table())).build())
290+
.error(internalErrorCallback)
291+
.success(internalSuccessCallback)
292+
.build();
292293

293294
if (transact) {
294295
transaction.execute();
@@ -369,7 +370,7 @@ public TModel get(int row) {
369370
@Override
370371
public int indexOf(Object object) {
371372
throw new UnsupportedOperationException(
372-
"We cannot determine which index in the table this item exists at efficiently");
373+
"We cannot determine which index in the table this item exists at efficiently");
373374
}
374375

375376
@Override
@@ -396,7 +397,7 @@ public FlowCursorIterator<TModel> iterator(int startingLocation, long limit) {
396397
@Override
397398
public int lastIndexOf(Object object) {
398399
throw new UnsupportedOperationException(
399-
"We cannot determine which index in the table this item exists at efficiently");
400+
"We cannot determine which index in the table this item exists at efficiently");
400401
}
401402

402403
/**
@@ -433,10 +434,10 @@ public TModel remove(int location) {
433434
TModel model = internalCursorList.getItem(location);
434435

435436
Transaction transaction = FlowManager.getDatabaseForTable(internalCursorList.table())
436-
.beginTransactionAsync(new ProcessModelTransaction.Builder<>(deleteModel)
437-
.add(model).build())
438-
.error(internalErrorCallback)
439-
.success(internalSuccessCallback).build();
437+
.beginTransactionAsync(new ProcessModelTransaction.Builder<>(deleteModel)
438+
.add(model).build())
439+
.error(internalErrorCallback)
440+
.success(internalSuccessCallback).build();
440441

441442
if (transact) {
442443
transaction.execute();
@@ -462,10 +463,10 @@ public boolean remove(Object object) {
462463
if (internalCursorList.table().isAssignableFrom(object.getClass())) {
463464
TModel model = ((TModel) object);
464465
Transaction transaction = FlowManager.getDatabaseForTable(internalCursorList.table())
465-
.beginTransactionAsync(new ProcessModelTransaction.Builder<>(deleteModel)
466-
.add(model).build())
467-
.error(internalErrorCallback)
468-
.success(internalSuccessCallback).build();
466+
.beginTransactionAsync(new ProcessModelTransaction.Builder<>(deleteModel)
467+
.add(model).build())
468+
.error(internalErrorCallback)
469+
.success(internalSuccessCallback).build();
469470

470471
if (transact) {
471472
transaction.execute();
@@ -492,10 +493,10 @@ public boolean removeAll(@NonNull Collection<?> collection) {
492493
// if its a ModelClass
493494
Collection<TModel> modelCollection = (Collection<TModel>) collection;
494495
Transaction transaction = FlowManager.getDatabaseForTable(internalCursorList.table())
495-
.beginTransactionAsync(new ProcessModelTransaction.Builder<>(deleteModel)
496-
.addAll(modelCollection).build())
497-
.error(internalErrorCallback)
498-
.success(internalSuccessCallback).build();
496+
.beginTransactionAsync(new ProcessModelTransaction.Builder<>(deleteModel)
497+
.addAll(modelCollection).build())
498+
.error(internalErrorCallback)
499+
.success(internalSuccessCallback).build();
499500

500501
if (transact) {
501502
transaction.execute();
@@ -518,10 +519,10 @@ public boolean retainAll(@NonNull Collection<?> collection) {
518519
List<TModel> tableList = internalCursorList.getAll();
519520
tableList.removeAll(collection);
520521
Transaction transaction = FlowManager.getDatabaseForTable(internalCursorList.table())
521-
.beginTransactionAsync(new ProcessModelTransaction.Builder<>(tableList, deleteModel)
522-
.build())
523-
.error(internalErrorCallback)
524-
.success(internalSuccessCallback).build();
522+
.beginTransactionAsync(new ProcessModelTransaction.Builder<>(tableList, deleteModel)
523+
.build())
524+
.error(internalErrorCallback)
525+
.success(internalSuccessCallback).build();
525526

526527
if (transact) {
527528
transaction.execute();
@@ -552,11 +553,11 @@ public TModel set(int location, TModel object) {
552553
*/
553554
public TModel set(TModel object) {
554555
Transaction transaction = FlowManager.getDatabaseForTable(internalCursorList.table())
555-
.beginTransactionAsync(new ProcessModelTransaction.Builder<>(updateModel)
556-
.add(object)
557-
.build())
558-
.error(internalErrorCallback)
559-
.success(internalSuccessCallback).build();
556+
.beginTransactionAsync(new ProcessModelTransaction.Builder<>(updateModel)
557+
.add(object)
558+
.build())
559+
.error(internalErrorCallback)
560+
.success(internalSuccessCallback).build();
560561

561562
if (transact) {
562563
transaction.execute();
@@ -598,28 +599,28 @@ public void close() {
598599
}
599600

600601
private final ProcessModelTransaction.ProcessModel<TModel> saveModel =
601-
new ProcessModelTransaction.ProcessModel<TModel>() {
602-
@Override
603-
public void processModel(TModel model, DatabaseWrapper wrapper) {
604-
getModelAdapter().save(model);
605-
}
606-
};
602+
new ProcessModelTransaction.ProcessModel<TModel>() {
603+
@Override
604+
public void processModel(TModel model, DatabaseWrapper wrapper) {
605+
getModelAdapter().save(model);
606+
}
607+
};
607608

608609
private final ProcessModelTransaction.ProcessModel<TModel> updateModel =
609-
new ProcessModelTransaction.ProcessModel<TModel>() {
610-
@Override
611-
public void processModel(TModel model, DatabaseWrapper wrapper) {
612-
getModelAdapter().update(model);
613-
}
614-
};
610+
new ProcessModelTransaction.ProcessModel<TModel>() {
611+
@Override
612+
public void processModel(TModel model, DatabaseWrapper wrapper) {
613+
getModelAdapter().update(model);
614+
}
615+
};
615616

616617
private final ProcessModelTransaction.ProcessModel<TModel> deleteModel =
617-
new ProcessModelTransaction.ProcessModel<TModel>() {
618-
@Override
619-
public void processModel(TModel model, DatabaseWrapper wrapper) {
620-
getModelAdapter().delete(model);
621-
}
622-
};
618+
new ProcessModelTransaction.ProcessModel<TModel>() {
619+
@Override
620+
public void processModel(TModel model, DatabaseWrapper wrapper) {
621+
getModelAdapter().delete(model);
622+
}
623+
};
623624

624625
private final Transaction.Error internalErrorCallback = new Transaction.Error() {
625626
@Override

0 commit comments

Comments
 (0)