2

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

Shubham
  • 1,442
  • 3
  • 16
  • 34

3 Answers3

1

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.

Kshitij Aggarwal
  • 5,287
  • 5
  • 34
  • 41
  • 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? – Shubham Jan 25 '16 at 11:09
  • 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. – Kshitij Aggarwal Jan 25 '16 at 11:12
  • Then how would I know that list has stopped scrolling? – Shubham Jan 25 '16 at 11:14
  • By implementing an OnScrollListener – Kshitij Aggarwal Jan 25 '16 at 11:14
  • Yupp I'll implement your suggested method and if it solves I'll accept it. – Shubham Jan 25 '16 at 11:17
1

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.

Cyph3rCod3r
  • 1,978
  • 23
  • 33
0

It was better that put your code here , but I think if you download image asynchronously, your problem is solved. you can download image in back ground by using "dispatch_async()" method.

BinMan1
  • 95
  • 1
  • 10