mirror of
https://github.com/SimpleMobileTools/Simple-App-Launcher.git
synced 2025-03-28 17:10:15 +01:00
properly handle custom sorting
This commit is contained in:
parent
4da1259e58
commit
da7acb2c9f
@ -93,16 +93,18 @@ class LaunchersAdapter(activity: SimpleActivity, val launchers: ArrayList<AppLau
|
||||
override fun onActionModeCreated() {}
|
||||
|
||||
override fun onActionModeDestroyed() {
|
||||
if (isChangingOrder) {
|
||||
notifyDataSetChanged()
|
||||
launchers.forEachIndexed { index, appLauncher ->
|
||||
appLauncher.order = index + 1
|
||||
}
|
||||
|
||||
launchers.forEach {
|
||||
activity.dbHelper.updateLauncherOrder(it.id, it.order)
|
||||
}
|
||||
}
|
||||
|
||||
isChangingOrder = false
|
||||
notifyDataSetChanged()
|
||||
|
||||
launchers.forEachIndexed { index, appLauncher ->
|
||||
appLauncher.order = index + 1
|
||||
}
|
||||
|
||||
launchers.forEach {
|
||||
activity.dbHelper.updateLauncherOrder(it.id, it.order)
|
||||
}
|
||||
}
|
||||
|
||||
private fun changeOrder() {
|
||||
|
@ -16,7 +16,17 @@ data class AppLauncher(val id: Int, var title: String, val packageName: String,
|
||||
override fun compareTo(other: AppLauncher): Int {
|
||||
var result = when {
|
||||
sorting and SORT_BY_TITLE != 0 -> title.toLowerCase().compareTo(other.title.toLowerCase())
|
||||
else -> order.compareTo(other.order)
|
||||
else -> {
|
||||
if (order > 0 && other.order == 0) {
|
||||
-1
|
||||
} else if (order == 0 && other.order > 0) {
|
||||
1
|
||||
} else if (order > 0 && other.order > 0) {
|
||||
order.compareTo(other.order)
|
||||
} else {
|
||||
title.toLowerCase().compareTo(other.title.toLowerCase())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (sorting and SORT_DESCENDING != 0) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user