OSDN Git Service

Fix for deleted items not deleting sometimes.
authorVenkat Krishnaraj <venkatkrishnaraj@venkat-krishnarajs-macbook-pro.local>
Wed, 24 Feb 2010 21:42:30 +0000 (13:42 -0800)
committerDave Sparks <davidsparks@android.com>
Thu, 25 Feb 2010 16:09:37 +0000 (08:09 -0800)
src/com/cooliris/cache/CacheService.java
src/com/cooliris/media/LocalDataSource.java
src/com/cooliris/media/SingleDataSource.java

index 0bd6afe..ef3c8ff 100644 (file)
@@ -402,6 +402,7 @@ public final class CacheService extends IntentService {
             final DataInputStream dis = new DataInputStream(new BufferedInputStream(new ByteArrayInputStream(albumData), 256));
             try {
                 final int numItems = dis.readInt();
+                Log.i(TAG, "Loading " + numItems + " into set " + set.mName + ":" + set);
                 set.setNumExpectedItems(numItems);
                 set.mMinTimestamp = dis.readLong();
                 set.mMaxTimestamp = dis.readLong();
@@ -498,7 +499,6 @@ public final class CacheService extends IntentService {
         if (!item.isDateTakenValid() && !item.mTriedRetrievingExifDateTaken
                 && (item.mFilePath.endsWith(".jpg") || item.mFilePath.endsWith(".jpeg"))) {
             try {
-                Log.i(TAG, "Parsing date taken from exif");
                 final ExifInterface exif = new ExifInterface(item.mFilePath);
                 final String dateTakenStr = exif.getAttribute(ExifInterface.TAG_DATETIME);
                 if (dateTakenStr != null) {
@@ -1012,12 +1012,14 @@ public final class CacheService extends IntentService {
                 }
                 Log.i(TAG, "Refreshing dirty albums");
                 populateMediaItemsForSets(context, sets, acceleratedSets, true);
-                // Logic to refresh the UI for dirty sets
-                if (context instanceof Gallery) {
-                    int numSets = sets.size();
-                    for (int i = 0; i < numSets; ++i) {
-                        MediaSet set = sets.get(i);
-                        ((Gallery)context).refreshUIForSet(set);
+                if (!Thread.interrupted()) {
+                    // Logic to refresh the UI for dirty sets
+                    if (context instanceof Gallery) {
+                        int numSets = sets.size();
+                        for (int i = 0; i < numSets; ++i) {
+                            MediaSet set = sets.get(i);
+                            ((Gallery) context).refreshUIForSet(set);
+                        }
                     }
                 }
             }
index 2c92295..2bc5f46 100644 (file)
@@ -171,7 +171,6 @@ public final class LocalDataSource implements DataSource {
                     final String whereVideos = Video.VideoColumns.BUCKET_ID + "=" + Long.toString(set.mId);
                     cr.delete(uriImages, whereImages, null);
                     cr.delete(uriVideos, whereVideos, null);
-                    CacheService.markDirty(mContext);
                 }
                 if (set != null && items != null) {
                     // We need to remove these items from the set.
@@ -187,7 +186,6 @@ public final class LocalDataSource implements DataSource {
                     }
                     set.updateNumExpectedItems();
                     set.generateTitle(true);
-                    CacheService.markDirty(mContext, set.mId);
                 }
             }
             break;
index 7461b81..6407ada 100644 (file)
@@ -292,7 +292,6 @@ public class SingleDataSource implements DataSource {
                     final String whereVideos = Video.VideoColumns.BUCKET_ID + "=" + Long.toString(set.mId);
                     cr.delete(uriImages, whereImages, null);
                     cr.delete(uriVideos, whereVideos, null);
-                    CacheService.markDirty(mContext);
                 }
                 if (set != null && items != null) {
                     // We need to remove these items from the set.
@@ -303,7 +302,6 @@ public class SingleDataSource implements DataSource {
                     }
                     set.updateNumExpectedItems();
                     set.generateTitle(true);
-                    CacheService.markDirty(mContext, set.mId);
                 }
             }
             break;