diff --git a/app/src/main/java/io/xpipe/app/core/window/ModifiedStage.java b/app/src/main/java/io/xpipe/app/core/window/ModifiedStage.java index 74a245a0f..2b38da4f7 100644 --- a/app/src/main/java/io/xpipe/app/core/window/ModifiedStage.java +++ b/app/src/main/java/io/xpipe/app/core/window/ModifiedStage.java @@ -33,12 +33,14 @@ public class ModifiedStage extends Stage { private static void hookUpStage(Stage stage) { applyModes(stage); - AppPrefs.get().theme.addListener((observable, oldValue, newValue) -> { - updateStage(stage); - }); - AppPrefs.get().performanceMode().addListener((observable, oldValue, newValue) -> { - updateStage(stage); - }); + if (AppPrefs.get() != null) { + AppPrefs.get().theme.addListener((observable, oldValue, newValue) -> { + updateStage(stage); + }); + AppPrefs.get().performanceMode().addListener((observable, oldValue, newValue) -> { + updateStage(stage); + }); + } } private static void applyModes(Stage stage) { diff --git a/app/src/main/java/io/xpipe/app/fxcomps/impl/PrettyImageComp.java b/app/src/main/java/io/xpipe/app/fxcomps/impl/PrettyImageComp.java index cc741e629..97980fd3b 100644 --- a/app/src/main/java/io/xpipe/app/fxcomps/impl/PrettyImageComp.java +++ b/app/src/main/java/io/xpipe/app/fxcomps/impl/PrettyImageComp.java @@ -93,8 +93,9 @@ public class PrettyImageComp extends SimpleComp { stack.getChildren().add(storeIcon); Consumer update = val -> { + var useDark = AppPrefs.get() != null && AppPrefs.get().theme.get() != null && AppPrefs.get().theme.get().isDark(); var fixed = val != null - ? FileNames.getBaseName(val) + (AppPrefs.get().theme.get().isDark() ? "-dark" : "") + "." + ? FileNames.getBaseName(val) + (useDark ? "-dark" : "") + "." + FileNames.getExtension(val) : null; image.set(fixed); @@ -107,9 +108,11 @@ public class PrettyImageComp extends SimpleComp { }; PlatformThread.sync(value).subscribe(update); - AppPrefs.get().theme.addListener((observable, oldValue, newValue) -> { - update.accept(value.getValue()); - }); + if (AppPrefs.get() != null) { + AppPrefs.get().theme.addListener((observable, oldValue, newValue) -> { + update.accept(value.getValue()); + }); + } stack.setFocusTraversable(false); stack.setPrefWidth(width); diff --git a/app/src/main/java/io/xpipe/app/fxcomps/impl/PrettySvgComp.java b/app/src/main/java/io/xpipe/app/fxcomps/impl/PrettySvgComp.java index 3fb8cf80b..6b4409a74 100644 --- a/app/src/main/java/io/xpipe/app/fxcomps/impl/PrettySvgComp.java +++ b/app/src/main/java/io/xpipe/app/fxcomps/impl/PrettySvgComp.java @@ -88,17 +88,20 @@ public class PrettySvgComp extends SimpleComp { } Consumer update = val -> { + var useDark = AppPrefs.get() != null && AppPrefs.get().theme.get() != null && AppPrefs.get().theme.get().isDark(); var fixed = val != null - ? FileNames.getBaseName(val) + (AppPrefs.get().theme.get().isDark() ? "-dark" : "") + "." + ? FileNames.getBaseName(val) + (useDark ? "-dark" : "") + "." + FileNames.getExtension(val) : null; image.set(fixed); }; syncValue.subscribe(update); - AppPrefs.get().theme.addListener((observable, oldValue, newValue) -> { - update.accept(syncValue.getValue()); - }); + if (AppPrefs.get() != null) { + AppPrefs.get().theme.addListener((observable, oldValue, newValue) -> { + update.accept(syncValue.getValue()); + }); + } stack.setFocusTraversable(false); stack.setPrefWidth(width);