don't wait with adding untill all elements have been loaded

This commit is contained in:
Jannik 2019-06-07 16:19:04 +02:00
parent 2c9a23ec8a
commit d5b7fd0f94
Signed by: Seil0
GPG Key ID: E8459F3723C52C24
3 changed files with 8 additions and 20 deletions

View File

@ -121,12 +121,16 @@ class RootController : Controller() {
}
}
fun search(tags: ObservableList<String>): ArrayList<GUIModel> {
fun queryElements(tags: ObservableList<String>): ArrayList<GUIModel> {
val previewList = arrayListOf<GUIModel>()
try {
con.query(tags.toTypedArray()).forEach {
previewList.add(GUIModel(it, con.getTexturePreview(it.textureHash)))
runAsync {
Platform.runLater {
mvc.addElement(GUIModel(it, con.getTexturePreview(it.textureHash)))
}
}
}
} catch (e: Exception) {
println(e)

View File

@ -14,7 +14,6 @@ import tornadofx.*
class MainView : View() {
val cvSearch = JFXChipView<String>()
val spinnerSearch = JFXSpinner()
val folderView = find(FolderView::class)
val detailView = find(DetailView::class)
@ -35,7 +34,6 @@ class MainView : View() {
this.vbarPolicy = ScrollPane.ScrollBarPolicy.ALWAYS
add(folderView.root)
}
add(spinnerSearch)
}
}
@ -43,14 +41,6 @@ class MainView : View() {
right = detailView.root
style {
spinnerSearch.isVisible = false
spinnerSearch.anchorpaneConstraints {
topAnchor = 150
bottomAnchor = 150
leftAnchor = 150
rightAnchor = 150
}
cvSearch.paddingAll = 7.0
cvSearch.minHeight = 70.0
cvSearch.style = "-fx-background-color: #3c3f41; -fx-text-inner-color: #b15b2e;"

View File

@ -51,23 +51,17 @@ class MainViewController : Controller() {
// DetailView actions
fun cvSearchAction(tags: ObservableList<String>) {
var previewList = arrayListOf<GUIModel>()
// show spinner, block ui
folderView.children.clear()
mv.spinnerSearch.isVisible = true
mv.cvSearch.isDisable = true
runAsync {
previewList = rootc.search(tags)
//previewList = rootc.search(tags)
rootc.queryElements(tags)
} ui {
// when search finished
addAllElements(previewList)
mv.spinnerSearch.isVisible = false
mv.cvSearch.isDisable = false
}
}
fun btnImportAction() {