使用CircleImageView解析Uri

时间:2018-02-17 18:29:39

标签: android firebase firebase-authentication

如何使用uri解析de.hdodenhof.circleimageview.CircleImageView

Error.png

我的代码

 protected void onActivityResult(int requestCode, int resultCode, Intent data){
super.onActivityResult(requestCode, resultCode, data);

if (requestCode == REQUEST_CODE && resultCode == RESULT_OK) {

    final Uri uri = data.getData();

    StorageReference path = mStoragereference.child("Photos").child(uri.getLastPathSegment());


    path.putFile(uri).addOnSuccessListener(new OnSuccessListener < UploadTask.TaskSnapshot > () {
        @Override
        public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {

            FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();

            UserProfileChangeRequest profileUpdate = new UserProfileChangeRequest.Builder()
                .setPhotoUri(Uri.parse(userPhoto))
                .build();

            if (userPhoto == null) {
              Toast.makeText(EditInfo.this, "Error updating image",
                             Toast.LENGTH_SHORT).show();
            }

感谢您的回复!

1 个答案:

答案 0 :(得分:0)

CircleImageView is a subclass of ImageView以来,它继承了properties/methods from ImageView的大部分内容。

不幸的是,似乎是ImageView doesn't expose its source URI,因此您必须保留传递到CircleImageView周围的URI。