Skip to content

Commit

Permalink
#1223 remove unnecessary functions for creating comparators
Browse files Browse the repository at this point in the history
  • Loading branch information
sds100 committed Jan 22, 2025
1 parent 9070e83 commit 5eb072b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 26 deletions.
22 changes: 0 additions & 22 deletions app/src/main/java/io/github/sds100/keymapper/sorting/SortField.kt
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
package io.github.sds100.keymapper.sorting

import io.github.sds100.keymapper.constraints.ConstraintUiHelper
import io.github.sds100.keymapper.sorting.comparators.KeyMapActionsComparator
import io.github.sds100.keymapper.sorting.comparators.KeyMapConstraintsComparator
import io.github.sds100.keymapper.sorting.comparators.KeyMapOptionsComparator
import io.github.sds100.keymapper.sorting.comparators.KeyMapTriggerComparator
import kotlinx.serialization.Serializable

@Serializable
Expand All @@ -14,20 +9,3 @@ enum class SortField {
CONSTRAINTS,
OPTIONS,
}

fun SortField.Companion.getTriggerComparator(
reverse: Boolean,
) = KeyMapTriggerComparator(reverse)

fun SortField.Companion.getActionsComparator(
reverse: Boolean,
) = KeyMapActionsComparator(reverse)

fun SortField.Companion.getConstraintsComparator(
constraintUiHelper: ConstraintUiHelper,
reverse: Boolean,
) = KeyMapConstraintsComparator(constraintUiHelper, reverse)

fun SortField.Companion.getOptionsComparator(
reverse: Boolean,
) = KeyMapOptionsComparator(reverse)
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ import io.github.sds100.keymapper.data.Keys
import io.github.sds100.keymapper.data.repositories.PreferenceRepository
import io.github.sds100.keymapper.mappings.DisplaySimpleMappingUseCase
import io.github.sds100.keymapper.mappings.keymaps.KeyMap
import io.github.sds100.keymapper.sorting.comparators.KeyMapActionsComparator
import io.github.sds100.keymapper.sorting.comparators.KeyMapConstraintsComparator
import io.github.sds100.keymapper.sorting.comparators.KeyMapOptionsComparator
import io.github.sds100.keymapper.sorting.comparators.KeyMapTriggerComparator
import io.github.sds100.keymapper.util.ui.ResourceProviderImpl
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.map
Expand All @@ -19,6 +23,9 @@ class SortKeyMapsUseCaseImpl(
private val constraintUiHelper =
ConstraintUiHelper(displaySimpleMappingUseCase, resourceProvider)

private val actionUiHelper =
ConstraintUiHelper(displaySimpleMappingUseCase, resourceProvider)

private val defaultOrder = listOf(
SortFieldOrder(SortField.TRIGGER),
SortFieldOrder(SortField.ACTIONS),
Expand Down Expand Up @@ -74,16 +81,16 @@ class SortKeyMapsUseCaseImpl(
val reverseOrder = sortFieldOrder.order == SortOrder.DESCENDING

return when (sortFieldOrder.field) {
SortField.TRIGGER -> SortField.getTriggerComparator(reverseOrder)
SortField.TRIGGER -> KeyMapTriggerComparator(reverseOrder)

SortField.ACTIONS -> SortField.getActionsComparator(reverseOrder)
SortField.ACTIONS -> KeyMapActionsComparator(reverseOrder)

SortField.CONSTRAINTS -> SortField.getConstraintsComparator(
SortField.CONSTRAINTS -> KeyMapConstraintsComparator(
constraintUiHelper,
reverseOrder,
)

SortField.OPTIONS -> SortField.getOptionsComparator(reverseOrder)
SortField.OPTIONS -> KeyMapOptionsComparator(reverseOrder)
}
}
}
Expand Down

0 comments on commit 5eb072b

Please sign in to comment.