() {
70 | @Override
71 | public void onCompleted() {
72 |
73 | }
74 |
75 | @Override
76 | public void onError(Throwable e) {
77 |
78 | }
79 |
80 | @Override
81 | public void onNext(Void tModels) {
82 | subscriber.onNext(tModels);
83 |
84 | if(mBaseQueriable.getQuery().toLowerCase().contains("delete")){
85 | SqlUtils.notifyModelChanged(mModelClazz, BaseModel.Action.DELETE, null);
86 | } else if(mBaseQueriable.getQuery().toLowerCase().contains("update")){
87 | SqlUtils.notifyModelChanged(mModelClazz, BaseModel.Action.UPDATE, null);
88 | }
89 | }
90 | };
91 |
92 | }
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/RxDbFlow-Rx1/src/main/java/au/com/roadhouse/rxdbflow/rx1/sql/transaction/RxGenericTransactionBlock.java:
--------------------------------------------------------------------------------
1 | package au.com.roadhouse.rxdbflow.rx1.sql.transaction;
2 |
3 | import android.database.sqlite.SQLiteException;
4 | import android.support.annotation.NonNull;
5 |
6 | import com.raizlabs.android.dbflow.config.FlowManager;
7 | import com.raizlabs.android.dbflow.structure.Model;
8 | import com.raizlabs.android.dbflow.structure.database.DatabaseWrapper;
9 |
10 | import java.util.ArrayList;
11 | import java.util.List;
12 |
13 | import rx.Observable;
14 | import rx.Subscriber;
15 |
16 | /**
17 | * Provides a transaction block that runs a series of database operations on a single database within
18 | * a single transaction. There is no limitation on what type of operations, that can run within a single transaction.
19 | * Creation of a ModelOperationTransaction is via the use of the inner builder.
20 | */
21 | public class RxGenericTransactionBlock extends Observable {
22 |
23 | private RxGenericTransactionBlock(Builder builder) {
24 | super(new OnTransactionSubscribe(builder.mTransactionProcessList, builder.mDatabaseWrapper));
25 | }
26 |
27 | private static class OnTransactionSubscribe implements OnSubscribe {
28 |
29 | private final List mTransactionProcessList;
30 | private final DatabaseWrapper mDatabaseWrapper;
31 |
32 | private OnTransactionSubscribe(List transactionProcessList, DatabaseWrapper databaseWrapper) {
33 | mTransactionProcessList = transactionProcessList;
34 | mDatabaseWrapper = databaseWrapper;
35 | }
36 |
37 | @Override
38 | public void call(Subscriber super Void> subscriber) {
39 |
40 | try {
41 | mDatabaseWrapper.beginTransaction();
42 |
43 | for (int i = 0; i < mTransactionProcessList.size(); i++) {
44 | if(!mTransactionProcessList.get(i).onProcess(mDatabaseWrapper)){
45 | throw new SQLiteException("A transaction process item failed");
46 | }
47 | }
48 | subscriber.onNext(null);
49 | subscriber.onCompleted();
50 |
51 |
52 | mDatabaseWrapper.setTransactionSuccessful();
53 | } catch (Exception e){
54 | subscriber.onError(e);
55 | } finally{
56 | mDatabaseWrapper.endTransaction();
57 | }
58 | }
59 | }
60 |
61 | /**
62 | * A build which creates a new generic transaction block.
63 | */
64 | public static class Builder {
65 |
66 | private final DatabaseWrapper mDatabaseWrapper;
67 | private List mTransactionProcessList;
68 |
69 | /**
70 | * Creates a new builder with a specific database wrapper.
71 | * @param databaseWrapper The database wrapper to run the transaction against
72 | */
73 | public Builder(@NonNull DatabaseWrapper databaseWrapper){
74 | mTransactionProcessList = new ArrayList<>();
75 | mDatabaseWrapper = databaseWrapper;
76 | }
77 |
78 | /**
79 | * Creates a new builder, using a Model class to derive the target database. The class passed
80 | * to the parameter does not restrict the tables on which the database operations are performed.
81 | * As long as the operations run on a single database.
82 | * @param clazz The model class used to derive the target database.
83 | */
84 | public Builder(@NonNull Class extends Model> clazz){
85 | mTransactionProcessList = new ArrayList<>();
86 | mDatabaseWrapper = FlowManager.getDatabaseForTable(clazz).getWritableDatabase();
87 | }
88 |
89 | /**
90 | * Adds a new transaction operation to be performed within a transaction block.
91 | * @param operation The operation to perform
92 | * @return An instance of the current builder object.
93 | */
94 | public Builder addOperation(@NonNull TransactionOperation operation){
95 | mTransactionProcessList.add(operation);
96 | return this;
97 | }
98 |
99 | /**
100 | * Builds a new GenericTransactionBlock observable which will run all database operations within
101 | * a single transaction once it's subscribed to.
102 | * @return A new GenericTransactionBlock containing all database operations
103 | */
104 | public RxGenericTransactionBlock build(){
105 | return new RxGenericTransactionBlock(this);
106 | }
107 | }
108 |
109 | /**
110 | * Represents a single transaction operation to perform within a transaction block.
111 | */
112 | public interface TransactionOperation {
113 | boolean onProcess(DatabaseWrapper databaseWrapper);
114 | }
115 | }
116 |
--------------------------------------------------------------------------------
/RxDbFlow-Rx1/src/main/java/au/com/roadhouse/rxdbflow/rx1/structure/RxBaseModel.java:
--------------------------------------------------------------------------------
1 | package au.com.roadhouse.rxdbflow.rx1.structure;
2 |
3 | import android.support.annotation.Nullable;
4 |
5 | import com.raizlabs.android.dbflow.structure.BaseModel;
6 | import com.raizlabs.android.dbflow.structure.InvalidDBConfiguration;
7 | import com.raizlabs.android.dbflow.structure.database.DatabaseWrapper;
8 |
9 | import au.com.roadhouse.rxdbflow.rx1.RxDbFlow;
10 | import rx.Observable;
11 |
12 | /**
13 | * A DBFlow BaseModel implementation which provides observables for saving, updating, inserting, and
14 | * deleting operations.
15 | */
16 | @SuppressWarnings("unchecked")
17 | public class RxBaseModel extends BaseModel implements RxModifications {
18 |
19 | private RxModelAdapter extends RxBaseModel> mModelAdapter;
20 |
21 | /**
22 | * Returns an observable for saving the object in the database
23 | * @return An observable
24 | */
25 | public Observable saveAsObservable(){
26 | return getRxModelAdapter().saveAsObservable(this);
27 | }
28 |
29 | /**
30 | * Returns an observable for saving the object in the database
31 | * @param databaseWrapper The database wrapper for the database holding the table
32 | * @return An observable
33 | */
34 | @SuppressWarnings("unchecked")
35 | public Observable saveAsObservable(@Nullable final DatabaseWrapper databaseWrapper){
36 | return getRxModelAdapter().saveAsObservable(this, databaseWrapper);
37 | }
38 |
39 | /**
40 | * Returns an observable for inserting the object in the database
41 | * @return An observable
42 | */
43 | public Observable insertAsObservable(){
44 | return getRxModelAdapter().insertAsObservable(this);
45 | }
46 |
47 | /**
48 | * Returns an observable for inserting the object in the database
49 | * @param databaseWrapper The database wrapper for the database holding the table
50 | * @return An observable
51 | */
52 | public Observable insertAsObservable(@Nullable final DatabaseWrapper databaseWrapper){
53 | return getRxModelAdapter().insertAsObservable(this, databaseWrapper);
54 | }
55 |
56 | /**
57 | * Returns an observable for deleting the object from the database
58 | * @return An observable
59 | */
60 | public Observable deleteAsObservable(){
61 | return getRxModelAdapter().deleteAsObservable(this);
62 | }
63 |
64 | /**
65 | * Returns an observable for deleting the object from the database
66 | * @param databaseWrapper The database wrapper for the database holding the table
67 | * @return An observable
68 | */
69 | public Observable deleteAsObservable(@Nullable final DatabaseWrapper databaseWrapper){
70 | return getRxModelAdapter().deleteAsObservable(this, databaseWrapper);
71 | }
72 |
73 | /**
74 | * Returns an observable for update the object in the database
75 | * @return An observable
76 | */
77 | public Observable updateAsObservable(){
78 | return getRxModelAdapter().updateAsObservable(this);
79 | }
80 |
81 | /**
82 | * Returns an observable for update in object from the database
83 | * @param databaseWrapper The database wrapper for the database holding the table
84 | * @return An observable
85 | */
86 | public Observable updateAsObservable(@Nullable final DatabaseWrapper databaseWrapper){
87 | return getRxModelAdapter().updateAsObservable(this, databaseWrapper);
88 | }
89 |
90 | /**
91 | * Returns an observable which will refresh the model's data based on the primary key when subscribed.
92 | * @return An observable
93 | */
94 | public Observable loadAsObservable(){
95 | return getRxModelAdapter().loadAsObservable(this);
96 | }
97 |
98 | /**
99 | * Returns an observable which will refresh the model's data based on the primary key when subscribed.
100 | * @param databaseWrapper The database wrapper for the database holding the table
101 | * @return An observable
102 | */
103 | public Observable loadAsObservable(@Nullable final DatabaseWrapper databaseWrapper){
104 | return getRxModelAdapter().loadAsObservable(this, databaseWrapper);
105 | }
106 |
107 | /**
108 | * @return The associated {@link RxModelAdapter}. The {@link RxDbFlow}
109 | * may throw a {@link InvalidDBConfiguration} for this call if this class
110 | * is not associated with a table, so be careful when using this method.
111 | */
112 | public RxModelAdapter getRxModelAdapter() {
113 | if (mModelAdapter == null) {
114 | mModelAdapter = RxDbFlow.getModelAdapter(getClass());
115 | }
116 | return mModelAdapter;
117 | }
118 | }
119 |
120 |
121 |
--------------------------------------------------------------------------------
/RxDbFlow-Rx1/src/main/java/au/com/roadhouse/rxdbflow/rx1/structure/RxModifications.java:
--------------------------------------------------------------------------------
1 | package au.com.roadhouse.rxdbflow.rx1.structure;
2 |
3 | import android.support.annotation.Nullable;
4 |
5 | import com.raizlabs.android.dbflow.structure.database.DatabaseWrapper;
6 |
7 | import rx.Observable;
8 |
9 | /**
10 | * Provides a common interface for any
11 | * @param
12 | */
13 | public interface RxModifications {
14 |
15 | Observable saveAsObservable();
16 |
17 | Observable saveAsObservable(@Nullable DatabaseWrapper databaseWrapper);
18 |
19 | Observable insertAsObservable();
20 |
21 | Observable insertAsObservable(@Nullable DatabaseWrapper databaseWrapper);
22 |
23 | Observable deleteAsObservable();
24 |
25 | Observable deleteAsObservable(@Nullable DatabaseWrapper databaseWrapper);
26 |
27 | Observable updateAsObservable();
28 |
29 | Observable updateAsObservable(@Nullable DatabaseWrapper databaseWrapper);
30 | }
31 |
--------------------------------------------------------------------------------
/RxDbFlow-Rx1/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | rxdbflow
3 |
4 |
--------------------------------------------------------------------------------
/RxDbFlow-Rx2/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/RxDbFlow-Rx2/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'com.github.dcendents.android-maven'
3 | group='com.github.roadhouse-dev'
4 | project.archivesBaseName="rxdbflow-rx2"
5 |
6 | android {
7 | compileSdkVersion 25
8 | buildToolsVersion "25.0.2"
9 |
10 | defaultConfig {
11 | minSdkVersion 14
12 | targetSdkVersion 25
13 | versionCode 10
14 | versionName "4.2.0.1"
15 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
16 | }
17 | buildTypes {
18 | release {
19 | minifyEnabled false
20 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
21 | }
22 | }
23 |
24 | lintOptions {
25 | abortOnError false
26 | }
27 | }
28 |
29 | dependencies {
30 | compile fileTree(dir: 'libs', include: ['*.jar'])
31 | compile 'com.github.Raizlabs.DBFlow:dbflow:4.0.0-beta7'
32 | compile 'io.reactivex.rxjava2:rxjava:2.0.5'
33 | compile 'com.android.support:support-annotations:25.3.1'
34 | testCompile 'junit:junit:4.12'
35 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
36 | exclude group: 'com.android.support', module: 'support-annotations'
37 | })
38 | }
39 |
40 | task sourcesJar(type: Jar) {
41 | from android.sourceSets.main.java.srcDirs
42 | classifier = 'sources'
43 | }
44 | task javadoc(type: Javadoc) {
45 | source = android.sourceSets.main.java.srcDirs
46 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
47 | failOnError false
48 | }
49 | task javadocJar(type: Jar, dependsOn: javadoc) {
50 | classifier = 'javadoc'
51 | from javadoc.destinationDir
52 | }
53 |
54 | task(type: Zip, "zipTestReport") {
55 | from("${rootDir.absolutePath}/library/build/reports/androidTests/connected/")
56 | archiveName 'test_report_library.zip'
57 | destinationDir file("${rootDir.absolutePath}/library/build/reports/")
58 | }
59 |
60 | configure(zipTestReport) {
61 | group = 'verification'
62 | description = 'Create a test report archive'
63 | }
64 |
65 | task(type: Zip, "zipLintReport") {
66 | from "${rootDir.absolutePath}/library/build/outputs/"
67 | include "lint-results-debug.html"
68 | include "lint-results-debug_files/*"
69 | archiveName 'lint_report_library.zip'
70 | destinationDir file("${rootDir.absolutePath}/library/build/reports/")
71 | }
72 |
73 | configure(zipLintReport) {
74 | group = 'verification'
75 | description = 'Create a lint report archive'
76 | }
77 |
78 | artifacts {
79 | archives sourcesJar
80 | archives javadocJar
81 | }
82 |
83 |
84 |
--------------------------------------------------------------------------------
/RxDbFlow-Rx2/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/dwaynehoy/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/RxDbFlow-Rx2/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
--------------------------------------------------------------------------------
/RxDbFlow-Rx2/src/main/java/au/com/roadhouse/rxdbflow/rx2/DBFlowSchedulers.java:
--------------------------------------------------------------------------------
1 | package au.com.roadhouse.rxdbflow.rx2;
2 |
3 | import java.util.concurrent.ArrayBlockingQueue;
4 | import java.util.concurrent.BlockingQueue;
5 | import java.util.concurrent.ThreadPoolExecutor;
6 | import java.util.concurrent.TimeUnit;
7 |
8 | import io.reactivex.Scheduler;
9 | import io.reactivex.schedulers.Schedulers;
10 |
11 |
12 | public class DBFlowSchedulers {
13 |
14 | private static Scheduler sScheduler;
15 |
16 | /**
17 | * A single threaded background scheduler, this should be used for dbflow observable operations
18 | * to avoid slamming the connection pool with multiple connection.
19 | *
20 | * @return A DBFlow background scheduler
21 | */
22 | public static Scheduler background() {
23 | if (sScheduler == null) {
24 | BlockingQueue threadQueue = new ArrayBlockingQueue<>(200);
25 | ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(1, 1, 1, TimeUnit.SECONDS, threadQueue);
26 | sScheduler = Schedulers.from(threadPoolExecutor);
27 | }
28 |
29 | return sScheduler;
30 | }
31 | }
--------------------------------------------------------------------------------
/RxDbFlow-Rx2/src/main/java/au/com/roadhouse/rxdbflow/rx2/RxDbFlow.java:
--------------------------------------------------------------------------------
1 | package au.com.roadhouse.rxdbflow.rx2;
2 |
3 | import com.raizlabs.android.dbflow.config.FlowManager;
4 |
5 | import au.com.roadhouse.rxdbflow.rx2.structure.RxModelAdapter;
6 |
7 | public class RxDbFlow {
8 |
9 | public static RxModelAdapter getModelAdapter(Class modelClass) {
10 | return new RxModelAdapter<>(FlowManager.getModelAdapter(modelClass));
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/RxDbFlow-Rx2/src/main/java/au/com/roadhouse/rxdbflow/rx2/sql/language/BaseModelQueriableObservable.java:
--------------------------------------------------------------------------------
1 | package au.com.roadhouse.rxdbflow.rx2.sql.language;
2 |
3 | import com.raizlabs.android.dbflow.list.FlowCursorList;
4 | import com.raizlabs.android.dbflow.list.FlowQueryList;
5 | import com.raizlabs.android.dbflow.sql.language.BaseModelQueriable;
6 | import com.raizlabs.android.dbflow.sql.language.CursorResult;
7 | import com.raizlabs.android.dbflow.sql.queriable.ModelQueriable;
8 | import com.raizlabs.android.dbflow.structure.BaseQueryModel;
9 | import com.raizlabs.android.dbflow.structure.database.DatabaseWrapper;
10 |
11 | import java.util.List;
12 |
13 | import au.com.roadhouse.rxdbflow.rx2.sql.observables.DBFlowCursorListSingle;
14 | import au.com.roadhouse.rxdbflow.rx2.sql.observables.DBFlowCustomListSingle;
15 | import au.com.roadhouse.rxdbflow.rx2.sql.observables.DBFlowCustomModelSingle;
16 | import au.com.roadhouse.rxdbflow.rx2.sql.observables.DBFlowListSingle;
17 | import au.com.roadhouse.rxdbflow.rx2.sql.observables.DBFlowMaybe;
18 | import au.com.roadhouse.rxdbflow.rx2.sql.observables.DBFlowModelMaybe;
19 | import au.com.roadhouse.rxdbflow.rx2.sql.observables.DBFlowModelSingle;
20 | import au.com.roadhouse.rxdbflow.rx2.sql.observables.DBFlowQueryListSingle;
21 | import au.com.roadhouse.rxdbflow.rx2.sql.observables.DBFlowResultSingle;
22 | import au.com.roadhouse.rxdbflow.rx2.sql.observables.DBFlowSingle;
23 |
24 |
25 | public class BaseModelQueriableObservable extends BaseQueriableObservable implements ModelQueriableObservable {
26 |
27 | private ModelQueriable mRealModelQueriable;
28 |
29 | protected BaseModelQueriableObservable(BaseModelQueriable realModelQueriable) {
30 | super(realModelQueriable);
31 | mRealModelQueriable = realModelQueriable;
32 | }
33 |
34 | @Override
35 | public DBFlowSingle asSingle() {
36 | return new DBFlowModelSingle(mRealModelQueriable.getTable(), mRealModelQueriable, null);
37 | }
38 |
39 | @Override
40 | public DBFlowMaybe asMaybe() {
41 | return new DBFlowModelMaybe(mRealModelQueriable.getTable(), mRealModelQueriable, null);
42 | }
43 |
44 | @Override
45 | public DBFlowSingle asSingle(DatabaseWrapper databaseWrapper) {
46 | return new DBFlowModelSingle<>(mRealModelQueriable.getTable(), mRealModelQueriable, databaseWrapper);
47 | }
48 |
49 | @Override
50 | public DBFlowSingle> asListSingle() {
51 | return new DBFlowListSingle<>(mRealModelQueriable.getTable(), mRealModelQueriable, null);
52 | }
53 |
54 | @Override
55 | public DBFlowSingle> asListSingle(DatabaseWrapper databaseWrapper) {
56 | return new DBFlowListSingle<>(mRealModelQueriable.getTable(), mRealModelQueriable, databaseWrapper);
57 | }
58 |
59 | @Override
60 | public DBFlowSingle> asResultsSingle() {
61 | return new DBFlowResultSingle<>(mRealModelQueriable.getTable(), mRealModelQueriable);
62 | }
63 |
64 | @Override
65 | public DBFlowSingle> asQueryListSingle() {
66 | return new DBFlowQueryListSingle<>(mRealModelQueriable.getTable(), mRealModelQueriable);
67 | }
68 |
69 | @Override
70 | public DBFlowSingle> asCursorListSingle() {
71 | return new DBFlowCursorListSingle<>(mRealModelQueriable.getTable(), mRealModelQueriable);
72 | }
73 |
74 | @Override
75 | public DBFlowSingle asCustomSingle(Class customClazz) {
76 | return new DBFlowCustomModelSingle<>(customClazz, mRealModelQueriable.getTable(), mRealModelQueriable);
77 | }
78 |
79 | @Override
80 | public DBFlowSingle> asCustomListObservable(Class customClazz) {
81 | return new DBFlowCustomListSingle<>(customClazz, mRealModelQueriable.getTable(), mRealModelQueriable);
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/RxDbFlow-Rx2/src/main/java/au/com/roadhouse/rxdbflow/rx2/sql/language/BaseQueriableObservable.java:
--------------------------------------------------------------------------------
1 | package au.com.roadhouse.rxdbflow.rx2.sql.language;
2 |
3 | import android.database.Cursor;
4 |
5 | import com.raizlabs.android.dbflow.sql.language.BaseQueriable;
6 | import com.raizlabs.android.dbflow.sql.queriable.Queriable;
7 | import com.raizlabs.android.dbflow.structure.database.DatabaseWrapper;
8 |
9 | import au.com.roadhouse.rxdbflow.rx2.sql.observables.DBFlowCountSingle;
10 | import au.com.roadhouse.rxdbflow.rx2.sql.observables.DBFlowCursorSingle;
11 | import au.com.roadhouse.rxdbflow.rx2.sql.observables.DBFlowExecuteCompletable;
12 | import au.com.roadhouse.rxdbflow.rx2.sql.observables.DBFlowSingle;
13 |
14 | public class BaseQueriableObservable implements QueriableObservable {
15 | private BaseQueriable mRealQueriable;
16 |
17 | public BaseQueriableObservable(BaseQueriable queriable) {
18 | mRealQueriable = queriable;
19 | }
20 |
21 | /**
22 | * {@inheritDoc}
23 | */
24 | @Override
25 | public DBFlowSingle asCountSingle() {
26 | return new DBFlowCountSingle(mRealQueriable.getTable(), mRealQueriable, null);
27 | }
28 |
29 | /**
30 | * {@inheritDoc}
31 | */
32 | @Override
33 | public DBFlowSingle asCountSingle(DatabaseWrapper databaseWrapper) {
34 | return new DBFlowCountSingle(mRealQueriable.getTable(), mRealQueriable, databaseWrapper);
35 | }
36 |
37 | /**
38 | * {@inheritDoc}
39 | */
40 | @Override
41 | public DBFlowExecuteCompletable asExecuteCompletable() {
42 | return new DBFlowExecuteCompletable<>(mRealQueriable.getTable(), mRealQueriable, null);
43 | }
44 |
45 | /**
46 | * {@inheritDoc}
47 | */
48 | @Override
49 | public DBFlowExecuteCompletable asExecuteCompletable(DatabaseWrapper databaseWrapper) {
50 | return new DBFlowExecuteCompletable<>(mRealQueriable.getTable(), mRealQueriable, databaseWrapper);
51 | }
52 |
53 | /**
54 | * {@inheritDoc}
55 | */
56 | @Override
57 | public DBFlowSingle asQuerySingle() {
58 | return new DBFlowCursorSingle<>(mRealQueriable.getTable(), mRealQueriable, null);
59 | }
60 |
61 | public Queriable getRealQueriable() {
62 | return mRealQueriable;
63 | }
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/RxDbFlow-Rx2/src/main/java/au/com/roadhouse/rxdbflow/rx2/sql/language/ModelQueriableObservable.java:
--------------------------------------------------------------------------------
1 | package au.com.roadhouse.rxdbflow.rx2.sql.language;
2 |
3 | import com.raizlabs.android.dbflow.list.FlowCursorList;
4 | import com.raizlabs.android.dbflow.list.FlowQueryList;
5 | import com.raizlabs.android.dbflow.sql.language.CursorResult;
6 | import com.raizlabs.android.dbflow.structure.BaseQueryModel;
7 | import com.raizlabs.android.dbflow.structure.database.DatabaseWrapper;
8 |
9 | import java.util.List;
10 |
11 | import au.com.roadhouse.rxdbflow.rx2.sql.observables.DBFlowMaybe;
12 | import au.com.roadhouse.rxdbflow.rx2.sql.observables.DBFlowSingle;
13 |
14 |
15 | public interface ModelQueriableObservable extends QueriableObservable {
16 |
17 | /**
18 | * Creates an Single that emits a single model from a query. This will be the first record
19 | * returned by the query.
20 | * @return An Single that emits a single model
21 | */
22 | DBFlowSingle asSingle();
23 |
24 | /**
25 | * Creates an Maybe that emits a single model or null from a query. This will be the first record
26 | * returned by the query or null if the query was empty.
27 | * @return An Single that emits a single model
28 | */
29 | DBFlowMaybe asMaybe();
30 |
31 | /**
32 | * Creates an Single that emits a single model from a query. This will be the first record
33 | * returned by the query.
34 | * @param databaseWrapper The database wrapper from which to run the query
35 | * @return An Single that emits a single model
36 | */
37 | DBFlowSingle