Show thumb, if offline_picture is not available

Tweak the insets
This commit is contained in:
0xboobface 2018-10-27 18:50:29 +02:00
parent 07864dc10a
commit 7442ddd3e4
1 changed files with 21 additions and 16 deletions

View File

@ -61,7 +61,7 @@ public class CamsodaShowsTab extends Tab implements TabSelectionListener {
} }
private void createGui() { private void createGui() {
showList = new VBox(10); showList = new VBox();
progressIndicator = new ProgressIndicator(); progressIndicator = new ProgressIndicator();
progressIndicator.setPrefSize(100, 100); progressIndicator.setPrefSize(100, 100);
setContent(progressIndicator); setContent(progressIndicator);
@ -120,7 +120,7 @@ public class CamsodaShowsTab extends Tab implements TabSelectionListener {
showList.getChildren().clear(); showList.getChildren().clear();
for (ShowBox showBox : boxes) { for (ShowBox showBox : boxes) {
showList.getChildren().add(showBox); showList.getChildren().add(showBox);
VBox.setMargin(showBox, new Insets(20)); VBox.setMargin(showBox, new Insets(20, 20, 0, 20));
} }
} catch (Exception e) { } catch (Exception e) {
LOG.error("Couldn't load upcoming camsoda shows", e); LOG.error("Couldn't load upcoming camsoda shows", e);
@ -147,8 +147,10 @@ public class CamsodaShowsTab extends Tab implements TabSelectionListener {
} }
private class ShowBox extends TitledPane { private class ShowBox extends TitledPane {
BorderPane root = new BorderPane(); BorderPane root = new BorderPane();
int thumbSize = 200; int thumbSize = 200;
public ShowBox(Model model, ZonedDateTime startTime, ZonedDateTime endTime) { public ShowBox(Model model, ZonedDateTime startTime, ZonedDateTime endTime) {
setText(model.getName()); setText(model.getName());
setPrefHeight(268); setPrefHeight(268);
@ -203,9 +205,13 @@ public class CamsodaShowsTab extends Tab implements TabSelectionListener {
JSONObject user = json.getJSONObject("user"); JSONObject user = json.getJSONObject("user");
if(user.has("settings")) { if(user.has("settings")) {
JSONObject settings = user.getJSONObject("settings"); JSONObject settings = user.getJSONObject("settings");
String imageUrl;
if(settings.has("offline_picture")) { if(settings.has("offline_picture")) {
imageUrl = settings.getString("offline_picture");
} else {
imageUrl = "https:" + user.getString("thumb");
}
Platform.runLater(() -> { Platform.runLater(() -> {
String imageUrl = settings.getString("offline_picture");
Image img = new Image(imageUrl, 1000, thumbSize, true, true, true); Image img = new Image(imageUrl, 1000, thumbSize, true, true, true);
img.progressProperty().addListener(new ChangeListener<Number>() { img.progressProperty().addListener(new ChangeListener<Number>() {
@Override @Override
@ -221,7 +227,6 @@ public class CamsodaShowsTab extends Tab implements TabSelectionListener {
} }
} }
} }
}
resp.close(); resp.close();
} catch(Exception e) { } catch(Exception e) {
LOG.error("Couldn't load model details", e); LOG.error("Couldn't load model details", e);