Back to project page webimageloader.
The source code is released under:
Apache License
If you think the Android project webimageloader listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.webimageloader.loader; // w w w . ja v a 2s .c o m import java.io.Closeable; import java.util.concurrent.ExecutorService; import java.util.concurrent.Future; import com.webimageloader.util.ListenerFuture; public abstract class BackgroundLoader implements Loader, Closeable { private ExecutorService executor; public BackgroundLoader(ExecutorService executor) { this.executor = executor; } @Override public void load(final LoaderWork.Manager manager, final LoaderRequest request) { run(manager, new ListenerFuture.Task() { @Override public void run() throws Exception { loadInBackground(manager, request); } }); } @Override public void close() { executor.shutdownNow(); } protected void run(LoaderWork.Manager manager, ListenerFuture.Task task) { Future<?> future = executor.submit(new ListenerFuture(task, manager)); manager.addFuture(future); } protected abstract void loadInBackground(LoaderWork.Manager manager, LoaderRequest request) throws Exception; }