Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The image cannot be showed sometimes when used by Glide 3.7.0 #13

Closed
mikiller opened this issue Sep 8, 2016 · 4 comments
Closed

The image cannot be showed sometimes when used by Glide 3.7.0 #13

mikiller opened this issue Sep 8, 2016 · 4 comments
Assignees

Comments

@mikiller
Copy link

mikiller commented Sep 8, 2016

SimpleTarget target = new SimpleTarget<GlideBitmapDrawable>() {
            @Override
            public void onResourceReady(GlideBitmapDrawable resource, GlideAnimation glideAnimation) {

                selectRoundIv.setImageBitmap(resource.getBitmap());
            }
        };

Glide.with(context).load(path).into(target);

This is my code for loading url image. The "selectRoundIv" is the object of SelectableRoundedImageView. It seems worked. But when I set scaleType with centerCrop, there's a problem. The image cannot be showed, or be showed without corners.

qq 20160908113755

This is the effect of this issue. By the way, the top imageview' url and the top selectableRoundImageView's url are the same.

qq 20160908114828
And this is the effect which is image be showed without cornors.

@pungrue26
Copy link
Owner

I'll look into it, and come back soon! :)

@pungrue26
Copy link
Owner

Found the reason, and solution as well!

It seems you are using old version of Glide. GlideBitmapDrawable was replaced with Android framework's BitmapDrawable at af6e1e8 commit which is done about 2 years ago!

Reason:
GlideBitmapDrawable class handles drawing itself, so SelectableRoundedImageView loses chance to draw.

Solution:
Don't use GlideBitmapDrawable as RequestListener's type argument. Use BitmapDrawable class.

Glide.with(this)
        .load(result.images.original.url)
        .thumbnail(thumbnailRequest)
        .listener(new RequestListener<BitmapDrawable>() {
          //...

          @Override
          public boolean onResourceReady(BitmapDrawable resource, Object model, Target<BitmapDrawable> target,
              DataSource dataSource, boolean isFirstResource) {
            // You can use resource as BitmapDrawable!
          }
        })
        .into(imageView);

@pungrue26 pungrue26 self-assigned this Sep 22, 2016
@mikiller
Copy link
Author

It's very kind of you to help me in resolving the problem. But there's a little pity, the version of Glide on jcenter is only upto 3.7.0. The way which you showed depends on 4.0 on github's library. So I have to use "asBitmap" to get bitmap and "setImagebitmap” in SimpleTarget and wait for 4.0 on jcenter later. Anyway, do not use GlideBitmapDrawable, that's right. Thank you for your help and your SelectableRoundedImageView :)

@pungrue26
Copy link
Owner

No problem! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants