From 66221ff82d1e2834c74789df0360bc4fd390bd8f Mon Sep 17 00:00:00 2001 From: tibbi Date: Wed, 30 Nov 2016 23:09:48 +0100 Subject: [PATCH] update the medium comparison function, allow result 0 --- .../com/simplemobiletools/gallery/models/Medium.kt | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/models/Medium.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/models/Medium.kt index 06c5fdfb3..8c2ddd839 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/models/Medium.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/models/Medium.kt @@ -19,9 +19,19 @@ class Medium(val name: String, var path: String, val isVideo: Boolean, val times if (sorting and SORT_BY_NAME != 0) { res = name.toLowerCase().compareTo(other.name.toLowerCase()) } else if (sorting and SORT_BY_DATE != 0) { - res = if (timestamp > other.timestamp) 1 else -1 + res = if (timestamp == other.timestamp) + 0 + else if (timestamp > other.timestamp) + 1 + else + -1 } else { - res = if (size > other.size) 1 else -1 + res = if (size == other.size) + 0 + else if (size > other.size) + 1 + else + -1 } if (sorting and SORT_DESCENDING != 0) {