Archived
[MODIFIED] StreamListe wird nun nach Aktualisierung nach online>offline sortiert.
This commit is contained in:
@@ -5,10 +5,8 @@ import java.util.ArrayList;
|
|||||||
|
|
||||||
public class Config implements Serializable {
|
public class Config implements Serializable {
|
||||||
private String LSPath;
|
private String LSPath;
|
||||||
private ArrayList<String> streamNames;
|
|
||||||
private ArrayList<StreamConfigItem> streamItems;
|
private ArrayList<StreamConfigItem> streamItems;
|
||||||
public Config() {
|
public Config() {
|
||||||
this.streamNames = new ArrayList<String>();
|
|
||||||
this.streamItems = new ArrayList<StreamConfigItem>();
|
this.streamItems = new ArrayList<StreamConfigItem>();
|
||||||
}
|
}
|
||||||
public void setLSPath(String path) {
|
public void setLSPath(String path) {
|
||||||
@@ -20,24 +18,20 @@ public class Config implements Serializable {
|
|||||||
|
|
||||||
public String getStreamName(int streamIndex) {
|
public String getStreamName(int streamIndex) {
|
||||||
return this.streamItems.get(streamIndex).getName();
|
return this.streamItems.get(streamIndex).getName();
|
||||||
//return this.streamNames.get(streamIndex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addStream(String streamName) {
|
public void addStream(String streamName) {
|
||||||
this.streamItems.add(new StreamConfigItem(streamName));
|
this.streamItems.add(new StreamConfigItem(streamName));
|
||||||
this.streamNames.add(streamName);
|
|
||||||
}
|
}
|
||||||
public void removeStream(Object stream) {
|
public void removeStream(Object stream) {
|
||||||
this.streamItems.remove(stream);
|
this.streamItems.remove(stream);
|
||||||
this.streamNames.remove(stream);
|
|
||||||
}
|
}
|
||||||
public ArrayList<StreamConfigItem> getStreams() {
|
public ArrayList<StreamConfigItem> getStreams() {
|
||||||
// public ArrayList<StreamConfigItem> getStreams() {
|
|
||||||
return this.streamItems;
|
return this.streamItems;
|
||||||
// return this.streamNames;
|
|
||||||
}
|
}
|
||||||
public int getStreamCount() {
|
public int getStreamCount() {
|
||||||
return this.streamItems.size();
|
return this.streamItems.size();
|
||||||
// return this.streamNames.size();
|
}
|
||||||
|
public void replaceStreamList(ArrayList<StreamConfigItem> list) {
|
||||||
|
this.streamItems = list;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package com.ixab.ConfigHandling;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public class StreamConfigSorter {
|
||||||
|
public static ArrayList<StreamConfigItem> sortStreamItemArrayList(ArrayList<StreamConfigItem> list) {
|
||||||
|
ArrayList<StreamConfigItem> result = new ArrayList<StreamConfigItem>();
|
||||||
|
for (int i = 0; i<list.size(); i++) {
|
||||||
|
if (list.get(i).getStatus()) {
|
||||||
|
result.add(list.get(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int i = 0; i<list.size(); i++) {
|
||||||
|
if (!list.get(i).getStatus()) {
|
||||||
|
result.add(list.get(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -71,7 +71,7 @@
|
|||||||
<text value="Kategorie:"/>
|
<text value="Kategorie:"/>
|
||||||
</properties>
|
</properties>
|
||||||
</component>
|
</component>
|
||||||
<grid id="31cd7" layout-manager="GridLayoutManager" row-count="2" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
<grid id="31cd7" layout-manager="GridLayoutManager" row-count="3" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||||
<margin top="0" left="0" bottom="0" right="0"/>
|
<margin top="0" left="0" bottom="0" right="0"/>
|
||||||
<constraints>
|
<constraints>
|
||||||
<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"/>
|
<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"/>
|
||||||
@@ -90,7 +90,7 @@
|
|||||||
<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">
|
<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"/>
|
<margin top="0" left="0" bottom="0" right="0"/>
|
||||||
<constraints>
|
<constraints>
|
||||||
<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">
|
<grid row="0" column="1" row-span="3" 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"/>
|
<minimum-size width="320" height="180"/>
|
||||||
<preferred-size width="320" height="180"/>
|
<preferred-size width="320" height="180"/>
|
||||||
<maximum-size width="320" height="180"/>
|
<maximum-size width="320" height="180"/>
|
||||||
@@ -109,9 +109,17 @@
|
|||||||
</hspacer>
|
</hspacer>
|
||||||
<vspacer id="edf84">
|
<vspacer id="edf84">
|
||||||
<constraints>
|
<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"/>
|
<grid row="1" column="0" row-span="2" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
</vspacer>
|
</vspacer>
|
||||||
|
<component id="8b335" class="javax.swing.JButton" binding="buttonReloadStreamData">
|
||||||
|
<constraints>
|
||||||
|
<grid row="2" 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="Stream Daten neu laden"/>
|
||||||
|
</properties>
|
||||||
|
</component>
|
||||||
</children>
|
</children>
|
||||||
</grid>
|
</grid>
|
||||||
<component id="7fec7" class="javax.swing.JTextField" binding="textFieldStreamTitle">
|
<component id="7fec7" class="javax.swing.JTextField" binding="textFieldStreamTitle">
|
||||||
@@ -204,12 +212,12 @@
|
|||||||
<properties/>
|
<properties/>
|
||||||
<border type="none"/>
|
<border type="none"/>
|
||||||
<children>
|
<children>
|
||||||
<component id="48958" class="javax.swing.JButton" binding="buttonReloadStreamData" default-binding="true">
|
<component id="48958" class="javax.swing.JButton" binding="buttonReloadAllStreamData">
|
||||||
<constraints>
|
<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"/>
|
<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>
|
</constraints>
|
||||||
<properties>
|
<properties>
|
||||||
<text value="Stream Infos neu laden"/>
|
<text value="Alle Stream Daten neu laden"/>
|
||||||
</properties>
|
</properties>
|
||||||
</component>
|
</component>
|
||||||
<component id="be49e" class="javax.swing.JButton" binding="buttonPlayStream" default-binding="true">
|
<component id="be49e" class="javax.swing.JButton" binding="buttonPlayStream" default-binding="true">
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package com.ixab.GUI;
|
|||||||
import com.ixab.ConfigHandling.ConfigFileIOHandler;
|
import com.ixab.ConfigHandling.ConfigFileIOHandler;
|
||||||
import com.ixab.ConfigHandling.ConfigFileInstanceHandler;
|
import com.ixab.ConfigHandling.ConfigFileInstanceHandler;
|
||||||
import com.ixab.ConfigHandling.StreamConfigItem;
|
import com.ixab.ConfigHandling.StreamConfigItem;
|
||||||
import com.ixab.StreamHandling.StreamInfo;
|
import com.ixab.ConfigHandling.StreamConfigSorter;
|
||||||
import com.ixab.StreamHandling.StreamOpener;
|
import com.ixab.StreamHandling.StreamOpener;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
@@ -20,7 +20,7 @@ public class MainWindow {
|
|||||||
private JTextField textFieldStreamViewers;
|
private JTextField textFieldStreamViewers;
|
||||||
private JTextField textFieldStreamTitle;
|
private JTextField textFieldStreamTitle;
|
||||||
private JTextField textFieldStreamGame;
|
private JTextField textFieldStreamGame;
|
||||||
private JButton buttonReloadStreamData;
|
private JButton buttonReloadAllStreamData;
|
||||||
private JPanel panelPreviewImage;
|
private JPanel panelPreviewImage;
|
||||||
private JButton buttonSettings;
|
private JButton buttonSettings;
|
||||||
private Thread updateThread;
|
private Thread updateThread;
|
||||||
@@ -30,38 +30,12 @@ public class MainWindow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private JLabel errorLabel;
|
private JLabel errorLabel;
|
||||||
|
private JButton buttonReloadStreamData;
|
||||||
protected boolean lockStreamInfoGetter = false;
|
protected boolean lockStreamInfoGetter = false;
|
||||||
|
|
||||||
public MainWindow() {
|
public MainWindow() {
|
||||||
|
|
||||||
//TODO: Updater thread
|
this.startUpdaterThread();
|
||||||
Runnable r = new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
for (final StreamConfigItem sci :
|
|
||||||
ConfigFileInstanceHandler.getConfig().getStreams()) {
|
|
||||||
Runnable r2 = new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
sci.refreshInfo();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Thread t2 = new Thread(r2);
|
|
||||||
t2.start();
|
|
||||||
}
|
|
||||||
makeAPause(60000);
|
|
||||||
}
|
|
||||||
private void makeAPause(long time) {
|
|
||||||
try {
|
|
||||||
System.out.println("schläft "+time/1000.0+" sek");
|
|
||||||
Thread.sleep(time);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Thread t = new Thread(r);
|
|
||||||
t.start();
|
|
||||||
|
|
||||||
|
|
||||||
MainWindowGate.setMainWindow(this);
|
MainWindowGate.setMainWindow(this);
|
||||||
@@ -98,10 +72,10 @@ public class MainWindow {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
buttonReloadStreamData.addActionListener(new ActionListener() {
|
buttonReloadAllStreamData.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
updateStreamDetails();
|
startUpdaterThread();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
buttonSettings.addActionListener(new ActionListener() {
|
buttonSettings.addActionListener(new ActionListener() {
|
||||||
@@ -111,6 +85,47 @@ public class MainWindow {
|
|||||||
sw.create();
|
sw.create();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
buttonReloadStreamData.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
updateStreamDetails();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
private void startUpdaterThread() {
|
||||||
|
Runnable r = new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
for (final StreamConfigItem sci :
|
||||||
|
ConfigFileInstanceHandler.getConfig().getStreams()) {
|
||||||
|
Runnable r2 = new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
sci.refreshInfo();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
Thread t2 = new Thread(r2);
|
||||||
|
t2.start();
|
||||||
|
}
|
||||||
|
makeAPause(60000);
|
||||||
|
|
||||||
|
ConfigFileInstanceHandler.getConfig().replaceStreamList(
|
||||||
|
StreamConfigSorter.sortStreamItemArrayList(
|
||||||
|
ConfigFileInstanceHandler.getConfig().getStreams()
|
||||||
|
));
|
||||||
|
refreshComboBoxes();
|
||||||
|
}
|
||||||
|
private void makeAPause(long time) {
|
||||||
|
try {
|
||||||
|
System.out.println("schläft "+time/1000.0+" sek");
|
||||||
|
Thread.sleep(time);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
Thread t = new Thread(r);
|
||||||
|
t.start();
|
||||||
}
|
}
|
||||||
private void updateStreamDetails() {
|
private void updateStreamDetails() {
|
||||||
if (updateThread != null) {
|
if (updateThread != null) {
|
||||||
@@ -142,15 +157,19 @@ public class MainWindow {
|
|||||||
as.create();
|
as.create();
|
||||||
}
|
}
|
||||||
private void refreshComboBoxes() {
|
private void refreshComboBoxes() {
|
||||||
|
lockStreamInfoGetter = true;
|
||||||
refreshQualityComboBox();
|
refreshQualityComboBox();
|
||||||
refreshStreamsComboBox();
|
refreshStreamsComboBox();
|
||||||
|
lockStreamInfoGetter = false;
|
||||||
}
|
}
|
||||||
protected void refreshStreamsComboBox() {
|
protected void refreshStreamsComboBox() {
|
||||||
|
Object o = comboBoxStreams.getSelectedItem();
|
||||||
comboBoxStreams.removeAllItems();
|
comboBoxStreams.removeAllItems();
|
||||||
for (StreamConfigItem stream :
|
for (StreamConfigItem stream :
|
||||||
ConfigFileInstanceHandler.getConfig().getStreams()) {
|
ConfigFileInstanceHandler.getConfig().getStreams()) {
|
||||||
comboBoxStreams.addItem(stream);
|
comboBoxStreams.addItem(stream);
|
||||||
}
|
}
|
||||||
|
comboBoxStreams.setSelectedItem(o);
|
||||||
}
|
}
|
||||||
private void refreshQualityComboBox() {
|
private void refreshQualityComboBox() {
|
||||||
comboBoxQuality.removeAllItems();
|
comboBoxQuality.removeAllItems();
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ public class UserInfo {
|
|||||||
try {
|
try {
|
||||||
JSONObject followed = new JSONObject(userFollowData.get(i).toString());
|
JSONObject followed = new JSONObject(userFollowData.get(i).toString());
|
||||||
JSONObject channel = new JSONObject(followed.get("channel").toString());
|
JSONObject channel = new JSONObject(followed.get("channel").toString());
|
||||||
System.out.println(i+" "+channel.get("display_name").toString()); //remove this line if not needed anymore
|
System.out.println(i+" "+channel.get("name").toString()); //remove this line if not needed anymore
|
||||||
names.add(channel.get("display_name").toString());
|
names.add(channel.get("name").toString());
|
||||||
// TODO: bisher nur maximal 100 importieren wegen twitch api.
|
// TODO: bisher nur maximal 100 importieren wegen twitch api.
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
// workaround for stupid limit of jsonarrays of twitch's api.
|
// workaround for stupid limit of jsonarrays of twitch's api.
|
||||||
|
|||||||
Reference in New Issue
Block a user