Skip to content

Commit

Permalink
display subscriber emotes on detail pane
Browse files Browse the repository at this point in the history
  • Loading branch information
s1mpl3x committed Apr 25, 2016
1 parent faac43d commit eaf1ee7
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 32 deletions.
16 changes: 7 additions & 9 deletions src/main/java/eu/over9000/skadi/remote/PanelDataRetriever.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,19 @@

package eu.over9000.skadi.remote;

import java.io.IOException;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;

import eu.over9000.skadi.model.Panel;
import eu.over9000.skadi.util.HttpUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;

public class PanelDataRetriever {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,18 @@

package eu.over9000.skadi.service;

import java.text.NumberFormat;

import eu.over9000.skadi.model.Channel;
import eu.over9000.skadi.remote.EmoteDataRetriever;
import eu.over9000.skadi.remote.PanelDataRetriever;
import eu.over9000.skadi.ui.ChannelDetailPaneContent;
import eu.over9000.skadi.util.*;
import javafx.beans.binding.Bindings;
import javafx.concurrent.Service;
import javafx.concurrent.Task;
import javafx.scene.chart.LineChart;
import javafx.scene.control.Tooltip;

import eu.over9000.skadi.model.Channel;
import eu.over9000.skadi.remote.PanelDataRetriever;
import eu.over9000.skadi.ui.ChannelDetailPaneContent;
import eu.over9000.skadi.util.DesktopUtil;
import eu.over9000.skadi.util.ImageUtil;
import eu.over9000.skadi.util.PanelUtil;
import eu.over9000.skadi.util.StringUtil;
import java.text.NumberFormat;

public class DetailPaneUpdateService extends Service<Void> {

Expand Down Expand Up @@ -70,7 +67,7 @@ protected Void call() throws Exception {

content.getLbViews().textProperty().bind(Bindings.createStringBinding(() -> "total views: " + formatter.format(channel.getViews()), channel.viewsProperty()));

content.getLbPartner().textProperty().bind(Bindings.createStringBinding(() -> "partner: " + channel.getPartner(), channel.partnerProperty()));
content.getLbPartner().textProperty().bind(Bindings.createStringBinding(() -> "partner: " + (channel.getPartner() ? "yes" : "no"), channel.partnerProperty()));

content.getIvPreview().imageProperty().bind(Bindings.createObjectBinding(channel::getPreview, channel.previewProperty()));

Expand All @@ -82,8 +79,13 @@ protected Void call() throws Exception {
content.getLbLogo().graphicProperty().bind(Bindings.createObjectBinding(() -> ImageUtil.getChannelLogo(channel.getLogoURL()), channel.logoURLProperty()));

content.getPanelPane().getChildren().clear();
content.getEmotePane().getChildren().clear();

PanelDataRetriever.retrievePanels(channel.getName()).forEach(panel -> content.getPanelPane().getChildren().add(PanelUtil.buildPanel(panel)));

EmoteUtil.buildEmotePanel(EmoteDataRetriever.retrieveEmotes(channel.getName())).forEach(box -> content.getEmotePane().getChildren().add(box));


return null;
}
};
Expand Down
37 changes: 24 additions & 13 deletions src/main/java/eu/over9000/skadi/ui/ChannelDetailPaneContent.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,14 @@

package eu.over9000.skadi.ui;

import de.jensd.fx.glyphs.GlyphsDude;
import de.jensd.fx.glyphs.fontawesome.FontAwesomeIcon;
import eu.over9000.skadi.ui.label.CopyableLabel;
import eu.over9000.skadi.util.TimeUtil;
import javafx.beans.binding.DoubleBinding;
import javafx.beans.property.ReadOnlyDoubleProperty;
import javafx.geometry.Insets;
import javafx.geometry.Orientation;
import javafx.scene.chart.LineChart;
import javafx.scene.chart.NumberAxis;
import javafx.scene.control.Button;
Expand All @@ -34,15 +39,11 @@
import javafx.scene.image.ImageView;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.FlowPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.scene.text.Font;
import javafx.util.StringConverter;

import de.jensd.fx.glyphs.GlyphsDude;
import de.jensd.fx.glyphs.fontawesome.FontAwesomeIcon;
import eu.over9000.skadi.ui.label.CopyableLabel;
import eu.over9000.skadi.util.TimeUtil;

public class ChannelDetailPaneContent extends ScrollPane {

private final DoubleBinding widthBinding;
Expand All @@ -60,6 +61,7 @@ public class ChannelDetailPaneContent extends ScrollPane {
private final CopyableLabel lbPartner;
private final FlowPane panelPane;
private final Button btOpenInBrowser;
private final FlowPane emotePane;

public ChannelDetailPaneContent(final ReadOnlyDoubleProperty widthPanel, final ReadOnlyDoubleProperty widthButton) {
widthBinding = widthPanel.subtract(widthButton).subtract(25);
Expand All @@ -75,6 +77,7 @@ public ChannelDetailPaneContent(final ReadOnlyDoubleProperty widthPanel, final R

final BorderPane bp_top = new BorderPane();
final BorderPane bp_img = new BorderPane();
final BorderPane bp_info = new BorderPane();

lbLogo = new Label();

Expand Down Expand Up @@ -108,15 +111,25 @@ public Number fromString(final String string) {
viewerChart.setPrefHeight(180);
viewerChart.setCreateSymbols(false);


lbAvg = new CopyableLabel();
lbCurr = new CopyableLabel();

lbFollowers = new CopyableLabel();
lbViews = new CopyableLabel();
lbPartner = new CopyableLabel();


btOpenInBrowser = GlyphsDude.createIconButton(FontAwesomeIcon.EXTERNAL_LINK, "Open in Browser");

emotePane = new FlowPane(5, 5);

final HBox boxInfo1 = new HBox(10, new VBox(10, lbCurr, lbAvg, lbFollowers, lbViews, lbPartner, btOpenInBrowser), new Separator(Orientation.VERTICAL));
final VBox boxInfo2 = new VBox(10, new Label("Subscriber Emotes:"), emotePane);

bp_info.setLeft(boxInfo1);
bp_info.setCenter(boxInfo2);

lbGame = new Label();

upperVBox.getChildren().add(lbName);
Expand All @@ -129,19 +142,13 @@ public Number fromString(final String string) {
bp_img.setLeft(ivPreview);
bp_img.setCenter(viewerChart);

final Separator bp_img_sep = new Separator();
panelPane = new FlowPane(10, 10);

detailPane.getChildren().add(bp_top);
detailPane.getChildren().add(new Separator());
detailPane.getChildren().add(bp_img);
detailPane.getChildren().add(bp_img_sep);
detailPane.getChildren().add(lbCurr);
detailPane.getChildren().add(lbAvg);
detailPane.getChildren().add(lbFollowers);
detailPane.getChildren().add(lbViews);
detailPane.getChildren().add(lbPartner);
detailPane.getChildren().add(btOpenInBrowser);
detailPane.getChildren().add(new Separator());
detailPane.getChildren().add(bp_info);
detailPane.getChildren().add(new Separator());
detailPane.getChildren().add(panelPane);

Expand Down Expand Up @@ -204,6 +211,10 @@ public FlowPane getPanelPane() {
return panelPane;
}

public FlowPane getEmotePane() {
return emotePane;
}

public Button getBtOpenInBrowser() {
return btOpenInBrowser;
}
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/eu/over9000/skadi/ui/label/CopyableLabel.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,11 @@ public CopyableLabel() {
getStyleClass().add("copyable-label");
setPadding(new Insets(0, 0, 0, 5));
}

public CopyableLabel(final String txt) {
super(txt);
setEditable(false);
getStyleClass().add("copyable-label");
setPadding(new Insets(0, 0, 0, 5));
}
}
1 change: 1 addition & 0 deletions src/main/java/eu/over9000/skadi/util/PanelUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public class PanelUtil {

private static final Logger LOGGER = LoggerFactory.getLogger(PanelUtil.class);


public static VBox buildPanel(final Panel panel) {
final VBox box = new VBox();
box.setMaxWidth(200);
Expand Down

0 comments on commit eaf1ee7

Please sign in to comment.