0
Good guys I started working with firebase Torage, I was able to send and receive data from firebase normally using documentation.
However I would like the photo that the user sent and received was maintained even without internet access, someone knows how to do this ?
Fragment that receives the image
mStorageRef = FirebaseStorage.getInstance().getReference();
//imagens instancia
imageView = (ImageView) view.findViewById(R.id.imageView4);
btn_imagem = (ImageButton) view.findViewById(R.id.imageButton);
btn_imagem.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(Intent.ACTION_PICK);
i.setType("image/*");
startActivityForResult(i,GALERIA);
}
});
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(requestCode == GALERIA && resultCode == RESULT_OK){
progressDialog.setMax(100);
progressDialog.setTitle("Upload de imagem");
progressDialog.setMessage("Salvando...");
progressDialog.show();
Uri uri = data.getData();
StorageReference filepatch = mStorageRef.child("Fotos").child(uri.getLastPathSegment());
filepatch.putFile(uri).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
progressDialog.dismiss();
Uri imagemRecebida = taskSnapshot.getDownloadUrl();
Picasso.with(getActivity()).load(imagemRecebida).fit().centerCrop().into(imageView);
Toast.makeText(getActivity(), "Upload realizado com sucesso!!!",Toast.LENGTH_SHORT).show();
}
});
}
}
}