feat: Added fileSize for getPhotos API (#180)

Co-authored-by: Antonio Gallo <antgallo@amazon.com>
This commit is contained in:
Antonio Gallo
2020-05-20 20:35:59 +03:00
committed by GitHub
co-authored by Antonio Gallo
parent 306bc75027
commit e7cf8665d4
5 changed files with 10 additions and 1 deletions
@@ -79,6 +79,7 @@ public class CameraRollModule extends ReactContextBaseJavaModule {
Images.Media.DATE_TAKEN,
MediaStore.MediaColumns.WIDTH,
MediaStore.MediaColumns.HEIGHT,
MediaStore.MediaColumns.SIZE,
MediaStore.MediaColumns.DATA
};
@@ -465,13 +466,14 @@ public class CameraRollModule extends ReactContextBaseJavaModule {
int dateTakenIndex = media.getColumnIndex(Images.Media.DATE_TAKEN);
int widthIndex = media.getColumnIndex(MediaStore.MediaColumns.WIDTH);
int heightIndex = media.getColumnIndex(MediaStore.MediaColumns.HEIGHT);
int sizeIndex = media.getColumnIndex(MediaStore.MediaColumns.SIZE);
int dataIndex = media.getColumnIndex(MediaStore.MediaColumns.DATA);
for (int i = 0; i < limit && !media.isAfterLast(); i++) {
WritableMap edge = new WritableNativeMap();
WritableMap node = new WritableNativeMap();
boolean imageInfoSuccess =
putImageInfo(resolver, media, node, idIndex, widthIndex, heightIndex, dataIndex, mimeTypeIndex);
putImageInfo(resolver, media, node, idIndex, widthIndex, heightIndex, sizeIndex, dataIndex, mimeTypeIndex);
if (imageInfoSuccess) {
putBasicNodeInfo(media, node, mimeTypeIndex, groupNameIndex, dateTakenIndex);
putLocationInfo(media, node, dataIndex);
@@ -506,6 +508,7 @@ public class CameraRollModule extends ReactContextBaseJavaModule {
int idIndex,
int widthIndex,
int heightIndex,
int sizeIndex,
int dataIndex,
int mimeTypeIndex) {
WritableMap image = new WritableNativeMap();
@@ -516,6 +519,7 @@ public class CameraRollModule extends ReactContextBaseJavaModule {
image.putString("filename", strFileName);
float width = media.getInt(widthIndex);
float height = media.getInt(heightIndex);
long fileSize = media.getLong(sizeIndex);
String mimeType = media.getString(mimeTypeIndex);
@@ -575,6 +579,7 @@ public class CameraRollModule extends ReactContextBaseJavaModule {
}
image.putDouble("width", width);
image.putDouble("height", height);
image.putDouble("fileSize", fileSize);
node.putMap("image", image);
return true;