don't wait with adding untill all elements have been loaded
This commit is contained in:
		@ -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)
 | 
			
		||||
 | 
			
		||||
@ -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;"
 | 
			
		||||
 | 
			
		||||
@ -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() {
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user