Quickest/best way to load a large image ( using Glide ) - java

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
)

Related

Android - set image to imageview for user profile

i have an app that get picture from gallery and display into ImageView.
i want the image to stay. when a user select image from gallery or camera i want the image to set as profile.the problem i have is when image selected and display, if i reopen the app the image is gone it does not say.i know i could you url but i dont want like that. whether SharedPreference , Bitmap catch or string64 i dont know. i'm feeling dump now i couldn't solve and couldn't find any example. i searched a lot but i couldn't find.
Thank you!!!!
I understand your requirement as to persist the profile image. Basically you can get the image from gallery and store it in your app storage. So next time, you open the app you can get the image from storage.

When I use Picasso to load image into ImageView, then setImageBitmap becomes has no effect

I have used Picasso lib to load images from server and it works fine for me but when I want to select another image from Gallery to load it into the same image view nothing happens.
Here is my code
Picasso.with(EditProfileActivity.this)
.load(User.getInstance().getProfilePicPath())
.placeholder(R.drawable.defaultpp)
.error(R.drawable.defaultpp)
.into(imageView);
By the way when I comment the above line, I can select an image and show it into the image view, so can anyone give the reason of what happened ?
If you want to load images from gallery, you can pass file URI into Picasso
Picasso.with(getActivity()).load(fileUri).into(imageView);
You also have to make sure that you have enough permissions to fetch the given image.
This is an issue with the picasso lib, and has been answered by the creator itself, though solved in the latest version (but is still in alpha), a work around for picasso with Uri is this:
Picasso.with(this).load("file://" + User.getInstance().getProfilePicPath()).placeholder(R.drawable.placeholder)
.config(Bitmap.Config.RGB_565).into(imageview);
Make sure you dont forget the file:// prefix
Ref: the issue tracker for Picasso here
Because of when you select image your activity is sended back and imageviews route is lost. So yo have to define it again when it returns to your activity. add onResume or add onRestoreInstanceState then define imageview again ex: imageview findview... etc. It is the problem.

CardView - refresh images on visible items only

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?

GridView loads slow for large image resources

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.

Creating a gridview of images' thumbnails that expands when tapped in Android

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

Categories

Resources