|
22 | 22 | import com.google.gson.JsonElement;
|
23 | 23 | import com.sun.jna.Platform;
|
24 | 24 | import javafx.scene.Node;
|
25 |
| -import javafx.scene.control.Alert; |
26 |
| -import javafx.scene.control.Button; |
27 |
| -import javafx.scene.control.ButtonBar; |
28 |
| -import javafx.scene.control.ButtonType; |
29 |
| -import javafx.scene.control.CheckBox; |
30 |
| -import javafx.scene.control.TextField; |
31 |
| -import javafx.scene.control.TextFormatter; |
| 25 | +import javafx.scene.control.*; |
32 | 26 | import javafx.scene.effect.DropShadow;
|
33 | 27 | import javafx.scene.input.Clipboard;
|
34 | 28 | import javafx.scene.input.ClipboardContent;
|
|
51 | 45 | import java.nio.file.StandardCopyOption;
|
52 | 46 | import java.nio.file.StandardOpenOption;
|
53 | 47 | import java.util.List;
|
| 48 | +import java.util.NoSuchElementException; |
54 | 49 | import java.util.Objects;
|
55 | 50 | import java.util.concurrent.ExecutorService;
|
56 | 51 | import java.util.concurrent.Executors;
|
@@ -269,6 +264,16 @@ static ButtonType showUnreportableError(String msg, ButtonType... buttons) {
|
269 | 264 | return alert.getResult();
|
270 | 265 | }
|
271 | 266 |
|
| 267 | + static ButtonType showUnreportableError(String msg, String toShow, ButtonType... buttons) { |
| 268 | + Alert alert = new Alert(Alert.AlertType.ERROR, msg, buttons); |
| 269 | + resizeAlertButtons(alert); |
| 270 | + var text = new TextArea(toShow); |
| 271 | + text.setEditable(false); |
| 272 | + alert.getDialogPane().setExpandableContent(text); |
| 273 | + alert.showAndWait(); |
| 274 | + return alert.getResult(); |
| 275 | + } |
| 276 | + |
272 | 277 | static void showInfoAlert(String msg, ButtonType... buttons) {
|
273 | 278 | Alert alert = new Alert(Alert.AlertType.INFORMATION, msg, buttons);
|
274 | 279 | alert.showAndWait();
|
@@ -374,10 +379,16 @@ static Stream<IOSVersion> getBetaList(String deviceIdentifier) throws IOExceptio
|
374 | 379 |
|
375 | 380 | static Stream<IOSVersion> getBetaHubList(String deviceIdentifier, boolean betas) throws IOException {
|
376 | 381 | String url = "https://www.betahub.cn/api/apple/firmwares/" + deviceIdentifier + "?type=" + (betas ? 2 : 1);
|
377 |
| - JsonArray firmwares = Network.makeJsonRequest(url).getAsJsonObject().getAsJsonArray("firmwares"); |
378 |
| - return StreamSupport.stream(firmwares.spliterator(), false) |
379 |
| - .map(JsonElement::getAsJsonObject) |
380 |
| - .map(o -> new IOSVersion(o.get("version").getAsString(), o.get("build_id").getAsString(), o.get("url").getAsString(), o.get("signing").getAsInt() == 1)); |
| 382 | + |
| 383 | + JsonElement response = Network.makeJsonRequest(url); |
| 384 | + try { |
| 385 | + var firmwares = response.getAsJsonObject().getAsJsonArray("firmwares"); |
| 386 | + return StreamSupport.stream(firmwares.spliterator(), false) |
| 387 | + .map(JsonElement::getAsJsonObject) |
| 388 | + .map(o -> new IOSVersion(o.get("version").getAsString(), o.get("build_id").getAsString(), o.get("url").getAsString(), o.get("signing").getAsInt() == 1)); |
| 389 | + } catch (NullPointerException e) { |
| 390 | + throw new NoSuchElementException("Unable to extract iOS Versions from JSON:\n" + response, e); |
| 391 | + } |
381 | 392 | }
|
382 | 393 |
|
383 | 394 | private static Stream<IOSVersion> createVersionStream(JsonArray array) {
|
|
0 commit comments