From 968865037144227b1615ca965e77640373514c1a Mon Sep 17 00:00:00 2001 From: vito Date: Wed, 11 Jul 2018 16:33:25 +0800 Subject: [PATCH] =?UTF-8?q?CORE-91=20=E8=AE=BE=E8=AE=A1=E5=90=AF=E5=8A=A8?= =?UTF-8?q?=E5=8A=A8=E7=94=BB=E4=B8=8D=E9=87=8A=E6=94=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/start/fx/FastGifImage.java | 10 +++++++++- .../src/main/java/com/fr/start/fx/SplashFxWindow.java | 7 +++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/start/fx/FastGifImage.java b/designer-realize/src/main/java/com/fr/start/fx/FastGifImage.java index 69d74c8a4..9eb3ecef2 100644 --- a/designer-realize/src/main/java/com/fr/start/fx/FastGifImage.java +++ b/designer-realize/src/main/java/com/fr/start/fx/FastGifImage.java @@ -114,7 +114,7 @@ public class FastGifImage extends WritableImage { private static final class Animation { final WeakReference imageRef; final Timeline timeline; - final ImageLoader loader; + private ImageLoader loader; public Animation(final FastGifImage image, final ImageLoader loader) { this.loader = loader; @@ -141,6 +141,7 @@ public class FastGifImage extends WritableImage { public void stop() { timeline.stop(); + loader = null; } private void updateImage(final int frameIndex) { @@ -197,4 +198,11 @@ public class FastGifImage extends WritableImage { finishImage(new PrismImageLoader2(url, gifCount, (int) getRequestedWidth(), (int) getRequestedHeight(), isPreserveRatio(), isSmooth())); } + /** + * 销毁gif动画 + */ + public void destroy() { + animation.stop(); + } + } diff --git a/designer-realize/src/main/java/com/fr/start/fx/SplashFxWindow.java b/designer-realize/src/main/java/com/fr/start/fx/SplashFxWindow.java index 5b65ac882..e86384669 100644 --- a/designer-realize/src/main/java/com/fr/start/fx/SplashFxWindow.java +++ b/designer-realize/src/main/java/com/fr/start/fx/SplashFxWindow.java @@ -9,7 +9,6 @@ import javafx.application.Application; import javafx.application.Platform; import javafx.geometry.Rectangle2D; import javafx.scene.Scene; -import javafx.scene.image.Image; import javafx.scene.image.ImageView; import javafx.scene.layout.AnchorPane; import javafx.scene.paint.Color; @@ -51,6 +50,7 @@ public class SplashFxWindow extends Application { private Text moduleInfo; private Text thanks; + private FastGifImage image; private List listeners = new ArrayList(); private static int uiScale(int i) { @@ -84,7 +84,7 @@ public class SplashFxWindow extends Application { public void start(Stage primaryStage) { AnchorPane root = new AnchorPane(); primaryStage.initStyle(StageStyle.TRANSPARENT); - Image image = new FastGifImage(SplashContext.SPLASH_PATH, FRAME_COUNT, WINDOW_WIDTH, WINDOW_HEIGHT); + image = new FastGifImage(SplashContext.SPLASH_PATH, FRAME_COUNT, WINDOW_WIDTH, WINDOW_HEIGHT); ImageView gif = new ImageView(image); @@ -129,6 +129,7 @@ public class SplashFxWindow extends Application { public void run() { try { ((Stage) moduleInfo.getScene().getWindow()).close(); + image.destroy(); fireSplashClose(); } catch (Exception e) { FRContext.getLogger().error(e.getMessage(), e); @@ -181,8 +182,10 @@ public class SplashFxWindow extends Application { }); } + /** * 添加一个动画状态监听 + * * @param listener */ public void addSplashActionListener(SplashFxActionListener listener) {