Creating a Facebook-like image upload interface on Android - android

I'm trying to replicate the functionality of Facebook's image upload. To briefly describe it you click the Photo button from the main screen of the app you are taken to an image picker that will let you select up to 30 images. Once selected the images load in some kind of list view that allows you to add a caption, remove the image from the list, or do some other Facebook-y things. If you scroll around the list can move very quickly, and if you only have 5-10 images you generally spend little to no time waiting for items to reload.
Right now I have a recycler view and am using Picasso to load the images from disk, resize them, and then display them. This works, but it's not smooth or fast. Even if I only have five or six images loaded they don't come up instantly if I scroll from the bottom back to the top. I have tried increasing the LRU Cache size in Picasso, but that didn't do anything at all. It seems like the scaled image isn't getting cached so it has to be scaled to fit the screen width every time. That's just my guess though.
Any suggestions on how to get this to run more smoothly?

Related

Moving to the next Activity without killing the previous one

I have got an activity where i download images from a server and display them in a gridView.
Then If i click on one of those images I open a new Activity where I display the full screen image. Now if I get back to the first activity, the one with the gridView, images are downloaded again.
I am using Picasso for displaying images either in the gridView and in the following activity.
Is there a way to avoid the downloading of the whole set of images in the gridView EVERY time I go back from the second activity?
When picasso download an image it saves it to the heap memory, if the images is too large for the heap they are not cached. So if you have grid view full of images, use picasso's ".resize()" to down scale those images and ".config(Bitmap.Config.RGB_565)" to use 16 bit colors (you won't see a difference in the quality, but there is significant difference in size).
Ex: picasso.load(url).resize(200, 200).config(Bitmap.Config.RGB_565).into(target);

Picasso Square Next Image Cache

I'm using Picasso Square library in my android application. The app is a very simple one and shows a grid of pictures. When you touch one it opens it in full screen and when swiping to the right the next in line should be displayed.
My problem is that for every swipe, the image is loaded by picasso method:
Picasso.with(getApplicationContext()).load(Properties.IMAGE_URL + i).transform(transformation).centerCrop().fit().into(imageView);
I would like to avoid the load wait time and simply cache the next 2 images to be displayed. how would I go about doing this?
I know that picasso caches the images if they were loaded before. Is there a way to load the next image with picasso without attaching it to a specific ui element to be displayed?
There is a way to do it – use fetch(). You can get more information from this question.

Loading big images with least effort

I have high quality, rich in color images in my server. I am displaying them in ListView in small ImageViews. After the user selects item, he gets fullscreen of the selected image. In this way after selecting image, the image loads quickly, as it was already loaded and I save them in cache.
The problem is that the whole List on first startup is loading pretty slow, as each item needs to be downloaded. Is there any way I could reduce the image loading in ListView? In my vision the ListView should load pretty quick, and after selection the image may load longer. I know I could optimize this by passing low quality, resized images from server to list. And after selection pass high quality image url. But this is a very big job, as I have ton of images and resizing each one of them would be a pain.
Any ideas how could I optimize this even a little?
Update: I guess my question wasn't clear enough. There is no problem with ListView, or image loading. I do not hung user at some "loading" screen, I do asynchrounsly load images, and I do simbolize that images are being loaded for each item in ListView. But with slow internet connection, the thumbnails just stay there for too long, I think the user would just quit the app... I'm looking for a way to optimize loading process. Loading just resized Images would be great, something like: 50kb for ListView and fullsize for SelectedView. I think in such way the user experience would be much better.
https://github.com/nostra13/Android-Universal-Image-Loader. Universal Image Loader is Asynchronous, uses caching and is a improves version of LazyLoading.
You can cache images in memory or disc. You can also provide custom folder to cache images. Universal Image Loader also provides you with other configuration options.
https://github.com/thest1/LazyList. you can also use lazy loading.
For performance and smooth scrolling use ViewHolder.http://developer.android.com/training/improving-layouts/smooth-scrolling.html.
http://www.youtube.com/watch?v=wDBM6wVEO70. The talk on View Holder for listview.
You can use the universal image loader. It enables you to download the images on a background thread. Basically you display the ListView with some default thumbnail and when each image is downloaded the UIL replaces the thumbnail with the real image.
That way the user will not be trapped while the images are downloading, but showing all the thumbnails will surely require downloading all the big images until you start serving small variants for the images.

Auto loading and disposing image gallery

I need to make an image gallery that takes a JSON list of remote images and pre-loads them and disposes them on the fly as i scroll left or right. I cannt seem to find any examples of this other than a list of images being loaded on the fly. What I want to do is to load the next ones (left and right) while the previous one is on the screen, dumping the others as I go.
I see widget.gallery but is this suitable for this or should I use a Canvas and write my own?
Look at here. There is a ListView with lazy loading, this should show you the solution.
Lazy load of images in ListView

Why is scrollview and app moving slow (lagging)

I have a scrollview and in each row I load a picture plus text (the picture path and text are loaded from database). The problem is that if the picture has a very high resolution, the application moves very slow, and when I scroll, it takes a while until it loads, but when I resize the picture, the scrolling becomes fluid. So, the question is: how can I make the app faster? should I load a thumbnail of the picture and load the thumbnail instead of the actual image?
I think you are loading the contents of the list view on the main UI thread (Reason for the UI to be less responsive). I suggest loading the contents of the list using an AsyncTask. Hope this helps you.

Categories

Resources