Skip to content

Commit

Permalink
fix(android): consider double and int separately
Browse files Browse the repository at this point in the history
  • Loading branch information
ER-lee-byeoksan committed Apr 23, 2024
1 parent 6f498c0 commit 5c32d25
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions android/src/main/java/com/lodev09/exify/ExifyModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,18 @@ class ExifyModule(reactContext: ReactApplicationContext) :
context.contentResolver.openFileDescriptor(photoUri, "rw", null)?.use { parcelDescriptor ->
val exif = ExifInterface(parcelDescriptor.fileDescriptor)

for ((_, tag) in EXIFY_TAGS) {
for ((valType, tag) in EXIFY_TAGS) {
if (!tags.hasKey(tag)) continue

val type = tags.getType(tag)

when (type) {
ReadableType.Boolean -> exif.setAttribute(tag, tags.getBoolean(tag).toString())
ReadableType.Number -> exif.setAttribute(tag, tags.getDouble(tag).toBigDecimal().toPlainString())
ReadableType.Number ->
when (valType) {
"double" -> exif.setAttribute(tag, tags.getDouble(tag).toBigDecimal().toPlainString())
else -> exif.setAttribute(tag, tags.getDouble(tag).toInt().toString())
}
ReadableType.String -> exif.setAttribute(tag, tags.getString(tag))
ReadableType.Array -> exif.setAttribute(tag, tags.getArray(tag).toString())
else -> exif.setAttribute(tag, tags.getString(tag))
Expand Down

0 comments on commit 5c32d25

Please sign in to comment.