This commit is contained in:
da
2015-11-07 00:56:35 +01:00
parent a9739f57f8
commit 7ed9d8689c
5 changed files with 81 additions and 57 deletions
Binary file not shown.
+3
View File
@@ -0,0 +1,3 @@
Manifest-Version: 1.0
Main-Class: com.ixab.Main
+11 -3
View File
@@ -38,7 +38,7 @@
<grid row="3" column="4" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/> <grid row="3" 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> </constraints>
</hspacer> </hspacer>
<component id="35b31" class="javax.swing.JComboBox" binding="comboBox2" default-binding="true"> <component id="35b31" class="javax.swing.JComboBox" binding="comboBoxQuality">
<constraints> <constraints>
<grid row="0" column="7" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/> <grid row="0" column="7" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
</constraints> </constraints>
@@ -128,7 +128,7 @@
</component> </component>
<component id="2a9d4" class="javax.swing.JLabel" binding="labelStreamTitle"> <component id="2a9d4" class="javax.swing.JLabel" binding="labelStreamTitle">
<constraints> <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"/> <grid row="1" column="1" row-span="1" col-span="7" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints> </constraints>
<properties> <properties>
<text value=""/> <text value=""/>
@@ -144,12 +144,20 @@
</component> </component>
<component id="dcbec" class="javax.swing.JLabel" binding="labelStreamGame"> <component id="dcbec" class="javax.swing.JLabel" binding="labelStreamGame">
<constraints> <constraints>
<grid row="2" 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="2" column="1" row-span="1" col-span="7" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints> </constraints>
<properties> <properties>
<text value=""/> <text value=""/>
</properties> </properties>
</component> </component>
<component id="48958" class="javax.swing.JButton" binding="neuLadenButton" default-binding="true">
<constraints>
<grid row="3" column="5" 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="Neu laden"/>
</properties>
</component>
</children> </children>
</grid> </grid>
</form> </form>
+27 -14
View File
@@ -6,15 +6,12 @@ import com.ixab.StreamHandling.StreamInfo;
import com.ixab.StreamHandling.StreamOpener; import com.ixab.StreamHandling.StreamOpener;
import javax.swing.*; import javax.swing.*;
import java.awt.event.ActionEvent; import java.awt.event.*;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
public class StreamChooserMenu { public class StreamChooserMenu {
private JPanel panel; private JPanel panel;
private JComboBox comboBoxStreams; private JComboBox comboBoxStreams;
private JComboBox comboBox2; private JComboBox comboBoxQuality;
private JTextField textField1; private JTextField textField1;
private JButton hinzufügenButton; private JButton hinzufügenButton;
private JButton streamAbspielenButton; private JButton streamAbspielenButton;
@@ -23,13 +20,15 @@ public class StreamChooserMenu {
private JLabel labelStreamViewers; private JLabel labelStreamViewers;
private JLabel labelStreamTitle; private JLabel labelStreamTitle;
private JLabel labelStreamGame; private JLabel labelStreamGame;
private JButton neuLadenButton;
private boolean lockStreamInfoGetter = false;
public StreamChooserMenu() { public StreamChooserMenu() {
this.initComboBoxes(); this.initComboBoxes();
streamAbspielenButton.addActionListener(new ActionListener() { streamAbspielenButton.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
StreamOpener so = new StreamOpener(ConfigFileInstanceHandler.getConfig(), ConfigFileInstanceHandler.getConfig().getStreams().indexOf(comboBoxStreams.getSelectedItem()), comboBox2.getSelectedItem().toString()); StreamOpener so = new StreamOpener(ConfigFileInstanceHandler.getConfig(), ConfigFileInstanceHandler.getConfig().getStreams().indexOf(comboBoxStreams.getSelectedItem()), comboBoxQuality.getSelectedItem().toString());
so.start(); so.start();
} }
}); });
@@ -44,18 +43,17 @@ public class StreamChooserMenu {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
ConfigFileInstanceHandler.getConfig().removeStream(comboBoxStreams.getSelectedItem()); ConfigFileInstanceHandler.getConfig().removeStream(comboBoxStreams.getSelectedItem());
ConfigFileIOHandler.save(ConfigFileInstanceHandler.getConfig()); ConfigFileIOHandler.save(ConfigFileInstanceHandler.getConfig());
lockStreamInfoGetter = true;
initStreamsComboBox(); initStreamsComboBox();
lockStreamInfoGetter = false;
} }
}); });
comboBoxStreams.addActionListener(new ActionListener() { comboBoxStreams.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
// TODO: implement twitch api and update stream info if (!lockStreamInfoGetter) {
StreamInfo.getStreamInfo(comboBoxStreams.getSelectedItem().toString()); updateStreamDetails();
labelStreamStatus.setText(StreamInfo.getStatus()); }
labelStreamGame.setText(StreamInfo.getGame());
labelStreamViewers.setText(StreamInfo.getViewers());
labelStreamTitle.setText(StreamInfo.getTitle());
} }
}); });
textField1.addKeyListener(new KeyAdapter() { textField1.addKeyListener(new KeyAdapter() {
@@ -67,11 +65,26 @@ public class StreamChooserMenu {
} }
} }
}); });
neuLadenButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
updateStreamDetails();
}
});
}
private void updateStreamDetails() {
StreamInfo.getStreamInfo(comboBoxStreams.getSelectedItem().toString());
labelStreamStatus.setText(StreamInfo.getStatus());
labelStreamGame.setText(StreamInfo.getGame());
labelStreamViewers.setText(StreamInfo.getViewers());
labelStreamTitle.setText(StreamInfo.getTitle());
} }
private void addNewStream() { private void addNewStream() {
ConfigFileInstanceHandler.getConfig().addStream(textField1.getText()); ConfigFileInstanceHandler.getConfig().addStream(textField1.getText());
ConfigFileIOHandler.save(ConfigFileInstanceHandler.getConfig()); ConfigFileIOHandler.save(ConfigFileInstanceHandler.getConfig());
lockStreamInfoGetter = true;
initStreamsComboBox(); initStreamsComboBox();
lockStreamInfoGetter = false;
textField1.setText(""); textField1.setText("");
} }
private void initComboBoxes() { private void initComboBoxes() {
@@ -86,8 +99,8 @@ public class StreamChooserMenu {
} }
} }
private void initQualityComboBox() { private void initQualityComboBox() {
comboBox2.removeAllItems(); comboBoxQuality.removeAllItems();
comboBox2.addItem("best"); comboBox2.addItem("high"); comboBox2.addItem("medium"); comboBox2.addItem("low"); comboBox2.addItem("mobile"); comboBoxQuality.addItem("best"); comboBoxQuality.addItem("high"); comboBoxQuality.addItem("medium"); comboBoxQuality.addItem("low"); comboBoxQuality.addItem("mobile");
} }
public static void main(String[] args) { public static void main(String[] args) {
JFrame frame = new JFrame("jLSLauncher v"+ com.ixab.Main.getVersion()); JFrame frame = new JFrame("jLSLauncher v"+ com.ixab.Main.getVersion());
+3 -3
View File
@@ -43,6 +43,7 @@ public class StreamInfo {
} }
} }
public static void getStreamInfo(String streamName) { public static void getStreamInfo(String streamName) {
if (streamName != null) {
InputStream is = null; InputStream is = null;
URL url = null; URL url = null;
JSONObject object = null; JSONObject object = null;
@@ -69,8 +70,7 @@ public class StreamInfo {
try { try {
String line; String line;
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
while ((line = br.readLine()) != null) while ((line = br.readLine()) != null) {
{
sb.append(line); sb.append(line);
} }
object = new JSONObject(sb.toString()); object = new JSONObject(sb.toString());
@@ -88,6 +88,6 @@ public class StreamInfo {
streamData = new JSONObject(result); streamData = new JSONObject(result);
streamPreviewData = new JSONObject(streamData.get("preview").toString()); streamPreviewData = new JSONObject(streamData.get("preview").toString());
} }
}
} }
} }