28
28
import java .util .Map ;
29
29
import java .util .concurrent .Executor ;
30
30
31
+ import durdinapps .rxfirebase2 .exceptions .RxFirebaseNullDataException ;
31
32
import io .reactivex .BackpressureStrategy ;
32
33
import io .reactivex .Completable ;
33
34
import io .reactivex .CompletableEmitter ;
@@ -133,6 +134,10 @@ public void subscribe(final SingleEmitter<DocumentReference> emitter) {
133
134
ref .add (data ).addOnCompleteListener (new OnCompleteListener <DocumentReference >() {
134
135
@ Override
135
136
public void onComplete (@ NonNull Task <DocumentReference > task ) {
137
+ if (task .getResult () == null ){
138
+ emitter .onError (new RxFirebaseNullDataException (task .getException ()));
139
+ return ;
140
+ }
136
141
emitter .onSuccess (task .getResult ());
137
142
}
138
143
}).addOnFailureListener (new OnFailureListener () {
@@ -162,6 +167,10 @@ public void subscribe(final SingleEmitter<DocumentReference> emitter) {
162
167
ref .add (pojo ).addOnCompleteListener (new OnCompleteListener <DocumentReference >() {
163
168
@ Override
164
169
public void onComplete (@ NonNull Task <DocumentReference > task ) {
170
+ if (task .getResult () == null ){
171
+ emitter .onError (new RxFirebaseNullDataException (task .getException ()));
172
+ return ;
173
+ }
165
174
emitter .onSuccess (task .getResult ());
166
175
}
167
176
}).addOnFailureListener (new OnFailureListener () {
@@ -186,7 +195,7 @@ public void onFailure(@NonNull Exception e) {
186
195
* @return a Single which emits the {@link DocumentReference} of the added Document.
187
196
*/
188
197
@ NonNull
189
- private static Completable addDocumentOffline (@ NonNull final CollectionReference ref ,
198
+ public static Completable addDocumentOffline (@ NonNull final CollectionReference ref ,
190
199
@ NonNull final Map <String , Object > data ) {
191
200
return Completable .create (new CompletableOnSubscribe () {
192
201
@ Override
@@ -212,7 +221,7 @@ public void subscribe(CompletableEmitter emitter) {
212
221
* @return a Single which emits the {@link DocumentReference} of the added Document.
213
222
*/
214
223
@ NonNull
215
- private static Completable addDocumentOffline (@ NonNull final CollectionReference ref ,
224
+ public static Completable addDocumentOffline (@ NonNull final CollectionReference ref ,
216
225
@ NonNull final Object pojo ) {
217
226
return Completable .create (new CompletableOnSubscribe () {
218
227
@ Override
@@ -1232,7 +1241,7 @@ public static <T> Maybe<List<T>> getCollection(@NonNull final CollectionReferenc
1232
1241
* @param mapper specific function to map the dispatched events.
1233
1242
*/
1234
1243
@ NonNull
1235
- private static <T > Maybe <List <T >> getCollection (CollectionReference ref ,
1244
+ public static <T > Maybe <List <T >> getCollection (CollectionReference ref ,
1236
1245
DocumentSnapshotMapper <QuerySnapshot ,
1237
1246
List <T >> mapper ) {
1238
1247
return getCollection (ref )
@@ -1259,7 +1268,7 @@ public static <T> Maybe<List<T>> getCollection(@NonNull final Query query,
1259
1268
* @param mapper specific function to map the dispatched events.
1260
1269
*/
1261
1270
@ NonNull
1262
- private static <T > Maybe <List <T >> getCollection (@ NonNull Query query ,
1271
+ public static <T > Maybe <List <T >> getCollection (@ NonNull Query query ,
1263
1272
@ NonNull DocumentSnapshotMapper <QuerySnapshot ,
1264
1273
List <T >> mapper ) {
1265
1274
return getCollection (query )
0 commit comments