[Android] AsyncImage: kill an other thread
Thomas Guillem
git at videolan.org
Tue Oct 6 18:42:00 CEST 2015
vlc-ports/android | branch: master | Thomas Guillem <thomas at gllm.fr> | Tue Oct 6 18:41:51 2015 +0200| [86a0cc617155b3a76d5732a6d11c7fb7001f528e] | committer: Thomas Guillem
AsyncImage: kill an other thread
> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=86a0cc617155b3a76d5732a6d11c7fb7001f528e
---
.../src/org/videolan/vlc/gui/AsyncImageLoader.java | 15 +++++----------
1 file changed, 5 insertions(+), 10 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/gui/AsyncImageLoader.java b/vlc-android/src/org/videolan/vlc/gui/AsyncImageLoader.java
index f3ff370..6084c99 100644
--- a/vlc-android/src/org/videolan/vlc/gui/AsyncImageLoader.java
+++ b/vlc-android/src/org/videolan/vlc/gui/AsyncImageLoader.java
@@ -50,18 +50,15 @@ public class AsyncImageLoader {
public final static String TAG = "VLC/AsyncImageLoader";
- static ExecutorService executor = Executors.newSingleThreadExecutor();
-
/* Maximum one thread that is killed after 2 seconds of inactivity */
static ThreadPoolExecutor sThreadPool = new ThreadPoolExecutor(0, 1, 2, TimeUnit.SECONDS,
new LinkedBlockingQueue<Runnable>());
- public static void LoadImage(Callable<Bitmap> loader, final ImageUpdater updater, final View target){
- final Future<Bitmap> future = executor.submit(loader);
+ public static void LoadImage(final Callable<Bitmap> loader, final ImageUpdater updater, final View target){
sThreadPool.execute(new Runnable() {
@Override
public void run() {
- handleImage(updater, future, target);
+ handleImage(updater, loader, target);
}
});
}
@@ -106,13 +103,11 @@ public class AsyncImageLoader {
LoadImage(loader, updater, null);
}
- private static void handleImage(final ImageUpdater updater, final Future<Bitmap> future, View target){
+ private static void handleImage(final ImageUpdater updater, Callable<Bitmap> loader, View target){
try {
- final Bitmap bitmap = future.get();
+ final Bitmap bitmap = loader.call();
updater.updateImage(bitmap, target);
- } catch (InterruptedException e) {
- e.printStackTrace();
- } catch (ExecutionException e) {
+ } catch (Exception e) {
e.printStackTrace();
}
}
More information about the Android
mailing list