|
33 | 33 | import io.reactivex.SingleOnSubscribe;
|
34 | 34 | import io.reactivex.functions.Cancellable;
|
35 | 35 | import io.reactivex.functions.Function;
|
36 |
| -import io.reactivex.functions.Predicate; |
37 | 36 |
|
38 |
| -public class RxFirebaseDatabase { |
| 37 | +import static durdinapps.rxfirebase2.DataSnapshotMapper.DATA_SNAPSHOT_EXISTENCE_PREDICATE; |
39 | 38 |
|
40 |
| - public static final Predicate<DataSnapshot> DATA_SNAPSHOT_EXISTENCE_PREDICATE = new Predicate<DataSnapshot>() { |
41 |
| - @Override |
42 |
| - public boolean test(@io.reactivex.annotations.NonNull DataSnapshot dataSnapshot) throws Exception { |
43 |
| - return dataSnapshot.exists(); |
44 |
| - } |
45 |
| - }; |
| 39 | +public class RxFirebaseDatabase { |
46 | 40 |
|
47 | 41 | /**
|
48 | 42 | * Listener for changes in te data at the given query location.
|
@@ -163,7 +157,7 @@ public static Completable setValue(@NonNull final DatabaseReference ref,
|
163 | 157 | final Object value) {
|
164 | 158 | return Completable.create(new CompletableOnSubscribe() {
|
165 | 159 | @Override
|
166 |
| - public void subscribe(@io.reactivex.annotations.NonNull final CompletableEmitter e) throws Exception { |
| 160 | + public void subscribe(@NonNull final CompletableEmitter e) throws Exception { |
167 | 161 | ref.setValue(value).addOnSuccessListener(new OnSuccessListener<Void>() {
|
168 | 162 | @Override public void onSuccess(Void aVoid) {
|
169 | 163 | e.onComplete();
|
@@ -274,7 +268,7 @@ public static Flowable<DataSnapshot> observeMultipleSingleValueEvent(@NonNull Da
|
274 | 268 | return Maybe.merge(Flowable.fromArray(whereRefs)
|
275 | 269 | .map(new Function<DatabaseReference, MaybeSource<? extends DataSnapshot>>() {
|
276 | 270 | @Override
|
277 |
| - public MaybeSource<? extends DataSnapshot> apply(@io.reactivex.annotations.NonNull DatabaseReference databaseReference) throws |
| 271 | + public MaybeSource<? extends DataSnapshot> apply(@NonNull DatabaseReference databaseReference) throws |
278 | 272 | Exception {
|
279 | 273 | return observeSingleValueEvent(databaseReference);
|
280 | 274 | }
|
@@ -304,7 +298,7 @@ public static Maybe<DatabaseReference[]> requestFilteredReferenceKeys(@NonNull f
|
304 | 298 | @NonNull Query whereRef) {
|
305 | 299 | return observeSingleValueEvent(whereRef, new Function<DataSnapshot, DatabaseReference[]>() {
|
306 | 300 | @Override
|
307 |
| - public DatabaseReference[] apply(@io.reactivex.annotations.NonNull DataSnapshot dataSnapshot) throws Exception { |
| 301 | + public DatabaseReference[] apply(@NonNull DataSnapshot dataSnapshot) throws Exception { |
308 | 302 | int childrenCount = (int) dataSnapshot.getChildrenCount();
|
309 | 303 | DatabaseReference[] filterRefs = new DatabaseReference[childrenCount];
|
310 | 304 | final Iterator<DataSnapshot> iterator = dataSnapshot.getChildren().iterator();
|
|
0 commit comments