Fixed unknown date taken (#2295)

This commit is contained in:
Agnieszka C 2021-12-08 15:30:38 +01:00
parent f88e1848d7
commit adf2fc26da

View file

@ -439,7 +439,7 @@ class MediaFetcher(val context: Context) {
val filename = cursor.getStringValue(Images.Media.DISPLAY_NAME) val filename = cursor.getStringValue(Images.Media.DISPLAY_NAME)
val path = cursor.getStringValue(Images.Media.DATA) val path = cursor.getStringValue(Images.Media.DATA)
val lastModified = cursor.getLongValue(Images.Media.DATE_MODIFIED) * 1000 val lastModified = cursor.getLongValue(Images.Media.DATE_MODIFIED) * 1000
val dateTaken = cursor.getLongValue(Images.Media.DATE_TAKEN) var dateTaken = cursor.getLongValue(Images.Media.DATE_TAKEN)
val size = cursor.getLongValue(Images.Media.SIZE) val size = cursor.getLongValue(Images.Media.SIZE)
val videoDuration = Math.round(cursor.getIntValue(MediaStore.MediaColumns.DURATION) / 1000.toDouble()).toInt() val videoDuration = Math.round(cursor.getIntValue(MediaStore.MediaColumns.DURATION) / 1000.toDouble()).toInt()
@ -485,6 +485,10 @@ class MediaFetcher(val context: Context) {
else -> TYPE_IMAGES else -> TYPE_IMAGES
} }
if (dateTaken == 0L) {
dateTaken = lastModified
}
val isFavorite = favoritePaths.contains(path) val isFavorite = favoritePaths.contains(path)
val medium = val medium =
Medium(null, filename, path, path.getParentPath(), lastModified, dateTaken, size, type, videoDuration, isFavorite, 0L, mediaStoreId) Medium(null, filename, path, path.getParentPath(), lastModified, dateTaken, size, type, videoDuration, isFavorite, 0L, mediaStoreId)