update commons to 2.25.1 for proper alphanumeric sorting

This commit is contained in:
tibbi 2017-08-06 14:08:17 +02:00
parent a493595207
commit 1074043c93
3 changed files with 11 additions and 17 deletions

View file

@ -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'

View file

@ -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

View file

@ -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
}
}