Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When to use lazy Loading and when not to use.?

I have like 5000 names in the database. I want all these names to be inflated onto a ListView. Which has the following elements

  1. Icon Image (which is stored locally in Drawables)
  2. Name
  3. Distance in kms

I am filtering this listView using Search Filtering, something like this:

adapter.getFilter().filter(someText);

I am also sorting the listview, for example: sort listView names alphabetically(A-Z and Z-A). Sorting is done on the listView adapter like this:

adapter.sort(new Comparator<String>() {

                @Override
                public int compare(String lhs, String rhs) {
                    return lhs.getPlaceName().compareTo(rhs.getPlaceName());
                };
            });

Now i am pretty confused whether to use Lazy loading of names onto the listview(because I have 5000+ names) considering the performance of the adapter. Please suggest.

like image 484
suresh cheemalamudi Avatar asked Nov 03 '22 07:11

suresh cheemalamudi


1 Answers

Alternatively, you may store your data in the database sorted and then apply lazy loading. Because though approach suggested by @Singularity in very good, you may end up sorting only chunks [of 100, say] and not the whole data. Also, you would require sorting to be done for each of those chunk.

like image 184
HarshalK Avatar answered Nov 15 '22 00:11

HarshalK