When to use lazy loading and when not to use it.?

I have 5,000 names in the database. I want all of these names to be inflated in a ListView. Which has the following elements

  • Image icon (which is stored locally in Drawables)
  • Name
  • The distance in km.

I am filtering this View list with search filtering, something like this:

adapter.getFilter().filter(someText); 

I also sort listview, for example: sort listView names in alphabetical order (AZ and ZA). Sorting is performed in the listView adapter as follows:

 adapter.sort(new Comparator<String>() { @Override public int compare(String lhs, String rhs) { return lhs.getPlaceName().compareTo(rhs.getPlaceName()); }; }); 

Now I'm pretty confused about whether to use Lazy loading names in a listview (because I have 5000+ names), given the performance of the adapter. Please suggest.

+4
source share
1 answer

Alternatively, you can save your data in a sorted database, and then apply lazy loading. Because, although the approach suggested by @Singularity is very good, you can end up only sorting pieces [out of 100, say], and not whole data. In addition, you will need to sort for each of these fragments.

+2
source

All Articles