Using Firebase Storage image with Glide

前端 未结 6 2070
醉梦人生
醉梦人生 2020-12-03 18:08

There are tons of duplicated answers I had tried almost all of them but I am still not able to use Firebase storage image with Glide.

First of all I am using docs

6条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-03 18:53

    If you've uploaded little images for icons on to your Firebase storage, get rid off glide and that "model". It makes a lot of changes on its git. So your code should look like:

       StorageReference referenseLcl = FirebaseStorage.getInstance().getReference();
                    StorageReference islandRefLcl = referenseLcl.child(userLcl.getImageIconPath());
                    final long ONE_MEGABYTE = 1024 * 1024;
                    islandRefLcl.getBytes(ONE_MEGABYTE).addOnSuccessListener(bytesPrm -> {
                        Bitmap bmp = BitmapFactory.decodeByteArray(bytesPrm, 0, bytesPrm.length);
                        imageOfUser.setImageBitmap(bmp);
                    }).addOnFailureListener(new OnFailureListener() {
                        @Override
                        public void onFailure(@NonNull Exception exception) {
                            imageOfUser.setImageResource(R.mipmap.ic_launcher);
                        }
                    });
    

提交回复
热议问题