[android-developers] Re: AsyncTask : java.util.concurrent.RejectedExecutionException
Hi arnouf, I don't mean to butt in but I suspect this is a similar problem to something I saw before. In your ViewAdapter, I am assuming you are creating or using a View which is or contains an ImageView which you are trying to load the image contents for remotely. If you are always creating the view in your adapter, then it simplifies the process a lot but at a performance tradeoff since you won't get the View recycling that the ListView does for you. If you create only when the view passed into your adapter is null, and use the passed in View other times then you gain some performance, however now you have to sync the ImageViews to what is being displayed on the screen or else like you said, you may get images rendered in the incorrect cells of the list. So there are 2 problems, #1 For the AsyncTask, you can still use the AsyncTask, but stagger their execution (try using a handler on the UI thread to spawn the AsyncTask after a delay, via postDelay). #2 The Image Syncing problem, when you get the information back you should make sure the view that the task is loading the image for is not "dirty." By dirty I mean that the ListView is still displaying that cell and it is the correct cell. It may have been recycled and passed back to your adapter as the user scrolled and you will end up out of sync. I have been storing the image url in the tag of the image view and on a successful image load comparing the tag with the source of the image bitmap to make sure the view still is "fresh." If you cache the image somewhere (in memory or storage) you can then retrieve it faster later and just fill the image view next time that cell needs to be rendered. Not sure if this is the exact problem you describe but I don't see any harm in giving some advice. Hope it helps. -Greg On Apr 7, 8:14 am, arnouf wrote: > I'm not sure that it will resolve my first problem related to the > image loaded from remote and display in my listview > I can useAsynctaskin my adapter to load each image. But when I do a > bog scroll, displayed image are not to the good place (ex. : the image > number 4 is displayed at the line 15 ...). It's trying to tesolve this > first issue, that I meet the exception. But this issue is maybe due to > the Async pooltoo. > > I come you back later. > > Thanks > > On Apr 7, 4:37 pm, "Mark Murphy" wrote: > > > > > > When you have a lot of Image to load this is a big limitation. > > > You can: > > > -- Grab the source code toAsyncTask, clone it into your own package, and > > modify the LinkedBlockingQueue. I did this with my AsyncTaskEx class. > > > -- SkipAsyncTaskand roll your own thread pool. > > > -- > > Mark Murphy (a Commons Guy)http://commonsware.com > >AndroidApp Developer Books:http://commonsware.com/books.html -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en To unsubscribe, reply using "remove me" as the subject.
[android-developers] Re: AsyncTask : java.util.concurrent.RejectedExecutionException
I'm not sure that it will resolve my first problem related to the image loaded from remote and display in my listview I can use Asynctask in my adapter to load each image. But when I do a bog scroll, displayed image are not to the good place (ex. : the image number 4 is displayed at the line 15 ...). It's trying to tesolve this first issue, that I meet the exception. But this issue is maybe due to the Async pool too. I come you back later. Thanks On Apr 7, 4:37 pm, "Mark Murphy" wrote: > > When you have a lot of Image to load this is a big limitation. > > You can: > > -- Grab the source code to AsyncTask, clone it into your own package, and > modify the LinkedBlockingQueue. I did this with my AsyncTaskEx class. > > -- Skip AsyncTask and roll your own thread pool. > > -- > Mark Murphy (a Commons Guy)http://commonsware.com > Android App Developer Books:http://commonsware.com/books.html -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en To unsubscribe, reply using "remove me" as the subject.
Re: [android-developers] Re: AsyncTask : java.util.concurrent.RejectedExecutionException
> When you have a lot of Image to load this is a big limitation. You can: -- Grab the source code to AsyncTask, clone it into your own package, and modify the LinkedBlockingQueue. I did this with my AsyncTaskEx class. -- Skip AsyncTask and roll your own thread pool. -- Mark Murphy (a Commons Guy) http://commonsware.com Android App Developer Books: http://commonsware.com/books.html -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en To unsubscribe, reply using "remove me" as the subject.
[android-developers] Re: AsyncTask : java.util.concurrent.RejectedExecutionException
Ok thanks Mark. When you have a lot of Image to load this is a big limitation. Strangely, we don't have this situation If I call the same number of element inside a listview...But another issue appears : images are not placed on good lines :( On Apr 7, 3:57 pm, "Mark Murphy" wrote: > > What is this exception ? > > The second link in a Google search for RejectedExecutionException turns up: > > http://pveentjer.wordpress.com/2008/02/06/are-you-dealing-with-the-re... > > Your problem is probably the second on that list -- you have tried to > start too many AsyncTasks. AsyncTask uses a limited-length BlockingQueue > for jobs waiting for a thread in the thread pool to free up, and it will > throw that exception when you exceed the available number of slots in the > queue. > > -- > Mark Murphy (a Commons Guy)http://commonsware.com > Android App Developer Books:http://commonsware.com/books.html -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en To unsubscribe, reply using "remove me" as the subject.