简体   繁体   中英

Unchecked call to 'continueWithTask…' as a member of raw type

I get this warning on all three methods, I tried to search stackoverflow for a solution but could not figure it out how the available solution would apply in my case. Even though the code works fine as expected but the code block gets highlighted in yellow and seems to constantly ask for attention. Thank you for your help!

        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 -> {

Finally resolved the issue, I modified the code as below and it no longer throws that warning, replaced StorageTask with UploadTask and it worked -

        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 -> {

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM