Archived
[ADDED/MODIFIED] Mehr Stream Daten. Threading.
This commit is contained in:
@@ -2,6 +2,7 @@ package com.ixab.GUI;
|
||||
|
||||
public class ErrorMessageGate {
|
||||
public static void setErrorText(String s) {
|
||||
// TODO: na was wohl?
|
||||
MainWindow mw = MainWindowGate.getMainWindow();
|
||||
mw.getErrorLabel().setText(s);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
<grid id="27dc6" binding="panel" layout-manager="GridLayoutManager" row-count="4" column-count="5" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<xy x="20" y="20" width="650" height="400"/>
|
||||
<xy x="20" y="20" width="650" height="500"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<minimumSize width="650" height="200"/>
|
||||
<preferredSize width="650" height="200"/>
|
||||
<minimumSize width="650" height="400"/>
|
||||
<preferredSize width="650" height="400"/>
|
||||
</properties>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
@@ -39,7 +39,7 @@
|
||||
<text value="Qualität:"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="7c5a1" class="javax.swing.JButton" binding="entfernenButton" default-binding="true">
|
||||
<component id="7c5a1" class="javax.swing.JButton" binding="buttonRemoveStream" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
@@ -47,7 +47,7 @@
|
||||
<text value="Ausgw. Stream entfernen"/>
|
||||
</properties>
|
||||
</component>
|
||||
<grid id="7567d" layout-manager="GridLayoutManager" row-count="4" column-count="4" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<grid id="7567d" layout-manager="GridLayoutManager" row-count="4" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="5" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
@@ -71,52 +71,97 @@
|
||||
<text value="Kategorie:"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="2a9d4" class="javax.swing.JLabel" binding="labelStreamTitle">
|
||||
<grid id="31cd7" layout-manager="GridLayoutManager" row-count="2" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
<grid row="3" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value=""/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="dcbec" class="javax.swing.JLabel" binding="labelStreamGame">
|
||||
<constraints>
|
||||
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value=""/>
|
||||
</properties>
|
||||
</component>
|
||||
<hspacer id="7a444">
|
||||
<constraints>
|
||||
<grid row="1" column="3" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</hspacer>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="658e2" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Vorschau:"/>
|
||||
</properties>
|
||||
</component>
|
||||
<grid id="8ebda" binding="previewImagePanel" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<grid id="8ebda" binding="panelPreviewImage" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="3" column="1" row-span="1" col-span="3" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
<grid row="0" column="1" row-span="2" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
|
||||
<minimum-size width="320" height="180"/>
|
||||
<preferred-size width="320" height="180"/>
|
||||
<maximum-size width="320" height="180"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<properties>
|
||||
<background color="-1"/>
|
||||
</properties>
|
||||
<border type="none"/>
|
||||
<children/>
|
||||
</grid>
|
||||
<grid id="136f3" layout-manager="GridLayoutManager" row-count="1" column-count="5" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<hspacer id="8b583">
|
||||
<constraints>
|
||||
<grid row="0" column="2" row-span="2" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</hspacer>
|
||||
<vspacer id="edf84">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
</children>
|
||||
</grid>
|
||||
<component id="7fec7" class="javax.swing.JTextField" binding="textFieldStreamTitle">
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="150" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties>
|
||||
<editable value="false"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="544c8" class="javax.swing.JTextField" binding="textFieldStreamGame">
|
||||
<constraints>
|
||||
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="150" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties>
|
||||
<editable value="false"/>
|
||||
</properties>
|
||||
</component>
|
||||
<grid id="75d86" layout-manager="GridLayoutManager" row-count="1" column-count="5" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="4" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
<grid row="2" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="bbe9d" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Status:"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="7f132" class="javax.swing.JTextField" binding="textFieldStreamStatus">
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<minimum-size width="50" height="-1"/>
|
||||
<preferred-size width="50" height="-1"/>
|
||||
<maximum-size width="50" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties>
|
||||
<editable value="false"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="c34b7" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
@@ -125,37 +170,23 @@
|
||||
<text value="Zuschauer:"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="65a1f" class="javax.swing.JLabel" binding="labelStreamViewers">
|
||||
<component id="97d89" class="javax.swing.JTextField" binding="textFieldStreamViewers">
|
||||
<constraints>
|
||||
<grid row="0" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
<grid row="0" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<minimum-size width="70" height="-1"/>
|
||||
<preferred-size width="70" height="-1"/>
|
||||
<maximum-size width="70" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value=""/>
|
||||
<editable value="false"/>
|
||||
</properties>
|
||||
</component>
|
||||
<hspacer id="b1486">
|
||||
<hspacer id="903e4">
|
||||
<constraints>
|
||||
<grid row="0" column="4" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</hspacer>
|
||||
<component id="e40fa" class="javax.swing.JLabel" binding="labelStreamStatus">
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value=""/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="bbe9d" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="39" height="14"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Status:"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
@@ -173,7 +204,7 @@
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="48958" class="javax.swing.JButton" binding="neuLadenButton" default-binding="true">
|
||||
<component id="48958" class="javax.swing.JButton" binding="buttonReloadStreamData" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
@@ -181,7 +212,7 @@
|
||||
<text value="Stream Infos neu laden"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="be49e" class="javax.swing.JButton" binding="streamAbspielenButton" default-binding="true">
|
||||
<component id="be49e" class="javax.swing.JButton" binding="buttonPlayStream" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
@@ -189,7 +220,7 @@
|
||||
<text value="Stream abspielen"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="95ee2" class="javax.swing.JButton" binding="einstellungenButton" default-binding="true">
|
||||
<component id="95ee2" class="javax.swing.JButton" binding="buttonSettings" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
@@ -197,7 +228,7 @@
|
||||
<text value="Einstellungen"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="a3649" class="javax.swing.JButton" binding="hinzufügenButton" default-binding="true">
|
||||
<component id="a3649" class="javax.swing.JButton" binding="buttonAddStream" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
|
||||
@@ -12,17 +12,17 @@ public class MainWindow {
|
||||
private JPanel panel;
|
||||
private JComboBox comboBoxStreams;
|
||||
private JComboBox comboBoxQuality;
|
||||
private JTextField textField1;
|
||||
private JButton hinzufügenButton;
|
||||
private JButton streamAbspielenButton;
|
||||
private JButton entfernenButton;
|
||||
private JLabel labelStreamStatus;
|
||||
private JLabel labelStreamViewers;
|
||||
private JLabel labelStreamTitle;
|
||||
private JLabel labelStreamGame;
|
||||
private JButton neuLadenButton;
|
||||
private JPanel previewImagePanel;
|
||||
private JButton einstellungenButton;
|
||||
private JButton buttonAddStream;
|
||||
private JButton buttonPlayStream;
|
||||
private JButton buttonRemoveStream;
|
||||
private JTextField textFieldStreamStatus;
|
||||
private JTextField textFieldStreamViewers;
|
||||
private JTextField textFieldStreamTitle;
|
||||
private JTextField textFieldStreamGame;
|
||||
private JButton buttonReloadStreamData;
|
||||
private JPanel panelPreviewImage;
|
||||
private JButton buttonSettings;
|
||||
private Thread updateThread;
|
||||
|
||||
protected JLabel getErrorLabel() {
|
||||
return errorLabel;
|
||||
@@ -34,20 +34,20 @@ public class MainWindow {
|
||||
public MainWindow() {
|
||||
MainWindowGate.setMainWindow(this);
|
||||
this.initComboBoxes();
|
||||
streamAbspielenButton.addActionListener(new ActionListener() {
|
||||
buttonPlayStream.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
StreamOpener so = new StreamOpener(ConfigFileInstanceHandler.getConfig(), ConfigFileInstanceHandler.getConfig().getStreams().indexOf(comboBoxStreams.getSelectedItem()), comboBoxQuality.getSelectedItem().toString());
|
||||
so.start();
|
||||
}
|
||||
});
|
||||
hinzufügenButton.addActionListener(new ActionListener() {
|
||||
buttonAddStream.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
addNewStream();
|
||||
}
|
||||
});
|
||||
entfernenButton.addActionListener(new ActionListener() {
|
||||
buttonRemoveStream.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
ConfigFileInstanceHandler.getConfig().removeStream(comboBoxStreams.getSelectedItem());
|
||||
@@ -65,13 +65,13 @@ public class MainWindow {
|
||||
}
|
||||
}
|
||||
});
|
||||
neuLadenButton.addActionListener(new ActionListener() {
|
||||
buttonReloadStreamData.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
updateStreamDetails();
|
||||
}
|
||||
});
|
||||
einstellungenButton.addActionListener(new ActionListener() {
|
||||
buttonSettings.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
SettingsWindow sw = new SettingsWindow();
|
||||
@@ -80,11 +80,26 @@ public class MainWindow {
|
||||
});
|
||||
}
|
||||
private void updateStreamDetails() {
|
||||
if (updateThread != null) {
|
||||
if (updateThread.isAlive()) {
|
||||
updateThread.interrupt();
|
||||
}
|
||||
}
|
||||
Runnable r = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
StreamInfo.initStreamData(comboBoxStreams.getSelectedItem().toString());
|
||||
labelStreamStatus.setText(StreamInfo.getStatus());
|
||||
labelStreamGame.setText(StreamInfo.getGame());
|
||||
labelStreamViewers.setText(StreamInfo.getViewers());
|
||||
labelStreamTitle.setText(StreamInfo.getTitle());
|
||||
textFieldStreamStatus.setText(StreamInfo.getStatus());
|
||||
textFieldStreamGame.setText(StreamInfo.getGame());
|
||||
textFieldStreamViewers.setText(StreamInfo.getViewers());
|
||||
textFieldStreamTitle.setText(StreamInfo.getTitle());
|
||||
panelPreviewImage.getGraphics().drawImage(StreamInfo.getPreviewImage(),0,0,null);
|
||||
}
|
||||
};
|
||||
Thread t = new Thread(r);
|
||||
this.updateThread = t;
|
||||
t.start();
|
||||
ErrorMessageGate.setErrorText("Lade Stream-Daten von " + comboBoxStreams.getSelectedItem().toString() + "...");
|
||||
}
|
||||
private void addNewStream() {
|
||||
AddStreamDialog as = new AddStreamDialog();
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="e3588" layout-manager="GridLayoutManager" row-count="3" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<grid id="e3588" layout-manager="GridLayoutManager" row-count="4" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
@@ -102,6 +102,32 @@
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</hspacer>
|
||||
<component id="c3f1e" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Benutzer Import:"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="3e70" class="javax.swing.JTextField" binding="twitchBenutzernameTextField" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="150" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Twitch-Benutzername"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="9749e" class="javax.swing.JButton" binding="buttonImportUserData">
|
||||
<constraints>
|
||||
<grid row="3" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Importieren"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.ixab.GUI;
|
||||
|
||||
import com.ixab.ConfigHandling.ConfigFileIOHandler;
|
||||
import com.ixab.ConfigHandling.ConfigFileInstanceHandler;
|
||||
import com.ixab.UserInfoHandling.UserInfo;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.*;
|
||||
@@ -12,6 +14,8 @@ public class SettingsWindow extends JDialog {
|
||||
private JCheckBox debugmodusCheckBox;
|
||||
private JTextField textField1;
|
||||
private JButton suchenButton;
|
||||
private JTextField twitchBenutzernameTextField;
|
||||
private JButton buttonImportUserData;
|
||||
|
||||
public SettingsWindow() {
|
||||
textField1.setText(ConfigFileInstanceHandler.getConfig().getLSPath());
|
||||
@@ -54,10 +58,25 @@ public class SettingsWindow extends JDialog {
|
||||
if (jfc.getSelectedFile() != null) textField1.setText(jfc.getSelectedFile().getAbsolutePath());
|
||||
}
|
||||
});
|
||||
buttonImportUserData.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent actionEvent) {
|
||||
UserInfo.initUserFollowData(twitchBenutzernameTextField.getText());
|
||||
UserInfo.getFollowedChannelNames();
|
||||
}
|
||||
});
|
||||
twitchBenutzernameTextField.addFocusListener(new FocusAdapter() {
|
||||
@Override
|
||||
public void focusGained(FocusEvent e) {
|
||||
super.focusGained(e);
|
||||
twitchBenutzernameTextField.setText("");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void onOK() {
|
||||
// add your code here
|
||||
ConfigFileInstanceHandler.getConfig().setLSPath(textField1.getText());
|
||||
ConfigFileIOHandler.save(ConfigFileInstanceHandler.getConfig());
|
||||
dispose();
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import com.ixab.GUI.MainWindow;
|
||||
import javax.swing.*;
|
||||
|
||||
public class Main {
|
||||
private final static String version = "0.3 Alpha";
|
||||
private final static String version = "0.4 Alpha";
|
||||
private static Config c = null;
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
@@ -28,8 +28,6 @@ public class Main {
|
||||
catch (IllegalAccessException e) {
|
||||
// handle exception
|
||||
}
|
||||
|
||||
//ConfigLoadMenu.create(null);
|
||||
c = ConfigFileIOHandler.load();
|
||||
if (c == null) {
|
||||
initNewConfig();
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
package com.ixab.StreamHandling;
|
||||
|
||||
import com.ixab.GUI.ErrorMessageGate;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@@ -14,7 +17,7 @@ public class StreamInfo {
|
||||
private static JSONObject streamPreviewData = null;
|
||||
public static String getGame() {
|
||||
if (streamData == null && streamPreviewData == null) {
|
||||
return "0";
|
||||
return "-";
|
||||
} else {
|
||||
JSONObject channelData = new JSONObject(streamData.get("channel").toString());
|
||||
return channelData.get("game").toString();
|
||||
@@ -22,7 +25,7 @@ public class StreamInfo {
|
||||
}
|
||||
public static String getTitle() {
|
||||
if (streamData == null && streamPreviewData == null) {
|
||||
return "0";
|
||||
return "-";
|
||||
} else {
|
||||
JSONObject channelData = new JSONObject(streamData.get("channel").toString());
|
||||
return channelData.get("status").toString();
|
||||
@@ -42,7 +45,27 @@ public class StreamInfo {
|
||||
return "online";
|
||||
}
|
||||
}
|
||||
public static void initStreamData(String streamName) {
|
||||
public static BufferedImage getPreviewImage() {
|
||||
if (streamPreviewData == null) {
|
||||
BufferedImage c = new BufferedImage(1,1,0);
|
||||
return c;
|
||||
} else {
|
||||
URL url = null;
|
||||
BufferedImage c = null;
|
||||
try {
|
||||
url = new URL(streamPreviewData.get("medium").toString());
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
c = ImageIO.read(url);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return c;
|
||||
}
|
||||
}
|
||||
public static boolean initStreamData(String streamName) {
|
||||
if (streamName != null) {
|
||||
InputStream is = null;
|
||||
URL url = null;
|
||||
@@ -62,7 +85,9 @@ public class StreamInfo {
|
||||
try {
|
||||
is = url.openStream();
|
||||
} catch (IOException e) {
|
||||
ErrorMessageGate.setErrorText("Fehler bei Verbindungsaufbau zu Twitch.");
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
InputStreamReader isr = new InputStreamReader(is);
|
||||
BufferedReader br = new BufferedReader(isr);
|
||||
@@ -89,5 +114,6 @@ public class StreamInfo {
|
||||
streamPreviewData = new JSONObject(streamData.get("preview").toString());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
package com.ixab.UserInfoHandling;
|
||||
|
||||
import com.ixab.GUI.ErrorMessageGate;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class UserInfo {
|
||||
private static JSONArray userFollowData;
|
||||
private static String userFollowCount;
|
||||
|
||||
private static int getFollowCount() {
|
||||
return Integer.getInteger(userFollowCount);
|
||||
}
|
||||
public static ArrayList<String> getFollowedChannelNames() {
|
||||
ArrayList<String> names = new ArrayList<String>();
|
||||
System.out.println(userFollowData.toString()); // TODO: implement something to work with
|
||||
return names;
|
||||
}
|
||||
|
||||
public static boolean initUserFollowData(String userName) {
|
||||
if (userName != null) {
|
||||
InputStream is = null;
|
||||
URL url = null;
|
||||
JSONObject object = null;
|
||||
StringBuilder urlBuilder = new StringBuilder();
|
||||
urlBuilder.append("https://api.twitch.tv/kraken/users/");
|
||||
|
||||
urlBuilder.append(userName);
|
||||
|
||||
urlBuilder.append("/follows/channels");
|
||||
|
||||
String URLString = urlBuilder.toString();
|
||||
|
||||
try {
|
||||
url = new URL(URLString);
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
is = url.openStream();
|
||||
} catch (FileNotFoundException e) {
|
||||
ErrorMessageGate.setErrorText("Benutzer "+userName+" existiert nicht.");
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
} catch (IOException e) {
|
||||
ErrorMessageGate.setErrorText("Fehler bei Verbindungsaufbau zu Twitch.");
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
InputStreamReader isr = new InputStreamReader(is);
|
||||
BufferedReader br = new BufferedReader(isr);
|
||||
|
||||
try {
|
||||
String line;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
while ((line = br.readLine()) != null) {
|
||||
sb.append(line);
|
||||
}
|
||||
object = new JSONObject(sb.toString());
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
String result = object.get("_total").toString();
|
||||
|
||||
if (result == "null") {
|
||||
userFollowData = null;
|
||||
userFollowCount = null;
|
||||
} else {
|
||||
userFollowData = new JSONArray(object.getJSONArray("follows").toString());
|
||||
userFollowCount = result;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user