I have a listview in which images gets downloaded when I scroll so whatever I have understand till now is the element which are visible only that element's images gets downloaded. Suppose only 7 elements are visible at a time and when I Scroll previous views are recycled with the new once so what happens to the process which was downloading the image of the previous views is it also cancelled or it queues the new request of downloading images of the new Views.I am asking about the process that queueing of process happens or the process which are not completed yet are cancelled. with process I mean downloading images in background
4
-
@chintan-rathod I am asking that if views are recycled does the process also gets killed.Shubham– Shubham2016-01-25 11:06:08 +00:00Commented Jan 25, 2016 at 11:06
-
Depend upon logic. Otherwise NO.Chintan Rathod– Chintan Rathod2016-01-25 11:11:32 +00:00Commented Jan 25, 2016 at 11:11
-
So do you know any way where i can stop the previous process for the views which hoes out of the screen or which are recycled?Shubham– Shubham2016-01-25 11:13:03 +00:00Commented Jan 25, 2016 at 11:13
-
Nope.. I have not heard regarding how to get update when view get disappeared from list..Chintan Rathod– Chintan Rathod2016-01-25 11:26:45 +00:00Commented Jan 25, 2016 at 11:26
Add a comment
|
3 Answers
Depends completely on how you are downloading and caching the images.
If you are using AyncTasks to download your images and not cancelling them as you scroll then the image will be downloaded. If you are using libraries like volley/picasso/glide to handle your images then they cancel or cache the images depending on how much of the image was downloaded.
5 Comments
Shubham
so suppose I am using AsyncTask when i scrolled faster and lands on 60th element so do i have to wait till all images till 60th downloaded to see my image of 60th element?
Kshitij Aggarwal
Yes. How AsyncTasks behave is that internally it will only launch a limited number of threads after which all requests start going to a queue and all those requests will then be handled sequentially. To avoid this, dont start async tasks until your list has stopped scrolling.
Shubham
Then how would I know that list has stopped scrolling?
Kshitij Aggarwal
By implementing an OnScrollListener
Shubham
Yupp I'll implement your suggested method and if it solves I'll accept it.
Why don't you use Glide or Picasso or UIL for Lazy loading of images. Instead of downloading you can get the bitmap and save them as per your need.
1 Comment
Shubham
Yeah I'll Surely try these libraries. Thanks