uploadTask
.addOnSuccessListener(AdminDisplayProductActivity.this, new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(final UploadTask.TaskSnapshot taskSnapshot) {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
mProgressBar.setProgress(0);
downloadUrl = taskSnapshot.getMetadata().getReference().getDownloadUrl().toString();
AddProduct(downloadUrl);
Toast.makeText(AdminDisplayProductActivity.this, "Uploaded !" + downloadUrl, Toast.LENGTH_SHORT).show();
}
}, 500);
Toast.makeText(AdminDisplayProductActivity.this, "File Uploaded"
, Toast.LENGTH_SHORT).show();
}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Toast.makeText(AdminDisplayProductActivity.this, "Upload Fail !", Toast.LENGTH_SHORT).show();
}
})
.addOnProgressListener(new OnProgressListener<UploadTask.TaskSnapshot>() {
@Override
public void onProgress(UploadTask.TaskSnapshot taskSnapshot) {
double progress = (100.0 * taskSnapshot.getBytesTransferred() / taskSnapshot.getTotalByteCount());
mProgressBar.setProgress((int) progress);
}
});