如何解决红线的问题(taskSnapshot)?

时间:2017-04-06 06:59:52

标签: android

如何解决红线问题( taskSnapshots

  

int progress =(int)((100.0 * taskSnapshot.getBytesTransferred())/   taskSnapshot.getTotalByteCount());

那条线路有什么问题?

    private void uploadImg(final String path){
        final Uri file = Uri.fromFile(new File(path));
        StorageMetadata metadata = new StorageMetadata.Builder()
                .setContentDisposition("universe")
                .setContentType("image/jpg")
                .build();
        riversRef = mStorageRef.child(file.getLastPathSegment());
        UploadTask uploadTask = riversRef.putFile(file, metadata);
        uploadTask.addOnFailureListener(new OnFailureListener() {
            @Override
            public void onFailure(@NonNull Exception exception) {
                uploadInfoText.setText(exception.getMessage());
            }
        }).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
            @Override
            public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
                uploadInfoText.setText(R.string.upload_success);
                Glide.with(NewPostActivity.this)
                        .load(file)
                        .into(downloadImg);

            }
        }).addOnProgressListener(new OnProgressListener<UploadTask.TaskSnapshot>() {
            @Override
            public void onProgress(UploadTask.TaskSnapshot taskSnapshot) {
                int progress = (int)((100.0 * taskSnapshot.getBytesTransferred()) / taskSnapshot.getTotalByteCount());
                imgUploadProgress.setProgress(progress);
                if(progress >= 100){
                    imgUploadProgress.setVisibility(View.GONE);
                }
            }
        });
    }

1 个答案:

答案 0 :(得分:0)

查看截图,我看到左边有一个红色灯泡。单击它,它应该提供错误和/或建议来修复错误。如果您可以编译应用程序并使用它,则可以使用以下命令禁用检查:

@SuppressWarnings("VisibleForTests")