如果我已经拥有一个,如何使三个具有相同功能的ListViews

时间:2019-06-07 20:36:28

标签: android android-intent android-listview picasso

我有一个ListView,当您按下按钮时,将其制作一张照片并将其保存到Firebase存储中。我想使2个以上的ListViews能够相同地工作,但现在我不知道如何更改这样的代码:

try {
        localFile = createTempImageFile(getExternalCacheDir());
        final File finalLocalFile = localFile;

        mStorageRef.child("images/" + mRereference).getFile(localFile)
                .addOnSuccessListener(new OnSuccessListener<FileDownloadTask.TaskSnapshot>() {
                    @Override
                    public void onSuccess(FileDownloadTask.TaskSnapshot taskSnapshot) {
                        Picasso.with(getBaseContext())
                                .load(Uri.fromFile(finalLocalFile))
                           .into(mIVpicture2);
                    }
                }).addOnFailureListener(new OnFailureListener() {
            @Override
            public void onFailure(@NonNull Exception e) {
                Log.i("Load","" + e);
            }
        });

    } catch (IOException e) {
        e.printStackTrace();
    }
}

那一个:

 @Override
public void onActivityResult(int requestCode,int resultCode, Intent data){
    super.onActivityResult(requestCode , resultCode , data);
    switch (requestCode){
        case REQUEST_CODE_TAKE_PHOTO:
            if(resultCode == RESULT_OK) {
                if (data != null && data.getData() != null) {
                    mImageUri = getRealPathFromURI(data.getData());

                    Picasso.with(getBaseContext())
                            .load(data.getData())
                             .into(mIVpicture1); 
                    uploadFileInFireBaseStorage(data.getData());
                } else if (mImageUri != null) {
                    mImageUri = Uri.fromFile(mTempPhoto).toString();

                    Picasso.with(this)
                            .load(mImageUri)
                            .into(mIVpicture1);
                    uploadFileInFireBaseStorage(Uri.fromFile((mTempPhoto)));
                }
            }
            break;
    }
}

0 个答案:

没有答案