From 353dccf142d4895e9c5546743d5183e533c22ace Mon Sep 17 00:00:00 2001 From: Shadi Shaheen Date: Wed, 17 Jun 2020 14:41:49 +0300 Subject: [PATCH] fixed #1101 Exception when closing Snackbar while a event is still active --- .../com/jfoenix/controls/JFXSnackbar.java | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/jfoenix/src/main/java/com/jfoenix/controls/JFXSnackbar.java b/jfoenix/src/main/java/com/jfoenix/controls/JFXSnackbar.java index f16e3cad..2503a5d2 100644 --- a/jfoenix/src/main/java/com/jfoenix/controls/JFXSnackbar.java +++ b/jfoenix/src/main/java/com/jfoenix/controls/JFXSnackbar.java @@ -244,13 +244,15 @@ private Timeline getTimeline(Duration timeout) { pauseTransition = Duration.INDEFINITE.equals(timeout) ? null : new PauseTransition(timeout); if (pauseTransition != null) { animation.setOnFinished(finish -> { - pauseTransition.setOnFinished(done -> { - pauseTransition = null; - eventsSet.remove(currentEvent); - currentEvent = eventQueue.peek(); - close(); - }); - pauseTransition.play(); + if (pauseTransition != null) { + pauseTransition.setOnFinished(done -> { + pauseTransition = null; + eventsSet.remove(currentEvent); + currentEvent = eventQueue.peek(); + close(); + }); + pauseTransition.play(); + } }); } return animation; @@ -261,6 +263,10 @@ public void close() { openAnimation.stop(); } if (this.isVisible()) { + if (pauseTransition != null) { + pauseTransition.stop(); + pauseTransition = null; + } Timeline closeAnimation = new Timeline( new KeyFrame( Duration.ZERO,