gpt4 book ai didi

java - 未经检查地调用 'continueWithTask....' 作为原始类型的成员

转载 作者:行者123 更新时间:2023-12-01 16:49:32 25 4
gpt4 key购买 nike

我在所有三种方法上都收到此警告,我尝试在 stackoverflow 中搜索解决方案,但无法弄清楚可用的解决方案如何应用于我的情况。尽管代码按预期工作正常,但代码块以黄色突出显示,并且似乎不断要求注意。感谢您的帮助!

        final StorageReference storageReference = FirebaseStorage.getInstance().getReference()
.child(mStorageRef).child(mFileName);
final StorageTask storageTask = storageReference.putFile(intentDataUri);

storageTask.addOnProgressListener((OnProgressListener<UploadTask.TaskSnapshot>) taskSnapshot -> {
double p = 100.0 * taskSnapshot.getBytesTransferred() / taskSnapshot.getTotalByteCount();
progressDialog.setMessage((int) p + getString(R.string.percent_of) + taskSnapshot.getTotalByteCount() +getString(R.string.strUploading));
}).continueWithTask((Continuation) task -> {
if (!task.isSuccessful()) {
throw task.getException();
}
return storageReference.getDownloadUrl();
}).addOnCompleteListener((OnCompleteListener<Uri>) uriTask -> {

最佳答案

终于解决了这个问题,我修改了如下代码,它不再抛出该警告,用UploadTask替换StorageTask并且它起作用了 -

        final String messageID = databaseReference.child(getResources().getString(R.string.dbrefMessage)).child(mCurrentUserID)
.child(mMsgReceiverID).push().getKey();
final StorageReference storageReference = FirebaseStorage.getInstance().getReference()
.child(mStorageRef).child(mFileName);
final UploadTask uploadTask = storageReference.putFile(uri);

uploadTask.addOnProgressListener(taskSnapshot -> {
double p = 100.0 * taskSnapshot.getBytesTransferred() / taskSnapshot.getTotalByteCount();
progressDialog.setMessage((int) p + getString(R.string.percent_of) + taskSnapshot.getTotalByteCount() + getString(R.string.strUploading));
}).continueWithTask(task -> {
if(!task.isSuccessful()){
throw task.getException();
}
return storageReference.getDownloadUrl();
}).addOnCompleteListener(uriTask -> {

关于java - 未经检查地调用 'continueWithTask....' 作为原始类型的成员,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61720115/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com