From bd9dc8b04bee471cd5507ce68134f34e91e64e6a Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 10 Feb 2020 22:09:06 +0100 Subject: [PATCH] properly handle empty size or dates at comparing --- .../com/simplemobiletools/gallery/pro/extensions/Context.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Context.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Context.kt index d481041e8..adbc6c957 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Context.kt @@ -182,9 +182,9 @@ fun Context.getSortedDirectories(source: ArrayList): ArrayList AlphanumericComparator().compare(o1.sortValue.toLowerCase(), o2.sortValue.toLowerCase()) - sorting and SORT_BY_SIZE != 0 -> (o1.sortValue.toLong()).compareTo(o2.sortValue.toLong()) - sorting and SORT_BY_DATE_MODIFIED != 0 -> (o1.sortValue.toLong()).compareTo(o2.sortValue.toLong()) - else -> (o1.sortValue.toLong()).compareTo(o2.sortValue.toLong()) + sorting and SORT_BY_SIZE != 0 -> (o1.sortValue.toLongOrNull() ?: 0).compareTo(o2.sortValue.toLongOrNull() ?: 0) + sorting and SORT_BY_DATE_MODIFIED != 0 -> (o1.sortValue.toLongOrNull() ?: 0).compareTo(o2.sortValue.toLongOrNull() ?: 0) + else -> (o1.sortValue.toLongOrNull() ?: 0).compareTo(o2.sortValue.toLongOrNull() ?: 0) } if (sorting and SORT_DESCENDING != 0) {