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
+27 -14
View File
@@ -6,15 +6,12 @@ import com.ixab.StreamHandling.StreamInfo;
import com.ixab.StreamHandling.StreamOpener;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.*;
public class StreamChooserMenu {
private JPanel panel;
private JComboBox comboBoxStreams;
private JComboBox comboBox2;
private JComboBox comboBoxQuality;
private JTextField textField1;
private JButton hinzufügenButton;
private JButton streamAbspielenButton;
@@ -23,13 +20,15 @@ public class StreamChooserMenu {
private JLabel labelStreamViewers;
private JLabel labelStreamTitle;
private JLabel labelStreamGame;
private JButton neuLadenButton;
private boolean lockStreamInfoGetter = false;
public StreamChooserMenu() {
this.initComboBoxes();
streamAbspielenButton.addActionListener(new ActionListener() {
@Override
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();
}
});
@@ -44,18 +43,17 @@ public class StreamChooserMenu {
public void actionPerformed(ActionEvent e) {
ConfigFileInstanceHandler.getConfig().removeStream(comboBoxStreams.getSelectedItem());
ConfigFileIOHandler.save(ConfigFileInstanceHandler.getConfig());
lockStreamInfoGetter = true;
initStreamsComboBox();
lockStreamInfoGetter = false;
}
});
comboBoxStreams.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO: implement twitch api and update stream info
StreamInfo.getStreamInfo(comboBoxStreams.getSelectedItem().toString());
labelStreamStatus.setText(StreamInfo.getStatus());
labelStreamGame.setText(StreamInfo.getGame());
labelStreamViewers.setText(StreamInfo.getViewers());
labelStreamTitle.setText(StreamInfo.getTitle());
if (!lockStreamInfoGetter) {
updateStreamDetails();
}
}
});
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() {
ConfigFileInstanceHandler.getConfig().addStream(textField1.getText());
ConfigFileIOHandler.save(ConfigFileInstanceHandler.getConfig());
lockStreamInfoGetter = true;
initStreamsComboBox();
lockStreamInfoGetter = false;
textField1.setText("");
}
private void initComboBoxes() {
@@ -86,8 +99,8 @@ public class StreamChooserMenu {
}
}
private void initQualityComboBox() {
comboBox2.removeAllItems();
comboBox2.addItem("best"); comboBox2.addItem("high"); comboBox2.addItem("medium"); comboBox2.addItem("low"); comboBox2.addItem("mobile");
comboBoxQuality.removeAllItems();
comboBoxQuality.addItem("best"); comboBoxQuality.addItem("high"); comboBoxQuality.addItem("medium"); comboBoxQuality.addItem("low"); comboBoxQuality.addItem("mobile");
}
public static void main(String[] args) {
JFrame frame = new JFrame("jLSLauncher v"+ com.ixab.Main.getVersion());