Two Async Calls In Getview(), Am I Doing This Right?
Solution 1:
Two async calls in getview(), am I doing this right?
No.
I do this whole thing inside my custom ImageAdapter. Shall I call another thread from within my getView method ?
Aquery is starting another thread to do the download, so you would only duplicate the code they have already. BitmapAjaxCallback.callback
is called when that thread finishes doing its job.
The getView() method gets called 2 times can I control it to get called only once because it shouldn't as the track gets played multiple times based on its call?
getView
has to be called twice. First call will return View
without an image downloaded from the network. Second call is after the image is downloaded and can be attached. Only if you have the image in memory cache already getView
will be called once. What you don't want is BitmapAjaxCallback.callback
called twice.
Also you are downloading mp3 on main thread after image has finished downloading. They should both be downloaded on separate threads. And simultaneously.
Solution proposition:
As you Adapter
is bound to Activity
context and downloading of image and mp3 and starting playback should not be bound to that shortliving context, move it to Application
context or Service
and from Adapter
only request things to be done and get image from a cache, which should be put in Application
context. Maybe Aquery has some cache you can use.
Post a Comment for "Two Async Calls In Getview(), Am I Doing This Right?"