some code style update at the Directory and Medium classes

This commit is contained in:
tibbi 2017-09-24 22:51:03 +02:00
parent 2640f99e22
commit 7a653ec0c6
2 changed files with 34 additions and 46 deletions

View File

@ -16,29 +16,23 @@ 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 = AlphanumComparator().compare(name.toLowerCase(), other.name.toLowerCase())
} else if (sorting and SORT_BY_SIZE != 0) {
result = if (size == other.size)
0
else if (size > other.size)
1
else
-1
} else if (sorting and SORT_BY_DATE_MODIFIED != 0) {
result = if (modified == other.modified)
0
else if (modified > other.modified)
1
else
-1
} else {
result = if (taken == other.taken)
0
else if (taken > other.taken)
1
else
-1
when {
sorting and SORT_BY_NAME != 0 -> result = AlphanumComparator().compare(name.toLowerCase(), other.name.toLowerCase())
sorting and SORT_BY_SIZE != 0 -> result = when {
size == other.size -> 0
size > other.size -> 1
else -> -1
}
sorting and SORT_BY_DATE_MODIFIED != 0 -> result = when {
modified == other.modified -> 0
modified > other.modified -> 1
else -> -1
}
else -> result = when {
taken == other.taken -> 0
taken > other.taken -> 1
else -> -1
}
}
if (sorting and SORT_DESCENDING != 0) {

View File

@ -25,29 +25,23 @@ data class Medium(var name: String, var path: String, val video: Boolean, val mo
override fun compareTo(other: Medium): Int {
var result: Int
if (sorting and SORT_BY_NAME != 0) {
result = AlphanumComparator().compare(name.toLowerCase(), other.name.toLowerCase())
} else if (sorting and SORT_BY_SIZE != 0) {
result = if (size == other.size)
0
else if (size > other.size)
1
else
-1
} else if (sorting and SORT_BY_DATE_MODIFIED != 0) {
result = if (modified == other.modified)
0
else if (modified > other.modified)
1
else
-1
} else {
result = if (taken == other.taken)
0
else if (taken > other.taken)
1
else
-1
when {
sorting and SORT_BY_NAME != 0 -> result = AlphanumComparator().compare(name.toLowerCase(), other.name.toLowerCase())
sorting and SORT_BY_SIZE != 0 -> result = when {
size == other.size -> 0
size > other.size -> 1
else -> -1
}
sorting and SORT_BY_DATE_MODIFIED != 0 -> result = when {
modified == other.modified -> 0
modified > other.modified -> 1
else -> -1
}
else -> result = when {
taken == other.taken -> 0
taken > other.taken -> 1
else -> -1
}
}
if (sorting and SORT_DESCENDING != 0) {