OSDN Git Service

am d490f1aa: Merge "Dejank camera roll scrolling in grid view." into gb-ub-photos...
authorBobby Georgescu <georgescu@google.com>
Tue, 9 Oct 2012 20:23:27 +0000 (13:23 -0700)
committerAndroid Git Automerger <android-git-automerger@android.com>
Tue, 9 Oct 2012 20:23:27 +0000 (13:23 -0700)
* commit 'd490f1aa851db853b9865a380abd01c67605d58b':
  Dejank camera roll scrolling in grid view.

src/com/android/gallery3d/exif/ExifData.java

index 39eb574..7f79713 100644 (file)
@@ -216,7 +216,8 @@ public class ExifData {
     }
 
     /**
-     * Adds a tag with the given tag ID. The original tag will be replaced by the new tag. For tags
+     * Adds a tag with the given tag ID. If the tag of the given ID already exists,
+     * the original tag will be returned. Otherwise, a new ExifTag will be created. For tags
      * related to interoperability or thumbnail, call {@link #addInteroperabilityTag(short)} or
      * {@link #addThumbnailTag(short)} respectively.
      * @exception IllegalArgumentException if the tag ID is invalid.
@@ -224,32 +225,43 @@ public class ExifData {
     public ExifTag addTag(short tagId) {
         int ifdId = ExifTag.getIfdIdFromTagId(tagId);
         IfdData ifdData = getOrCreateIfdData(ifdId);
-        ExifTag tag = ExifTag.buildTag(tagId);
-        ifdData.setTag(tag);
+        ExifTag tag = ifdData.getTag(tagId);
+        if (tag == null) {
+            tag = ExifTag.buildTag(tagId);
+            ifdData.setTag(tag);
+        }
         return tag;
     }
 
     /**
-     * Adds a thumbnail-related tag with the given tag ID. The original tag will be replaced
-     * by the new tag.
+     * Adds a thumbnail-related tag with the given tag ID. If the tag of the given ID
+     * already exists, the original tag will be returned. Otherwise, a new ExifTag will
+     * be created.
      * @exception IllegalArgumentException if the tag ID is invalid.
      */
     public ExifTag addThumbnailTag(short tagId) {
         IfdData ifdData = getOrCreateIfdData(IfdId.TYPE_IFD_1);
-        ExifTag tag = ExifTag.buildThumbnailTag(tagId);
-        ifdData.setTag(tag);
+        ExifTag tag = ifdData.getTag(tagId);
+        if (tag == null) {
+            tag = ExifTag.buildThumbnailTag(tagId);
+            ifdData.setTag(tag);
+        }
         return tag;
     }
 
     /**
-     * Adds an interoperability-related tag with the given tag ID. The original tag will be
-     * replaced by the new tag.
+     * Adds an interoperability-related tag with the given tag ID. If the tag of the given ID
+     * already exists, the original tag will be returned. Otherwise, a new ExifTag will
+     * be created.
      * @exception IllegalArgumentException if the tag ID is invalid.
      */
     public ExifTag addInteroperabilityTag(short tagId) {
         IfdData ifdData = getOrCreateIfdData(IfdId.TYPE_IFD_INTEROPERABILITY);
-        ExifTag tag = ExifTag.buildInteroperabilityTag(tagId);
-        ifdData.setTag(tag);
+        ExifTag tag = ifdData.getTag(tagId);
+        if (tag == null) {
+            tag = ExifTag.buildInteroperabilityTag(tagId);
+            ifdData.setTag(tag);
+        }
         return tag;
     }
 
@@ -258,4 +270,4 @@ public class ExifData {
         mStripBytes.clear();
         mIfdDatas[IfdId.TYPE_IFD_1] = null;
     }
-}
\ No newline at end of file
+}