Skip to content

Instantly share code, notes, and snippets.

@benbaxter
Created August 21, 2017 21:21
Show Gist options
  • Save benbaxter/9db8dd73f34fe034a1cd65b12c4e3951 to your computer and use it in GitHub Desktop.
Save benbaxter/9db8dd73f34fe034a1cd65b12c4e3951 to your computer and use it in GitHub Desktop.
Cache background tasks per index.
@Override
public void getThumbnail(int index, ResultCallback callback) {
LoadBitmapAsyncTask task = mTasks.get(index);
if (task == null) {
task = new LoadBitmapAsyncTask(index, callback);
mTasks.put(index, task);
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment