diff options
author | Jean-Baptiste Queru <jbq@google.com> | 2011-05-26 07:43:16 -0700 |
---|---|---|
committer | Android Code Review <code-review@android.com> | 2011-05-26 07:43:16 -0700 |
commit | 61ab647c5ad9a101a01fff7f677fead8d37ebfba (patch) | |
tree | 6d7c2a37da22e45e630ea3ebe1d3105388ce3508 | |
parent | f54826e41455af5f59d6fb6ba804cfd57be992ff (diff) | |
parent | 922280596ba53e3e1d71d332e8ca1d4e8b89c716 (diff) | |
download | Gallery3D-61ab647c5ad9a101a01fff7f677fead8d37ebfba.tar.gz |
Merge "Fixed the issue that media sets still appear after deleting all albums in Gallery3D." into gingerbread
-rw-r--r-- | src/com/cooliris/cache/CacheService.java | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/src/com/cooliris/cache/CacheService.java b/src/com/cooliris/cache/CacheService.java index c8a5fc0..6f68913 100644 --- a/src/com/cooliris/cache/CacheService.java +++ b/src/com/cooliris/cache/CacheService.java @@ -1011,26 +1011,33 @@ public final class CacheService extends IntentService { } ++ctr; } while (ctr < numSets); - // We now check for any deleted sets. - final byte[] albumData = sAlbumCache.get(ALBUM_CACHE_METADATA_INDEX, 0); - if (albumData != null && albumData.length > 0) { - final DataInputStream dis = new DataInputStream(new BufferedInputStream(new ByteArrayInputStream(albumData), 256)); - try { - final int numAlbums = dis.readInt(); - for (int i = 0; i < numAlbums; ++i) { - final long setId = dis.readLong(); - Utils.readUTF(dis); - dis.readBoolean(); - dis.readBoolean(); - if (!setIds.contains(setId)) { + } + // We now check for any deleted sets. + final byte[] albumData = sAlbumCache.get(ALBUM_CACHE_METADATA_INDEX, 0); + if (albumData != null && albumData.length > 0) { + final DataInputStream dis = new DataInputStream(new BufferedInputStream(new ByteArrayInputStream(albumData), 256)); + try { + final int numAlbums = dis.readInt(); + for (int i = 0; i < numAlbums; ++i) { + final long setId = dis.readLong(); + Utils.readUTF(dis); + dis.readBoolean(); + dis.readBoolean(); + if (!setIds.contains(setId)) { + final byte[] existingData = sAlbumCache.get(ALBUM_CACHE_DIRTY_INDEX, 0); + if (existingData != null && existingData.length == 1 + && existingData[0] == sDummyData[0]) { + // markDirty() was already called, skip this time. + // (not do it too aggressively) + } else { // This set was deleted, we need to recompute the cache. markDirty(); - break; } + break; } - } catch (Exception e) { - ; } + } catch (Exception e) { + ; } } } finally { |