Ich wollte fragen, ob jemand jemals auch ein Problem mit dem Gluon Charm Down Plugin für die Bildschirmausrichtung für IOS hatte.Null Zeiger beim Lesen der Bildschirmausrichtung von Gluon Charm Down
JFXMobile Plugin: org.javafxports:jfxmobile-plugin:1.3.2
Charm Version: com.gluonhq:charm:4.2.0
downConfig {
version = '3.1.0'
plugins 'display', 'lifecycle', 'statusbar', 'storage', 'orientation'
}
Wenn ich versuche, es zu nennen, wie folgt aus:
Services.get(OrientationService.class).ifPresent(service -> {
onOrientationChange(service.orientationProperty(), null, service.getOrientation().orElse(Orientation.VERTICAL));
service.orientationProperty().addListener(this::onOrientationChange);
});
ich eine Ausnahme auf der Konsole:
Exception in Preloader start method
2017-02-06 10:43:37.104693 MyApp[447:282589] Orientation is Unknown
QuantumRenderer: shutdown
java.lang.RuntimeException: Exception in Preloader start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$156(LauncherImpl.java)
at com.sun.javafx.application.LauncherImpl$$Lambda$2.run(Unknown Source)
at java.lang.Thread.run(Thread.java)
Caused by: java.lang.NullPointerException
at com.gluonhq.charm.down.plugins.ios.IOSOrientationService.getOrientation(IOSOrientationService.java)
at my.app.Preloader.lambda$start$24(Preloader.java)
at my.app.Preloader$$Lambda$3.accept(Unknown Source)
at java.util.Optional.ifPresent(Optional.java)
at my.app.Preloader.start(Preloader.java)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$161(LauncherImpl.java)
at com.sun.javafx.application.LauncherImpl$$Lambda$7.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$176(PlatformImpl.java)
at com.sun.javafx.application.PlatformImpl$$Lambda$7.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl.lambda$null$174(PlatformImpl.java)
at com.sun.javafx.application.PlatformImpl$$Lambda$19.run(Unknown Source)
at java.security.AccessController.doPrivileged(AccessController.java)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$175(PlatformImpl.java)
at com.sun.javafx.application.PlatformImpl$$Lambda$6.run(Unknown Source)
at org.robovm.apple.uikit.UIApplication.main(UIApplication.java)
at org.robovm.apple.uikit.UIApplication.main(UIApplication.java)
at org.javafxports.jfxmobile.ios.BasicLauncher.main(BasicLauncher.java)
Mit Blick auf die code, nehme ich es nur einen Grund für das Problem sein könnte:
@Override
public final Optional<Orientation> getOrientation() {
switch (orientationText) {
case "Portrait":
case "PortraitUpsideDown":
return Optional.of(Orientation.VERTICAL);
case "LandscapeLeft":
case "LandscapeRight":
return Optional.of(Orientation.HORIZONTAL);
case "Unknown":
default:
return Optional.empty();
}
}
Meine Vermutung ist, dass orientationText
null
ist und deshalb stürzt.
Die Linie 2017-02-06 10:43:37.104693 MyApp[447:282589] Orientation is Unknown
trägt dazu bei, denke ich.
Ist das ein Fehler? Gibt es einen Weg, dies zu umgehen? (ZB gibt es einige Set-up auf IOS benötigt, wie das Berechtigungssystem auf Android?)
Vielen Dank im Voraus und Grüße,
Daniel
#edit: Die onOrientationChange
Methode ist nicht sehr kompliziert:
private void onOrientationChange(ObservableValue<? extends Orientation> obs, Orientation o, Orientation n) {
if (n == null || splashPane == null)
return;
splashPane.pseudoClassStateChanged(vertical, Orientation.VERTICAL == n);
splashPane.pseudoClassStateChanged(horizontal, Orientation.HORIZONTAL == n);
}
Also ich denke es wäre ausreichend den Code auf etw zu aktualisieren. wie diese
Services.get(OrientationService.class).ifPresent(service -> {
service.orientationProperty() addListener (dies :: onOrientationChange). });
(es ist auf Android arbeiten, so dass ich könnte alternativ die Plattform überprüfen und tun es nur auf nicht-IOS oder so)
Angesichts der Tatsache, dass das Protokoll eine nicht Null Ausrichtung gibt, glaube ich nicht, dass "orientationText" null ist. Können Sie Ihren Event-Handler modifizieren? Verwenden Sie nicht OnOrientationChange für jetzt. Drucken Sie einfach den orientierten neuen Wert aus: 'service.orientationProperty(). AddListener ((obs, ov, nv) -> System.out.println (" O: "+ nv));' und sehen Sie, ob es fehlschlägt. –
Ich habe meine Frage (siehe unten) mit dem Inhalt des 'onOrientationChange' aktualisiert - aber ja, ich kann es versuchen. Gibt dir das Ergebnis nach dem Mittagessen, ok? – dzim