Archived
bugfix
This commit is contained in:
@@ -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"/>
|
||||
</constraints>
|
||||
</hspacer>
|
||||
<component id="35b31" class="javax.swing.JComboBox" binding="comboBox2" default-binding="true">
|
||||
<component id="35b31" class="javax.swing.JComboBox" binding="comboBoxQuality">
|
||||
<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"/>
|
||||
</constraints>
|
||||
@@ -128,7 +128,7 @@
|
||||
</component>
|
||||
<component id="2a9d4" class="javax.swing.JLabel" binding="labelStreamTitle">
|
||||
<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>
|
||||
<properties>
|
||||
<text value=""/>
|
||||
@@ -144,12 +144,20 @@
|
||||
</component>
|
||||
<component id="dcbec" class="javax.swing.JLabel" binding="labelStreamGame">
|
||||
<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>
|
||||
<properties>
|
||||
<text value=""/>
|
||||
</properties>
|
||||
</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>
|
||||
</grid>
|
||||
</form>
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -43,51 +43,51 @@ public class StreamInfo {
|
||||
}
|
||||
}
|
||||
public static void getStreamInfo(String streamName) {
|
||||
InputStream is = null;
|
||||
URL url = null;
|
||||
JSONObject object = null;
|
||||
StringBuilder urlBuilder = new StringBuilder();
|
||||
urlBuilder.append("https://api.twitch.tv/kraken/streams/");
|
||||
if (streamName != null) {
|
||||
InputStream is = null;
|
||||
URL url = null;
|
||||
JSONObject object = null;
|
||||
StringBuilder urlBuilder = new StringBuilder();
|
||||
urlBuilder.append("https://api.twitch.tv/kraken/streams/");
|
||||
|
||||
urlBuilder.append(streamName);
|
||||
urlBuilder.append(streamName);
|
||||
|
||||
String URLString = urlBuilder.toString();
|
||||
String URLString = urlBuilder.toString();
|
||||
|
||||
try {
|
||||
url = new URL(URLString);
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
is = url.openStream();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
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);
|
||||
try {
|
||||
url = new URL(URLString);
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
object = new JSONObject(sb.toString());
|
||||
try {
|
||||
is = url.openStream();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
InputStreamReader isr = new InputStreamReader(is);
|
||||
BufferedReader br = new BufferedReader(isr);
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
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("stream").toString();
|
||||
|
||||
if (result == "null") {
|
||||
streamData = null;
|
||||
streamPreviewData = null;
|
||||
} else {
|
||||
streamData = new JSONObject(result);
|
||||
streamPreviewData = new JSONObject(streamData.get("preview").toString());
|
||||
}
|
||||
}
|
||||
|
||||
String result = object.get("stream").toString();
|
||||
|
||||
if (result == "null") {
|
||||
streamData = null;
|
||||
streamPreviewData = null;
|
||||
} else {
|
||||
streamData = new JSONObject(result);
|
||||
streamPreviewData = new JSONObject(streamData.get("preview").toString());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user