From 41960d8b903443cd6b70a2f98049b93a0a7e20d5 Mon Sep 17 00:00:00 2001 From: Manfred Karrer Date: Tue, 28 Jun 2016 00:19:50 +0200 Subject: [PATCH] add busyanimation to dispute view --- .../disputes/trader/TraderDisputeView.java | 40 ++++++++----------- 1 file changed, 17 insertions(+), 23 deletions(-) diff --git a/gui/src/main/java/io/bitsquare/gui/main/disputes/trader/TraderDisputeView.java b/gui/src/main/java/io/bitsquare/gui/main/disputes/trader/TraderDisputeView.java index 007d3448cb..05ff0fd310 100644 --- a/gui/src/main/java/io/bitsquare/gui/main/disputes/trader/TraderDisputeView.java +++ b/gui/src/main/java/io/bitsquare/gui/main/disputes/trader/TraderDisputeView.java @@ -24,14 +24,15 @@ import io.bitsquare.arbitration.Dispute; import io.bitsquare.arbitration.DisputeManager; import io.bitsquare.arbitration.messages.DisputeCommunicationMessage; import io.bitsquare.arbitration.payload.Attachment; +import io.bitsquare.common.Timer; import io.bitsquare.common.UserThread; import io.bitsquare.common.crypto.KeyRing; import io.bitsquare.common.util.Utilities; import io.bitsquare.gui.common.view.ActivatableView; import io.bitsquare.gui.common.view.FxmlView; +import io.bitsquare.gui.components.BusyAnimation; import io.bitsquare.gui.components.HyperlinkWithIcon; import io.bitsquare.gui.components.TableGroupHeadline; -import io.bitsquare.gui.components.indicator.TxConfidenceIndicator; import io.bitsquare.gui.main.overlays.popups.Popup; import io.bitsquare.gui.main.overlays.windows.ContractWindow; import io.bitsquare.gui.main.overlays.windows.DisputeSummaryWindow; @@ -102,7 +103,7 @@ public class TraderDisputeView extends ActivatableView { private TextArea inputTextArea; private AnchorPane messagesAnchorPane; private VBox messagesInputBox; - private TxConfidenceIndicator sendMsgProgressIndicator; + private BusyAnimation sendMsgBusyAnimation; private Label sendMsgInfoLabel; private ChangeListener arrivedPropertyListener; private ChangeListener storedInMailboxPropertyListener; @@ -307,14 +308,12 @@ public class TraderDisputeView extends ActivatableView { inputTextArea.setDisable(true); inputTextArea.clear(); - io.bitsquare.common.Timer timer = UserThread.runAfter(() -> { + Timer timer = UserThread.runAfter(() -> { sendMsgInfoLabel.setVisible(true); sendMsgInfoLabel.setManaged(true); sendMsgInfoLabel.setText("Sending Message..."); - sendMsgProgressIndicator.setProgress(-1); - sendMsgProgressIndicator.setVisible(true); - sendMsgProgressIndicator.setManaged(true); + sendMsgBusyAnimation.play(); }, 500, TimeUnit.MILLISECONDS); arrivedPropertyListener = (observable, oldValue, newValue) -> { @@ -335,7 +334,7 @@ public class TraderDisputeView extends ActivatableView { disputeCommunicationMessage.storedInMailboxProperty().addListener(storedInMailboxPropertyListener); } - private void hideSendMsgInfo(io.bitsquare.common.Timer timer) { + private void hideSendMsgInfo(Timer timer) { timer.stop(); inputTextArea.setDisable(false); @@ -343,9 +342,7 @@ public class TraderDisputeView extends ActivatableView { sendMsgInfoLabel.setVisible(false); sendMsgInfoLabel.setManaged(false); }, 5); - sendMsgProgressIndicator.setProgress(0); - sendMsgProgressIndicator.setVisible(false); - sendMsgProgressIndicator.setManaged(false); + sendMsgBusyAnimation.stop(); } private void onCloseDispute(Dispute dispute) { @@ -510,15 +507,12 @@ public class TraderDisputeView extends ActivatableView { sendMsgInfoLabel.setManaged(false); sendMsgInfoLabel.setPadding(new Insets(5, 0, 0, 0)); - sendMsgProgressIndicator = new TxConfidenceIndicator(0); - sendMsgProgressIndicator.setPrefSize(24, 24); - sendMsgProgressIndicator.setVisible(false); - sendMsgProgressIndicator.setManaged(false); + sendMsgBusyAnimation = new BusyAnimation(false); if (!selectedDispute.isClosed()) { HBox buttonBox = new HBox(); buttonBox.setSpacing(10); - buttonBox.getChildren().addAll(sendButton, uploadButton, sendMsgProgressIndicator, sendMsgInfoLabel); + buttonBox.getChildren().addAll(sendButton, uploadButton, sendMsgBusyAnimation, sendMsgInfoLabel); if (!isTrader) { Button closeDisputeButton = new Button("Close ticket"); @@ -550,7 +544,7 @@ public class TraderDisputeView extends ActivatableView { @Override public ListCell call(ListView list) { return new ListCell() { - public ChangeListener sendMsgProgressIndicatorListener; + public ChangeListener sendMsgBusyAnimationListener; final Pane bg = new Pane(); final ImageView arrow = new ImageView(); final Label headerLabel = new Label(); @@ -618,18 +612,18 @@ public class TraderDisputeView extends ActivatableView { else arrow.setId("bubble_arrow_blue_right"); - if (sendMsgProgressIndicatorListener != null) - sendMsgProgressIndicator.progressProperty().removeListener(sendMsgProgressIndicatorListener); + if (sendMsgBusyAnimationListener != null) + sendMsgBusyAnimation.runningProperty().removeListener(sendMsgBusyAnimationListener); - sendMsgProgressIndicatorListener = (observable, oldValue, newValue) -> { - if ((double) oldValue == -1 && (double) newValue == 0) { + sendMsgBusyAnimationListener = (observable, oldValue, newValue) -> { + if (!newValue) { if (item.arrivedProperty().get()) showArrivedIcon(); else if (item.storedInMailboxProperty().get()) showMailboxIcon(); } }; - sendMsgProgressIndicator.progressProperty().addListener(sendMsgProgressIndicatorListener); + sendMsgBusyAnimation.runningProperty().addListener(sendMsgBusyAnimationListener); if (item.arrivedProperty().get()) showArrivedIcon(); @@ -722,8 +716,8 @@ public class TraderDisputeView extends ActivatableView { // TODO There are still some cell rendering issues on updates setGraphic(messageAnchorPane); } else { - if (sendMsgProgressIndicator != null && sendMsgProgressIndicatorListener != null) - sendMsgProgressIndicator.progressProperty().removeListener(sendMsgProgressIndicatorListener); + if (sendMsgBusyAnimation != null && sendMsgBusyAnimationListener != null) + sendMsgBusyAnimation.runningProperty().removeListener(sendMsgBusyAnimationListener); messageAnchorPane.prefWidthProperty().unbind();