mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-11-04 21:36:45 +00:00
prevent potential npe on qr display dialog
This commit is contained in:
parent
c2eb505bd9
commit
94c5920c27
1 changed files with 14 additions and 6 deletions
|
@ -78,12 +78,7 @@ public class QRDisplayDialog extends Dialog<UR> {
|
||||||
if(encoder.isSinglePart()) {
|
if(encoder.isSinglePart()) {
|
||||||
qrImageView.setImage(getQrCode(currentPart));
|
qrImageView.setImage(getQrCode(currentPart));
|
||||||
} else {
|
} else {
|
||||||
animateQRService = new AnimateQRService();
|
createAnimateQRService();
|
||||||
animateQRService.setPeriod(Duration.millis(ANIMATION_PERIOD_MILLIS));
|
|
||||||
animateQRService.start();
|
|
||||||
setOnCloseRequest(event -> {
|
|
||||||
animateQRService.cancel();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final ButtonType cancelButtonType = new javafx.scene.control.ButtonType("Cancel", ButtonBar.ButtonData.CANCEL_CLOSE);
|
final ButtonType cancelButtonType = new javafx.scene.control.ButtonType("Cancel", ButtonBar.ButtonData.CANCEL_CLOSE);
|
||||||
|
@ -124,6 +119,15 @@ public class QRDisplayDialog extends Dialog<UR> {
|
||||||
setResultConverter(dialogButton -> dialogButton != cancelButtonType ? ur : null);
|
setResultConverter(dialogButton -> dialogButton != cancelButtonType ? ur : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void createAnimateQRService() {
|
||||||
|
animateQRService = new AnimateQRService();
|
||||||
|
animateQRService.setPeriod(Duration.millis(ANIMATION_PERIOD_MILLIS));
|
||||||
|
animateQRService.start();
|
||||||
|
setOnCloseRequest(event -> {
|
||||||
|
animateQRService.cancel();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private void nextPart() {
|
private void nextPart() {
|
||||||
if(!useLegacyEncoding) {
|
if(!useLegacyEncoding) {
|
||||||
String fragment = encoder.nextPart();
|
String fragment = encoder.nextPart();
|
||||||
|
@ -169,6 +173,8 @@ public class QRDisplayDialog extends Dialog<UR> {
|
||||||
|
|
||||||
nextPart();
|
nextPart();
|
||||||
qrImageView.setImage(getQrCode(currentPart));
|
qrImageView.setImage(getQrCode(currentPart));
|
||||||
|
} else if(animateQRService == null) {
|
||||||
|
createAnimateQRService();
|
||||||
} else if(!animateQRService.isRunning()) {
|
} else if(!animateQRService.isRunning()) {
|
||||||
animateQRService.reset();
|
animateQRService.reset();
|
||||||
animateQRService.start();
|
animateQRService.start();
|
||||||
|
@ -185,6 +191,8 @@ public class QRDisplayDialog extends Dialog<UR> {
|
||||||
}
|
}
|
||||||
|
|
||||||
qrImageView.setImage(getQrCode(currentPart));
|
qrImageView.setImage(getQrCode(currentPart));
|
||||||
|
} else if(animateQRService == null) {
|
||||||
|
createAnimateQRService();
|
||||||
} else if(!animateQRService.isRunning()) {
|
} else if(!animateQRService.isRunning()) {
|
||||||
animateQRService.reset();
|
animateQRService.reset();
|
||||||
animateQRService.start();
|
animateQRService.start();
|
||||||
|
|
Loading…
Reference in a new issue