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

Can we use Glide library with this to display the image? #234

Closed
abhimrawks opened this issue Jul 27, 2016 · 8 comments
Closed

Can we use Glide library with this to display the image? #234

abhimrawks opened this issue Jul 27, 2016 · 8 comments

Comments

@abhimrawks
Copy link

I am using Glide everywhere else and would like to integrate Glide here as well. Glide automatically takes care of all the network calls and caching. That would be nice to have.

@kakai248
Copy link

Your best approach would be to use Glide to downloadOnly. Because it gives you a File that you can use directly in this view. I eventually switched to UIL because I can access cache files and it still gives me bitmaps so I can use them in the preview part.

@fifa1016
Copy link

you can use this:
Bitmap bitmap = Glide.with(GalleryActivity.this).load(picUrl )
.asBitmap().into(-1, -1).get();

@gnumilanix
Copy link

gnumilanix commented Sep 11, 2016

Here's one approach. For some reason formatting did not work:

Glide.with(view.getContext()).load(url).asBitmap().into(new SimpleTarget<Bitmap>() {
    @Override
    public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) {
        view.setImage(ImageSource.bitmap(resource));
    }
});

@Reallym404
Copy link

@gnumilanix 使用你说的方法 glide显示大图,显示多张后,还会出现后面的图显示不出来的情况,改如何解决

@davemorrissey
Copy link
Owner

I'll close this now. There's plenty of advice on this in these comments, other issues and StackOverflow. The view can't easily be changed to work with image loaders because most work with bitmaps, bypassing this view's support for large images without out of memory errors. As kakai248 says, using an image loader to store the file locally is best.

@peerJasim
Copy link

  // For SubsamplingScaleImageView use SimpleTarget

  Glide.with(context)
                .asBitmap()
                .load(images[position])
                .apply(RequestOptions.diskCacheStrategyOf(DiskCacheStrategy.AUTOMATIC))
                .into(new SimpleTarget<Bitmap>(width, height) {
                    @Override
                    public void onResourceReady(Bitmap bitmap, Transition<? super Bitmap> transition) {
                        subsampleImageView.setImage(ImageSource.bitmap(bitmap)); //For SubsampleImage
                    }
                });

@CarsonRedeye
Copy link

CarsonRedeye commented Jul 29, 2019

How I downloaded a file with Glide and displayed in SSIV, just in case someone was looking for an example

class SubsamplingScaleImageViewTarget(view: SubsamplingScaleImageView)
    : CustomViewTarget<SubsamplingScaleImageView, File>(view) {
    override fun onResourceReady(resource: File, transition: Transition<in File>?) {
        view.setImage(ImageSource.uri(Uri.fromFile(resource)))
    }

    override fun onLoadFailed(errorDrawable: Drawable?) {
        // Ignore
    }

    override fun onResourceCleared(placeholder: Drawable?) {
        // Ignore
    }
}
Glide.with(this)
                    .download(GlideUrl(url))
                    .into(SubsamplingScaleImageViewTarget(image_preview))

@benni12er
Copy link

benni12er commented Dec 7, 2019

@CarsonRedeye Thank you, this is the right answer! When using Bitmaps as response, the app gets slowed down as hell while using the File, everything works like with a classic imageview.

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

9 participants