First look at this. I call a function uploadUserPdf() inside submitProfile()
public void submitProfile() {
if(!uploadUserPdf()) {
return;
}
else {
//...............
}
}
And Here is the uploadUserPdf() function
private boolean uploadUserBiodataPdf() {
Uri fileUri = Uri.parse(Pdf);
final StorageReference storageReference = FirebaseStorage.getInstance().getReference().child("Pictures");
StorageReference pdfRef = storageReference.child(mUser.getUid()).child(fileUri.getLastPathSegment());
pdfRef.putFile(fileUri).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
pdfRef.getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
@Override
public void onSuccess(Uri uri) {
Pdf = uri.toString();
Toast.makeText(ContinueProfile.this, "Pdf Uploaded", Toast.LENGTH_LONG).show();
}
});
}
});
return false;
}
I want to return true if file is successfully uploaded. But I cannot find any space to write return true. Is it possible to return the true value if file is successfully uploaded ??
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…