I just wanted to improve downloading files from Firebase Storage using the progress dialog box.
.addOnProgressListener(new OnProgressListener<UploadTask.TaskSnapshot>() {
@Override
public void onProgress(UploadTask.TaskSnapshot taskSnapshot) {
double progress = (100.0 * taskSnapshot.getBytesTransferred()) / taskSnapshot.getTotalByteCount();
progressDialog.setMessage((int) progress + "");
}
});
But the getBytesTransferred () and getTotalByteCount methods of the TaskSnapshot class do not allow calling here. Android Studio says: this method should be accessed only from a test or in a closed scope. The documentation does not say that there are any problems, and it seemed like a normal way to show progress ( update the progress bar with Firebase loading )
So why don't the methods want to be called?
Change: Works with @SuppressWarnings("VisibleForTests")
source
share