Browse Source

CORE-91 设计启动动画不释放

master
vito 6 years ago
parent
commit
9688650371
  1. 10
      designer-realize/src/main/java/com/fr/start/fx/FastGifImage.java
  2. 7
      designer-realize/src/main/java/com/fr/start/fx/SplashFxWindow.java

10
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<FastGifImage> 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();
}
}

7
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<SplashFxActionListener> listeners = new ArrayList<SplashFxActionListener>();
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) {

Loading…
Cancel
Save