From c613c59117c25a37456b2a346515cbcd1dfcf0e0 Mon Sep 17 00:00:00 2001 From: Chih-Chung Chang Date: Thu, 2 Jul 2009 16:12:12 +0800 Subject: [PATCH] Fix bug: wait for idle time before checking thumbnail only if there is still some thumbnail to check. --- src/com/android/camera/ImageLoader.java | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/com/android/camera/ImageLoader.java b/src/com/android/camera/ImageLoader.java index 8ebc345..5e3a0e6 100644 --- a/src/com/android/camera/ImageLoader.java +++ b/src/com/android/camera/ImageLoader.java @@ -145,18 +145,6 @@ public class ImageLoader { if (!mQueue.isEmpty()) { workItem = mQueue.remove(0); } else { - // Calculate the time we need to be idle before we - // start checking thumbnail. - long t = IDLE_TIME - (System.nanoTime() - lastWorkTime); - if (t > 0) { - try { - mQueue.wait(t / 1000000); // in milliseconds. - } catch (InterruptedException ex) { - // ignore the exception - } - continue; - } - if (!mThumbnailChecker.hasMoreThumbnailsToCheck()) { try { mQueue.wait(); @@ -164,6 +152,19 @@ public class ImageLoader { // ignore the exception } continue; + } else { + // Calculate the time we need to be idle before we + // start checking thumbnail. + long t = IDLE_TIME - (System.nanoTime() - lastWorkTime); + t = t / 1000000; // convert to milliseconds. + if (t > 0) { + try { + mQueue.wait(t); + } catch (InterruptedException ex) { + // ignore the exception + } + continue; + } } } } -- 2.11.0