Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If you fixed the low fps issues and fast scrolling performs smooth by now you're actually good to go.</p> <p>When the frequent GC action is just a cosmetic issue for you and you're not facing <code>OutOfMemoryException</code> or any other downsides, then you should probably leave it like that. If that is no option for you there is another thing you can do: Besides down sampling and caching you could also add a small, artificial waiting time (50-150ms) after launching the <code>AsyncTask</code> and before actually retrieving the resource file. Then you add a cancel flag to your task that has to be checked after the artificial delay. If it's set to <code>true</code> you don't request the resource file.</p> <p>Some (not executable) code examples:</p> <pre><code>class MyImageLoader extends AsyncTask { private boolean cancel = false private Bitmap bitmap; public void cancel() { cancel = true } public void doInBackground() { sleep(100); if(!cancel) { bitmap = BitmapFactory.decodeResource(...); } } } class Adapter { static class WeaponHolder { public TextView text; public ImageView image; public MyImageLoader loader; } public View getView(int position, View convertView, ViewGroup parent) { WeaponHolder holder; if (convertView == null) { ... holder = new WeaponHolder(); } else { holder = convertView.getTag(); holder.loader.cancel(); // Cancel currently active loading process } holder.loader = new MyImageLoader(); holder.loader.execute(); return convertView; } } </code></pre> <p>This way most of the images won't be read from your internal memory if the user is scrolling real fast and you'll save plenty of memory.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload