Skip to content

Instantly share code, notes, and snippets.

@jirawatee
Last active April 17, 2019 05:03
Show Gist options
  • Select an option

  • Save jirawatee/c5f20aee09dd997cbcdfd143c61d1a96 to your computer and use it in GitHub Desktop.

Select an option

Save jirawatee/c5f20aee09dd997cbcdfd143c61d1a96 to your computer and use it in GitHub Desktop.
Firebase Storage - Download in memory
private void downloadInMemory() {
//long ONE_MEGABYTE = 1024 * 1024;
Helper.showDialog(this);
imageRef.getBytes(Long.MAX_VALUE).addOnSuccessListener(new OnSuccessListener<byte[]>() {
@Override
public void onSuccess(byte[] bytes) {
Helper.dismissDialog();
Bitmap bitmap = BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
mImageView.setImageBitmap(bitmap);
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception exception) {
Helper.dismissDialog();
mTextView.setText(String.format("Failure: %s", exception.getMessage()));
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment