0
storageReference.child("ProfilePicture")
    .child(currUser.getUid())
    .getDownloadUrl()
    .addOnSuccessListener(new OnSuccessListener<Uri>() {

        @Override
        public void onSuccess(Uri uri) {
            profilePicture = storageReference.child("ProfilePicture").child(currUser.getUid());
            Glide.with(getBaseContext())
                    .using(new FirebaseImageLoader())
                    .load(profilePicture)
                    .signature(new StringSignature(String.valueOf(System.currentTimeMillis())))
                    .into(profilePictures)
                    .listener(new RequestListener<URL, GlideDrawable>() {
                        @Override
                        public boolean onException(Exception e, URL model, Target<GlideDrawable> target, boolean isFirstResource) {
                            progressDialogCreate.hide();
                            return false;
                        }
                        @Override
                        public boolean onResourceReady(GlideDrawable resource, URL model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
                            progressDialogCreate.hide();
                            return false;
                        }
                    });
            profilePictures.setVisibility(View.VISIBLE);
        }
    });

I'm getting this error,

I'm getting this error:

Can someone explain why this is happening?

K Neeraj Lal
  • 6,768
  • 3
  • 24
  • 33

3 Answers3

1

Try this:-

Use this dependency to use GlideDrawable method of Glide and .using(new FirebaseImageLoader()) method of FirebaseUi

compile 'com.firebaseui:firebase-ui-storage:0.6.0'
compile 'com.github.bumptech.glide:glide:3.8.0'

Glide.with(MainActivity.this)
                    .using(new FirebaseImageLoader())
                    .load(profilePicture)
                    .signature(new StringSignature(String.valueOf(System.currentTimeMillis())))
                    .into(profilePictures)
                    .listener(new RequestListener<URL, GlideDrawable>() {
                        @Override
                        public boolean onException(Exception e, URL model, Target<GlideDrawable> target, boolean isFirstResource) {
                            progressDialogCreate.hide();
                            return false;
                        }

                        @Override
                        public boolean onResourceReady(GlideDrawable resource, URL model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
                            progressDialogCreate.hide();
                            return false;
                        }
                    });

Edit:-

Try to apply listener like this.

Glide.with(MainActivity.this)
                .using(new FirebaseImageLoader())
                .load(profilePicture)
                .signature(new StringSignature(String.valueOf(System.currentTimeMillis())))
                .into(new GlideDrawableImageViewTarget(profilePictures) {
                    @Override
                    public void onResourceReady(GlideDrawable resource, GlideAnimation<? super GlideDrawable> animation) {
                        super.onResourceReady(resource, animation);
                        //try to hide here
                    }

                    @Override
                    public void onLoadFailed(Exception e, Drawable errorDrawable) {
                        super.onLoadFailed(e, errorDrawable);
                        //try to hide here
                    }
                });
0

You have the wrong order between the methods. into(profilePictures) will return a variable of type Target<GlideDrawable>, but listener needs to be called by a DrawableTypeRequest. Switch the order between into and listener and it should work.

Iulian Popescu
  • 2,595
  • 4
  • 23
  • 31
  • Well the error dissaperead, I had to change the parameter type too ( `URL` to `StorageReference`), but even if the image is loaded or not, it doesn't call none of the functions – Suto-Minyukus Tamas Dec 14 '17 at 09:18
  • How do you check to see if they are called? – Iulian Popescu Dec 14 '17 at 09:32
  • The progressDialog doesn't dissapear, even if the image is loaded and after I have tried with a Toast but it doesn't show up – Suto-Minyukus Tamas Dec 14 '17 at 09:38
  • Ok, I think that the issue is that your imageview is hidden. If it is hidden, then the load doesn't start, hence no callback called. Check this for more details https://stackoverflow.com/questions/32503327/glide-listener-doesnt-work – Iulian Popescu Dec 14 '17 at 09:50
  • its not hidden `` – Suto-Minyukus Tamas Dec 14 '17 at 11:18
  • Then why do you call this `profilePictures.setVisibility(View.VISIBLE);`? – Iulian Popescu Dec 14 '17 at 11:23
  • When I created the ImageView, I set it hidden in the xml file, but later I changed the code and I forget there that row in the java file. But it doesn't work even if I let there or I delete that row. – Suto-Minyukus Tamas Dec 14 '17 at 11:35
  • Did you tried other solutions from the link I provided? If the answer is yes, I think that you should open another question and ask that, because right now we are discussing something that is not related to the original question (which is solved now) – Iulian Popescu Dec 14 '17 at 11:42
0

GlideDrawable are deprecated, use listener like this.

            Glide.with(mContext)
                .load(item.getFriendUserPhotoUrl())
                .listener(new RequestListener<Drawable>() {
                    @Override
                    public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {

                        fullname.setVisibility(View.VISIBLE);
                        progressBar.setVisibility(View.GONE);
                        imageView.setImageResource(R.drawable.profile_default_photo);
                        return false;
                    }

                    @Override
                    public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {

                        progressBar.setVisibility(View.GONE);
                        fullname.setVisibility(View.VISIBLE);
                        return false;
                    }
                })
                .into(holder.thumbnail);
Said Erraoudy
  • 1,490
  • 1
  • 13
  • 21