Thanks, Romain. I'll try to refactor my code so that that the ListView
is being populated by a datastructure which I can update from that
background thread ....

On Dec 12, 6:30 pm, Romain Guy <[email protected]> wrote:
> All your message need to tell the UI thread is that a new image is
> available. You don't have to pass the image as part of the message.
> Usually, the background thread would download the image and put it in
> memory (in a list or map for instance) and then simply tell the UI
> thread to refresh the UI. You can see such an implementation in
> Photostream and Panoramio at code.google.com/p/apps-for-android
>
>
>
> On Sat, Dec 13, 2008 at 1:05 AM, DanG <[email protected]> wrote:
>
> > Hello -
>
> > I'm trying to figure out the best design pattern to use here.
>
> > I have a list view, for which each row consists of some text and an
> > image. This content must be downloaded from the web. Currently, the
> > list view is using a custom adapter, and I implemented the getView()
> > method to dynamically download the image as it is needed (i.e. as the
> > row on which it should be displayed becomes visible).
>
> > This is all happening in the main thread, and it's having an impact on
> > the user experience. So I'd like to move the downloading of the image
> > to the background thread. I know how to do this ... but my quandary is
> > then, how do I pass the image information back to the main UI thread.
> > AFAIK, the most convenient way to pass information between threads is
> > using Handler.sendMessage() and including a bundle with the message
> > containing any information. But I don't think it's possible to include
> > an Image as part of a bundle, because it's not serializable.
>
> > Do I need to write the image to disk and pass a string containing the
> > file path? what are some other ways I could go about passing
> > information about a downloaded image from the non-UI background thread
> > to the ui thread?
>
> > Thanks!
> > Dan
>
> --
> Romain Guywww.curious-creature.org
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to