Domanda

Note

This question is not aiming code answers. It intend to get some ideas for best code practices that deals with the problem proposed.

Problem

List view that is connected as usual with array adapter of countries. country object have 2 attributes. an image url and country name. at the very first time images will be downloaded from the url and must be saved on the internal memory. next time images will be loaded from the internal memory if exist. otherwise, they will be downloaded.

What is the best structure to solve this problem?

Spot lights

  • a bitmap object is the container that a download steam will write to.
  • an image in the internal will also be sit to the bitmap object before we set bitmap to the image view.
  • (is this point optional) a bitmap ref. should be a member of the country class.
  • on download complete the downloaded image may and may not still needed because it's view is no longer visible (actually it is visible but another country owns it). is it better to check that before we set the image bitmap. or its better to just notify data changed.

What do you think?

È stato utile?

Soluzione

Use this library for image downloading https://github.com/nostra13/Android-Universal-Image-Loader

It has tons of features, you can cache in memory or on disk, has image loading events, and a ton of more stuff.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top