summaryrefslogtreecommitdiffstats
path: root/src/com/android/camera/ImageGallery.java
diff options
context:
space:
mode:
authorChih-Chung Chang <chihchung@google.com>2009-04-28 18:10:04 +0800
committerChih-Chung Chang <chihchung@google.com>2009-04-28 18:28:39 +0800
commit2716078c6252f926cea467be4202855d491f8cf7 (patch)
tree0ec4b5c53b25953b7f2b0bcf32ca9fbac462df0b /src/com/android/camera/ImageGallery.java
parentb03f3bb03dd19163be05a8841ce78af3cb92b88d (diff)
downloadLegacyCamera-2716078c6252f926cea467be4202855d491f8cf7.zip
LegacyCamera-2716078c6252f926cea467be4202855d491f8cf7.tar.gz
LegacyCamera-2716078c6252f926cea467be4202855d491f8cf7.tar.bz2
Avoid too many progress updates from ImageLoader.
Diffstat (limited to 'src/com/android/camera/ImageGallery.java')
-rw-r--r--src/com/android/camera/ImageGallery.java24
1 files changed, 15 insertions, 9 deletions
diff --git a/src/com/android/camera/ImageGallery.java b/src/com/android/camera/ImageGallery.java
index a926f34..6816880 100644
--- a/src/com/android/camera/ImageGallery.java
+++ b/src/com/android/camera/ImageGallery.java
@@ -636,6 +636,7 @@ public class ImageGallery extends Activity implements
private final TextView mProgressTextView;
private final String mProgressTextFormatString;
boolean mDidSetProgress = false;
+ private long lastUpdateTime; // initialized to 0
private PowerManager.WakeLock mWakeLock;
private MyThumbCheckCallback() {
@@ -667,15 +668,20 @@ public class ImageGallery extends Activity implements
}
mGvs.postInvalidate();
- // Update the progress text.
- mHandler.post(new Runnable() {
- public void run() {
- String s = String.format(mProgressTextFormatString,
- maxCount - count);
- mProgressTextView.setText(s);
- }
- });
-
+ // Update the progress text. (Only if it has been one
+ // second since last update, to avoid the UI thread
+ // being overwhelmed by the update).
+ long currentTime = System.currentTimeMillis();
+ if (currentTime - lastUpdateTime > 1000) {
+ mHandler.post(new Runnable() {
+ public void run() {
+ String s = String.format(mProgressTextFormatString,
+ maxCount - count);
+ mProgressTextView.setText(s);
+ }
+ });
+ lastUpdateTime = currentTime;
+ }
return !mPausing;
}