From b952c070433a88889bfb571700f3e90dc4930da6 Mon Sep 17 00:00:00 2001 From: MoonLake Date: Wed, 2 Aug 2017 01:21:09 +0800 Subject: [PATCH] =?UTF-8?q?[Fix]=20=E4=BF=AE=E5=A4=8D=E7=BA=BF=E7=A8=8B?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E6=89=80=E9=80=A0=E6=88=90=E7=9A=84=E7=AC=AC?= =?UTF-8?q?=E4=BA=8C=E6=AC=A1=E4=B8=8B=E8=BD=BD=E6=8E=A7=E4=BB=B6=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E4=BF=A1=E6=81=AF=E4=B8=8D=E4=BC=9A=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../optifinecrawler/gui/OptifineCrawlerGui.kt | 26 +++---------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/src/main/kotlin/com/minecraft/moonlake/optifinecrawler/gui/OptifineCrawlerGui.kt b/src/main/kotlin/com/minecraft/moonlake/optifinecrawler/gui/OptifineCrawlerGui.kt index 982e767..d888539 100644 --- a/src/main/kotlin/com/minecraft/moonlake/optifinecrawler/gui/OptifineCrawlerGui.kt +++ b/src/main/kotlin/com/minecraft/moonlake/optifinecrawler/gui/OptifineCrawlerGui.kt @@ -158,33 +158,15 @@ class OptifineCrawlerGui: Application() { task.stateProperty().addListener { _, _, newValue -> run { when(newValue) { Worker.State.SCHEDULED -> disableBtnGroupButton(disableBtnGroup) - Worker.State.CANCELLED, Worker.State.FAILED, Worker.State.SUCCEEDED -> releaseDownloadGroup() + Worker.State.CANCELLED, Worker.State.FAILED, Worker.State.SUCCEEDED -> disableBtnGroupButton(false) else -> { } } }} downloadProgress.progressProperty().bind(task.progressProperty()) downloadLabel.textProperty().bind(task.messageProperty()) - Thread(task).start() - } - - private fun releaseDownloadGroup() { - val service = object: ScheduledService() { - override fun createTask(): Task { - return object: Task() { - override fun call() { - Platform.runLater { - disableBtnGroupButton(false) - downloadProgress.progressProperty().unbind() - downloadProgress.progress = -1.0 - downloadLabel.textProperty().unbind() - downloadLabel.text = "No Download" - } - } - } - } - } - service.delay = Duration.seconds(3.0) - service.start() + val thread = Thread(task, "OptifineCrawler Download Task") + thread.isDaemon = true + thread.start() } private fun disableBtnGroupButton(state: Boolean) {