com.google.firebase.storage.StreamDownloadTask Java Examples
The following examples show how to use
com.google.firebase.storage.StreamDownloadTask.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RxFirebaseStorageTests.java From RxFirebase with Apache License 2.0 | 6 votes |
@Test public void getStream() { TestSubscriber<StreamDownloadTask.TaskSnapshot> testSubscriber = new TestSubscriber<>(); RxFirebaseStorage.getStream(mockStorageRef) .subscribeOn(Schedulers.immediate()) .subscribe(testSubscriber); testOnSuccessListener.getValue().onSuccess(streamSnapshot); verify(mockStorageRef).getStream(); testSubscriber.assertNoErrors(); testSubscriber.assertValueCount(1); testSubscriber.assertReceivedOnNext(Collections.singletonList(streamSnapshot)); testSubscriber.assertNotCompleted(); testSubscriber.unsubscribe(); }
Example #2
Source File: RxFirebaseStorageTests.java From RxFirebase with Apache License 2.0 | 6 votes |
@Test public void getStreamProcessor() { TestSubscriber<StreamDownloadTask.TaskSnapshot> testSubscriber = new TestSubscriber<>(); RxFirebaseStorage.getStream(mockStorageRef, processor) .subscribeOn(Schedulers.immediate()) .subscribe(testSubscriber); testOnSuccessListener.getValue().onSuccess(streamSnapshot); verify(mockStorageRef).getStream(processor); testSubscriber.assertNoErrors(); testSubscriber.assertValueCount(1); testSubscriber.assertReceivedOnNext(Collections.singletonList(streamSnapshot)); testSubscriber.assertNotCompleted(); testSubscriber.unsubscribe(); }
Example #3
Source File: RxFirebaseStorageTest.java From rxfirebase with Apache License 2.0 | 6 votes |
@Test public void testGetStream() { mockSuccessfulResultForTask(mockStreamDownloadTask, mockStreamDownloadTaskSnapshot); when(mockStorageReference.getStream()).thenReturn(mockStreamDownloadTask); when(mockStreamDownloadTaskSnapshot.getTotalByteCount()).thenReturn(1000L); when(mockStreamDownloadTaskSnapshot.getBytesTransferred()).thenReturn(1000L); TestObserver<StreamDownloadTask.TaskSnapshot> obs = TestObserver.create(); RxFirebaseStorage.getStream(mockStorageReference).subscribe(obs); verifyAddOnCompleteListenerForTask(mockStreamDownloadTask); callOnComplete(mockStreamDownloadTask); obs.dispose(); callOnComplete(mockStreamDownloadTask); obs.assertNoErrors(); obs.assertComplete(); obs.assertValue(new Predicate<StreamDownloadTask.TaskSnapshot>() { @Override public boolean test(StreamDownloadTask.TaskSnapshot taskSnapshot) throws Exception { return taskSnapshot.getBytesTransferred() == taskSnapshot.getTotalByteCount() && taskSnapshot.getTotalByteCount() == 1000L; } }); }
Example #4
Source File: RxFirebaseStorageTest.java From rxfirebase with Apache License 2.0 | 6 votes |
@Test public void testGetStream_notSuccessful() { mockNotSuccessfulResultForTask(mockStreamDownloadTask, new IllegalStateException()); when(mockStorageReference.getStream()).thenReturn(mockStreamDownloadTask); TestObserver<StreamDownloadTask.TaskSnapshot> obs = TestObserver.create(); RxFirebaseStorage.getStream(mockStorageReference).subscribe(obs); verifyAddOnCompleteListenerForTask(mockStreamDownloadTask); callOnComplete(mockStreamDownloadTask); obs.dispose(); callOnComplete(mockStreamDownloadTask); obs.assertError(IllegalStateException.class); obs.assertNoValues(); }
Example #5
Source File: RxFirebaseStorageTest.java From rxfirebase with Apache License 2.0 | 6 votes |
@Test public void testGetStreamWithProcessor() { mockSuccessfulResultForTask(mockStreamDownloadTask, mockStreamDownloadTaskSnapshot); when(mockStorageReference.getStream(mockStreamProcessor)).thenReturn(mockStreamDownloadTask); when(mockStreamDownloadTaskSnapshot.getTotalByteCount()).thenReturn(1000L); when(mockStreamDownloadTaskSnapshot.getBytesTransferred()).thenReturn(1000L); TestObserver<StreamDownloadTask.TaskSnapshot> obs = TestObserver.create(); RxFirebaseStorage.getStream(mockStorageReference, mockStreamProcessor).subscribe(obs); verifyAddOnCompleteListenerForTask(mockStreamDownloadTask); callOnComplete(mockStreamDownloadTask); obs.dispose(); callOnComplete(mockStreamDownloadTask); obs.assertNoErrors(); obs.assertComplete(); obs.assertValue(new Predicate<StreamDownloadTask.TaskSnapshot>() { @Override public boolean test(StreamDownloadTask.TaskSnapshot taskSnapshot) throws Exception { return taskSnapshot.getBytesTransferred() == taskSnapshot.getTotalByteCount() && taskSnapshot.getTotalByteCount() == 1000L; } }); }
Example #6
Source File: RxFirebaseStorageTest.java From rxfirebase with Apache License 2.0 | 6 votes |
@Test public void testGetStreamWithProcessor_notSuccessful() { mockNotSuccessfulResultForTask(mockStreamDownloadTask, new IllegalStateException()); when(mockStorageReference.getStream(mockStreamProcessor)).thenReturn(mockStreamDownloadTask); TestObserver<StreamDownloadTask.TaskSnapshot> obs = TestObserver.create(); RxFirebaseStorage.getStream(mockStorageReference, mockStreamProcessor).subscribe(obs); verifyAddOnCompleteListenerForTask(mockStreamDownloadTask); callOnComplete(mockStreamDownloadTask); obs.dispose(); callOnComplete(mockStreamDownloadTask); obs.assertError(IllegalStateException.class); obs.assertNoValues(); }
Example #7
Source File: FirebaseImageLoader.java From FirebaseUI-Android with Apache License 2.0 | 6 votes |
@Override public void loadData(@NonNull Priority priority, @NonNull final DataCallback<? super InputStream> callback) { mStreamTask = mRef.getStream(); mStreamTask .addOnSuccessListener(new OnSuccessListener<StreamDownloadTask.TaskSnapshot>() { @Override public void onSuccess(StreamDownloadTask.TaskSnapshot snapshot) { mInputStream = snapshot.getStream(); callback.onDataReady(mInputStream); } }) .addOnFailureListener(new OnFailureListener() { @Override public void onFailure(@NonNull Exception e) { callback.onLoadFailed(e); } }); }
Example #8
Source File: FirebaseRequestHandler.java From android-instant-apps-demo with Apache License 2.0 | 5 votes |
@Override public Result load(Request request, int networkPolicy) throws IOException { Log.i(TAG, "load " + request.uri.toString()); StorageReference gsReference = firebaseStorage.getReferenceFromUrl(request.uri.toString()); StreamDownloadTask mStreamTask = gsReference.getStream(); InputStream inputStream; try { inputStream = Tasks.await(mStreamTask).getStream(); return new Result(BitmapFactory.decodeStream(inputStream), Picasso.LoadedFrom.NETWORK); } catch (ExecutionException | InterruptedException e) { throw new IOException(e); } }
Example #9
Source File: RxFirebaseStorage.java From RxFirebase with Apache License 2.0 | 5 votes |
@NonNull public static Observable<StreamDownloadTask.TaskSnapshot> getStream(@NonNull final StorageReference storageRef) { return Observable.unsafeCreate(new Observable.OnSubscribe<StreamDownloadTask.TaskSnapshot>() { @Override public void call(final Subscriber<? super StreamDownloadTask.TaskSnapshot> subscriber) { RxTask.assignOnTask(subscriber, storageRef.getStream()); } }); }
Example #10
Source File: RxFirebaseStorage.java From RxFirebase with Apache License 2.0 | 5 votes |
@NonNull public static Observable<StreamDownloadTask.TaskSnapshot> getStream(@NonNull final StorageReference storageRef, @NonNull final StreamDownloadTask.StreamProcessor processor) { return Observable.unsafeCreate(new Observable.OnSubscribe<StreamDownloadTask.TaskSnapshot>() { @Override public void call(final Subscriber<? super StreamDownloadTask.TaskSnapshot> subscriber) { RxTask.assignOnTask(subscriber, storageRef.getStream(processor)); } }); }
Example #11
Source File: RxFirebaseStorage.java From rxfirebase with Apache License 2.0 | 5 votes |
/** * @see StorageReference#getStream() */ @CheckReturnValue @NonNull public static Single<StreamDownloadTask.TaskSnapshot> getStream( @NonNull final StorageReference ref) { return RxTask.single(new Callable<Task<StreamDownloadTask.TaskSnapshot>>() { @Override public Task<StreamDownloadTask.TaskSnapshot> call() throws Exception { return ref.getStream(); } }); }
Example #12
Source File: RxFirebaseStorage.java From rxfirebase with Apache License 2.0 | 5 votes |
/** * @see StorageReference#getStream(StreamDownloadTask.StreamProcessor) */ @CheckReturnValue @NonNull public static Single<StreamDownloadTask.TaskSnapshot> getStream( @NonNull final StorageReference ref, @NonNull final StreamDownloadTask.StreamProcessor streamProcessor) { return RxTask.single(new Callable<Task<StreamDownloadTask.TaskSnapshot>>() { @Override public Task<StreamDownloadTask.TaskSnapshot> call() throws Exception { return ref.getStream(streamProcessor); } }); }