Merge pull request #2297 from Aga-C/fix-unknown-date-taken

Fixed unknown date taken (#2295)
This commit is contained in:
Tibor Kaputa 2021-12-17 15:26:40 +01:00 committed by GitHub
commit 419ee3b174
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

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