I just want to know how to display the image from an URL by using a bitmap and an AsyncTask in a Fragment - not in an Activity.
Use the Piccaso for load image more faster
Picasso.with(context)
.load(image url here)
.resize(50, 50)
.centerCrop()
.into(imageView)
refer this link
hope this helps.
Related
As the title suggests, is there a way to load a low resolution image (maybe about half the image's original size) using Glide? I don't know if it makes sense but I basically need it so data users of my application can minimize their data consumption. I need it to be the final image that Glide loads into the view (not thumbnail).
I Suggest Server will do this
and you can also compress and resize the image when load
RequestOptions reqOptions = new RequestOptions()
.fitCenter()
.override(100, 100);
Glide.with(context)
.asBitmap()
.apply(reqOptions)
.load(imageUrl)
.into(bitmapView);
Picasso and Glide aren't supporting/loading image URL with .jpeg extension within image view.
I am working in grid view where image is being loaded in image view , either by picasso or by glide but it isn't supporting the URL with .jpeg extension.
Are there any alternates available?
Glide.with(getActivity())
.load("https://abc/profile.jpeg")
.centerCrop()
.placeholder(logo)
.into(imageView);
Picasso.get()
.load("https://abc/profile.jpeg")
.placeholder(R.drawable.logo)
.error(R.drawable.logo)
.into(imageView);
Change the extension of images to .jpg and it'll work.
I'm using Glide to download and display images in my gridview. When I click on a item in my gridview I want to display this image in another activity to get this image in full screen. But with Glide I don't know how I can get the image saved in the cache.
Save the image filename in a Database and call again the link to download the image full size with Glide ?
Or try to get the image in the cache but I don't know how to do that.
Could you help me ?
try this code, it's working for me:
On your adapter:
Glide.with(context)
.load("photo_url")
.diskCacheStrategy(DiskCacheStrategy.ALL) //use this to cache
.centerCrop()
.crossFade()
.into(yourImageView);
On your another Activity:
Glide.with(AnotherActivity.this)
.load("photo_url")
.diskCacheStrategy(DiskCacheStrategy.ALL) //use this to cache
.crossFade()
.into(yourImageView);
Use .diskCacheStrategy(DiskCacheStrategy.ALL) to cache & don't forget to make image scaling same. It will working.
I've been working on this for a while now and it is time to ask a SO question on it.
Find and load cached Image in Glide looks like it, but following the links and the discussion on Glide's page it doesn't work for me.
On Activity A, I load the image via an URL in an ImageView.
After that, I go offline with the device. Then I open Activity B, where I load the same URL in a different ImageView, which has other dimensions. It only works if the width and height are equal to the ImageView on Activity A, or you supply an override() with the width and height of that first ImageView. But Activity B does not know about that.
I do this in Activity A:
Glide.with(context)
.load(url)
.diskCacheStrategy(DiskCacheStrategy.ALL)
.placeholder(R.drawable.placeholder)
.crossFade()
.into(image);
and in activity B I do:
Glide.with(mContext)
.load(url)
.override(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL)
.into(imageView);
I tried the above, because I thought the disk strategy will store the original too, so it will load that one than. Result is that no image is loaded.
I am thinking of going back to Picasso, because I think this is possible there, but I give Stackoverflow one more try.
I would throw in a bounty right away if that was possible...
Can you try the following code for Activity B?
Glide.with(mContext)
.load(url)
.diskCacheStrategy(DiskCacheStrategy.SOURCE)
.into(imageView);
now you can use that :
Glide.with(MainActivity.context)
.applyDefaultRequestOptions(new RequestOptions().diskCacheStrategy(DiskCacheStrategy.ALL))
.load(url)
.into(img);
Hi I used the picasso library for load the image from server url. But some of images loading in wrong orientation. ExifInterface is class to find out the image orientation but here image is not in resource folder. I have only image url but i want to show the image in correct orientation. How I can achieve to show the image on imageview with correct view.
Picasso.with(context)
.load(url)
.resize(200, 200)
.centerCrop()
.placeholder(R.drawable.ic_pic)
.error(R.drawable.ic_pic)
.into(holder.image);