I have cardview list with each item containing image view and text. Each image for each item is provided as url with image to download.
Now, instead of converting each image to bitmap and putting it into my adapter I want to get functionality similar to Google Play search results, where images are refreshing after list is shown.
My idea is to use Universal Image Loader: https://github.com/nostra13/Android-Universal-Image-Loader so my images will be loaded in background.
However, I have no idea how to force refreshing only visible items. The rest should be refreshed on scroll, just after they appear when list is scrolled down. So basically, the same as it works in Google Playstore app.
Any tips?
Related
I have been trying to make a photo gallery app and I want to select multiple photos.
The problem in the current implementation is that when I try to longpress to make checkbox visible, the thumbnails are reloading for a fraction of second.
This is because I am calling notifydatasetchanged() after I longpress so that onbindviewholder can load the checkboxes on the screen for every recycler view item, which in turn reloads the thumbnails.
I am using glide to load thumbnails.
I am developing a Android application that display's images loaded from the sdcard.
I use the mediastore to populate a recyclerview.
If the user would click a image in the recyclerview i would like to open a activity that shows the image in full size.
When the clicked item is a huge image it takes 4/5 seconds to load.
I noticed some applications can somehow load them instantly(quickpic, google photos).
How do they do this and or what is the best practise?
I am using Glide for the async loading and caching.
I tried the glide function that loads a thumbnail first and loads the full image in the background.
I tried resizing and subsampling the image.
And thats about all the techniques i could find.
Some code i tried:
Glide.with(this)
.load(getUri().toString())
.asBitmap() .diskCacheStrategy(DiskCacheStrategy.RESULT)
.priority(Priority.IMMEDIATE)
.dontAnimate()
.thumbail(0.1f)
.override(height,width)
.info(imageView
)
Here's the situation:
I have a custom list item containing an ImageView, and some TextViews. I am lazy loading images to the ImageViews. When I use this in a ListView, it works fine.
I also want to use it in a Gallery. There are three scenarios:
lazy load images, not touching the spacing: The items overlap, but
scroll fine
don't load images, Gallery.setSpacing(0): The items are spaced
correctly, the scrolling works, but I have no images.
lazy load images, Gallery.setSpacing(0): The items are spaced
correctly, scrolling doesn't work, just behaves really jittery and
snaps back to original position. If I scroll very fast, repeatedly, it will start moving, but very poorly
Because it all works perfectly in a ListView, I can't understand what's going wrong. I know it's nothing wrong with my image loader, and I know it's nothing wrong with my layout. It seems like Gallery is having trouble handling changes to the list item.
EDIT: I forgot to mention, there's a placeholder image loaded in the ImageView before the images are loaded, and the ImageView has a fixed size.
Does anybody have any idea what I could be missing?
I think that because yo are lazy loading the images, when onMeasure is called on each item in the gallery, it doesn't know how big the image going to be (as it isn't loaded yet), and so it can't set the spacing to 0.
Maybe you should set your default gallery item size, or update the size of the view as the image is loaded?
I've been learning android programming for some days. I am creating an ebook application which reads images from the drawable folder. I've successfully implemented the pageviewer activity which loads bitmaps using asyncTask in background and shows a text "loading..." until loading is completed.
I wanted to show a pagelist in another activity using gridview so that user can scroll through a grid of pages and select any. I followed the android gridview tutorial and wasnt much problem. But since i have about 50 images in drawable and it seems gridview adapter shows the grid once all images are croped and placed in grid. It takes a lot of time to show the grid and its quite slow on scroll.
I was wondering if there was a better way to show the grid, asynchronously, like show the first item and then the 2nd and so on, instead of waiting for a long time and displaying the grid. I saw some topics like lazy load which seems similar to what i want, but they all show image from web, it was confusing. Hope i can get some sugestions, or if there is any other way.
Have you tried Fedor's Image Lazy Loader?
Here is the link: Lazy load of images in ListView ,
I know you want to implement it for GridView, but still you can refer the ImageLoader class given in the example code.
Update:
You can even try this example Lazy Loading GridView. I haven't tried it, but as i found it, i thought it may be of your help.
The images you show are probably a bit too large to be used with GridView in their current form.
I guess you need the GridView to display thumbnails, so one possible approach would be to store a thumbnail sized copy of every page you have, and use those in the Grid.
You can also try switching hardware acceleration on in the manifest, that might help you with the scrolling once the images are small enough to load them faster. But afaik hw acceleration is only available in 3.0 and up.
I would like to create a gridview of images, in which, these images will be downloaded based on a web service response.
The thumbnails of images will be displayed in a gridview, similar to how iPhone displays photos.
User can tap on the image and the corresponding full-res image will be shown, sized to fit within the android phone. Upon tapping on the full-res image, it will minimize and return to the gridview.
So far, following the guide here, I had manage to create the gridview of images, but I would like to have it expand to the original size upon tapping and tapping again, return to the gridview.
See the Gallery, maybe all you need to do is change the OnItemClick behaviour.
http://developer.android.com/resources/tutorials/views/hello-gallery.html