Refactor SearchController
This commit is contained in:
parent
a1a7567bd0
commit
959a5c2680
@ -16,22 +16,18 @@ class SearchController(private val model: Model) {
|
|||||||
@FXML
|
@FXML
|
||||||
@Suppress("UnusedPrivateMember")
|
@Suppress("UnusedPrivateMember")
|
||||||
private fun initialize() {
|
private fun initialize() {
|
||||||
textFieldSearch.textProperty().addListener { _, _, newValue ->
|
textFieldSearch.textProperty().addListener { _, _, _ -> search() }
|
||||||
if (newValue.isNullOrBlank()) {
|
searchModeToggleGroup.selectedToggleProperty().addListener { _, _, _ -> search() }
|
||||||
return@addListener
|
}
|
||||||
}
|
|
||||||
|
|
||||||
val searchMode = searchModeToggleGroup.selectedToggle.userData as SearchMode
|
private fun search() {
|
||||||
model.search(newValue, searchMode)
|
val searchQuery = textFieldSearch.text
|
||||||
|
val searchMode = searchModeToggleGroup.selectedToggle.userData as SearchMode
|
||||||
|
|
||||||
|
if (searchQuery.isNullOrBlank()) {
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
searchModeToggleGroup.selectedToggleProperty().addListener { _, _, newValue ->
|
model.search(searchQuery, searchMode)
|
||||||
if (textFieldSearch.text.isNullOrBlank()) {
|
|
||||||
return@addListener
|
|
||||||
}
|
|
||||||
|
|
||||||
val searchMode = newValue.userData as SearchMode
|
|
||||||
model.search(textFieldSearch.text, searchMode)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user