diff --git a/app/build.gradle b/app/build.gradle index 3e3bc000c..572ac4a1a 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -37,7 +37,7 @@ android { } dependencies { - compile 'com.simplemobiletools:commons:2.25.0' + compile 'com.simplemobiletools:commons:2.25.1' compile 'com.davemorrissey.labs:subsampling-scale-image-view:3.6.0' compile 'com.theartofdev.edmodo:android-image-cropper:2.4.0' compile 'com.bignerdranch.android:recyclerview-multiselect:0.2' diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/models/Directory.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/models/Directory.kt index 77cd94602..6293eba76 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/models/Directory.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/models/Directory.kt @@ -1,9 +1,6 @@ package com.simplemobiletools.gallery.models -import com.simplemobiletools.commons.helpers.SORT_BY_DATE_MODIFIED -import com.simplemobiletools.commons.helpers.SORT_BY_NAME -import com.simplemobiletools.commons.helpers.SORT_BY_SIZE -import com.simplemobiletools.commons.helpers.SORT_DESCENDING +import com.simplemobiletools.commons.helpers.* import java.io.Serializable data class Directory(val path: String, val tmb: String, val name: String, var mediaCnt: Int, val modified: Long, val taken: Long, @@ -20,7 +17,7 @@ data class Directory(val path: String, val tmb: String, val name: String, var me override fun compareTo(other: Directory): Int { var result: Int if (sorting and SORT_BY_NAME != 0) { - result = name.toLowerCase().compareTo(other.name.toLowerCase()) + result = AlphanumComparator().compare(name.toLowerCase(), other.name.toLowerCase()) } else if (sorting and SORT_BY_SIZE != 0) { result = if (size == other.size) 0 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 0fb1aa59a..1663c60b1 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/models/Medium.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/models/Medium.kt @@ -3,10 +3,7 @@ package com.simplemobiletools.gallery.models import com.simplemobiletools.commons.extensions.getMimeType import com.simplemobiletools.commons.extensions.isGif import com.simplemobiletools.commons.extensions.isPng -import com.simplemobiletools.commons.helpers.SORT_BY_DATE_MODIFIED -import com.simplemobiletools.commons.helpers.SORT_BY_NAME -import com.simplemobiletools.commons.helpers.SORT_BY_SIZE -import com.simplemobiletools.commons.helpers.SORT_DESCENDING +import com.simplemobiletools.commons.helpers.* import java.io.File import java.io.Serializable @@ -27,25 +24,25 @@ data class Medium(var name: String, var path: String, val video: Boolean, val mo fun getMimeType() = File(path).getMimeType() override fun compareTo(other: Medium): Int { - var res: Int + var result: Int if (sorting and SORT_BY_NAME != 0) { - res = name.toLowerCase().compareTo(other.name.toLowerCase()) + result = AlphanumComparator().compare(name.toLowerCase(), other.name.toLowerCase()) } else if (sorting and SORT_BY_SIZE != 0) { - res = if (size == other.size) + result = if (size == other.size) 0 else if (size > other.size) 1 else -1 } else if (sorting and SORT_BY_DATE_MODIFIED != 0) { - res = if (modified == other.modified) + result = if (modified == other.modified) 0 else if (modified > other.modified) 1 else -1 } else { - res = if (taken == other.taken) + result = if (taken == other.taken) 0 else if (taken > other.taken) 1 @@ -54,8 +51,8 @@ data class Medium(var name: String, var path: String, val video: Boolean, val mo } if (sorting and SORT_DESCENDING != 0) { - res *= -1 + result *= -1 } - return res + return result } }