fix: (Android) Fixed issue where timestamp was "0" (#277)

This commit is contained in:
Hanno J. Gödecke 2021-03-21 04:34:01 +01:00 committed by GitHub
parent 7fa9b7c062
commit a5befe328c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 3 deletions

View File

@ -86,6 +86,8 @@ public class CameraRollModule extends ReactContextBaseJavaModule {
Images.Media.MIME_TYPE, Images.Media.MIME_TYPE,
Images.Media.BUCKET_DISPLAY_NAME, Images.Media.BUCKET_DISPLAY_NAME,
Images.Media.DATE_TAKEN, Images.Media.DATE_TAKEN,
MediaStore.MediaColumns.DATE_ADDED,
MediaStore.MediaColumns.DATE_MODIFIED,
MediaStore.MediaColumns.WIDTH, MediaStore.MediaColumns.WIDTH,
MediaStore.MediaColumns.HEIGHT, MediaStore.MediaColumns.HEIGHT,
MediaStore.MediaColumns.SIZE, MediaStore.MediaColumns.SIZE,
@ -501,6 +503,8 @@ public class CameraRollModule extends ReactContextBaseJavaModule {
int mimeTypeIndex = media.getColumnIndex(Images.Media.MIME_TYPE); int mimeTypeIndex = media.getColumnIndex(Images.Media.MIME_TYPE);
int groupNameIndex = media.getColumnIndex(Images.Media.BUCKET_DISPLAY_NAME); int groupNameIndex = media.getColumnIndex(Images.Media.BUCKET_DISPLAY_NAME);
int dateTakenIndex = media.getColumnIndex(Images.Media.DATE_TAKEN); int dateTakenIndex = media.getColumnIndex(Images.Media.DATE_TAKEN);
int dateAddedIndex = media.getColumnIndex(MediaStore.MediaColumns.DATE_ADDED);
int dateModifiedIndex = media.getColumnIndex(MediaStore.MediaColumns.DATE_MODIFIED);
int widthIndex = media.getColumnIndex(MediaStore.MediaColumns.WIDTH); int widthIndex = media.getColumnIndex(MediaStore.MediaColumns.WIDTH);
int heightIndex = media.getColumnIndex(MediaStore.MediaColumns.HEIGHT); int heightIndex = media.getColumnIndex(MediaStore.MediaColumns.HEIGHT);
int sizeIndex = media.getColumnIndex(MediaStore.MediaColumns.SIZE); int sizeIndex = media.getColumnIndex(MediaStore.MediaColumns.SIZE);
@ -520,7 +524,7 @@ public class CameraRollModule extends ReactContextBaseJavaModule {
mimeTypeIndex, includeFilename, includeFileSize, includeImageSize, mimeTypeIndex, includeFilename, includeFileSize, includeImageSize,
includePlayableDuration); includePlayableDuration);
if (imageInfoSuccess) { if (imageInfoSuccess) {
putBasicNodeInfo(media, node, mimeTypeIndex, groupNameIndex, dateTakenIndex); putBasicNodeInfo(media, node, mimeTypeIndex, groupNameIndex, dateTakenIndex, dateAddedIndex, dateModifiedIndex);
putLocationInfo(media, node, dataIndex, includeLocation); putLocationInfo(media, node, dataIndex, includeLocation);
edge.putMap("node", node); edge.putMap("node", node);
@ -540,10 +544,18 @@ public class CameraRollModule extends ReactContextBaseJavaModule {
WritableMap node, WritableMap node,
int mimeTypeIndex, int mimeTypeIndex,
int groupNameIndex, int groupNameIndex,
int dateTakenIndex) { int dateTakenIndex,
int dateAddedIndex,
int dateModifiedIndex) {
node.putString("type", media.getString(mimeTypeIndex)); node.putString("type", media.getString(mimeTypeIndex));
node.putString("group_name", media.getString(groupNameIndex)); node.putString("group_name", media.getString(groupNameIndex));
node.putDouble("timestamp", media.getLong(dateTakenIndex) / 1000d); long dateTaken = media.getLong(dateTakenIndex);
if (dateTaken == 0L) {
//date added is in seconds, date taken in milliseconds, thus the multiplication
dateTaken = media.getLong(dateAddedIndex) * 1000;
}
node.putDouble("timestamp", dateTaken / 1000d);
node.putDouble("modified", media.getLong(dateModifiedIndex));
} }
/** /**