Archived
[ADDED] Persistierung der Checkbox-Auswahl
This commit is contained in:
@@ -6,11 +6,43 @@ import java.util.ArrayList;
|
|||||||
public class Config implements Serializable {
|
public class Config implements Serializable {
|
||||||
private String LSPath;
|
private String LSPath;
|
||||||
private ArrayList<StreamConfigItem> streamItems;
|
private ArrayList<StreamConfigItem> streamItems;
|
||||||
|
|
||||||
|
public int getSortStreamsBy() {
|
||||||
|
return sortStreamsBy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSortStreamsBy(int sortStreamsBy) {
|
||||||
|
this.sortStreamsBy = sortStreamsBy;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int sortStreamsBy;
|
||||||
|
|
||||||
|
public int getLastSelectedStream() {
|
||||||
|
return lastSelectedStream;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLastSelectedStream(int lastSelectedStream) {
|
||||||
|
this.lastSelectedStream = lastSelectedStream;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int lastSelectedStream;
|
||||||
|
public int getLastSelectedQuality() {
|
||||||
|
return lastSelectedQuality;
|
||||||
|
}
|
||||||
|
public void setLastSelectedQuality(int lastSelectedQuality) {
|
||||||
|
this.lastSelectedQuality = lastSelectedQuality;
|
||||||
|
ConfigFileIOHandler.save();
|
||||||
|
}
|
||||||
|
private int lastSelectedQuality;
|
||||||
public Config() {
|
public Config() {
|
||||||
this.streamItems = new ArrayList<StreamConfigItem>();
|
this.streamItems = new ArrayList<StreamConfigItem>();
|
||||||
|
setSortStreamsBy(1);
|
||||||
|
setLastSelectedStream(-1);
|
||||||
|
setLastSelectedQuality(-1);
|
||||||
}
|
}
|
||||||
public void setLSPath(String path) {
|
public void setLSPath(String path) {
|
||||||
this.LSPath = path;
|
this.LSPath = path;
|
||||||
|
ConfigFileIOHandler.save();
|
||||||
}
|
}
|
||||||
public String getLSPath() {
|
public String getLSPath() {
|
||||||
return this.LSPath;
|
return this.LSPath;
|
||||||
@@ -21,9 +53,11 @@ public class Config implements Serializable {
|
|||||||
}
|
}
|
||||||
public void addStream(String streamName) {
|
public void addStream(String streamName) {
|
||||||
this.streamItems.add(new StreamConfigItem(streamName));
|
this.streamItems.add(new StreamConfigItem(streamName));
|
||||||
|
ConfigFileIOHandler.save();
|
||||||
}
|
}
|
||||||
public void removeStream(Object stream) {
|
public void removeStream(Object stream) {
|
||||||
this.streamItems.remove(stream);
|
this.streamItems.remove(stream);
|
||||||
|
ConfigFileIOHandler.save();
|
||||||
}
|
}
|
||||||
public ArrayList<StreamConfigItem> getStreams() {
|
public ArrayList<StreamConfigItem> getStreams() {
|
||||||
return this.streamItems;
|
return this.streamItems;
|
||||||
@@ -33,5 +67,6 @@ public class Config implements Serializable {
|
|||||||
}
|
}
|
||||||
public void replaceStreamList(ArrayList<StreamConfigItem> list) {
|
public void replaceStreamList(ArrayList<StreamConfigItem> list) {
|
||||||
this.streamItems = list;
|
this.streamItems = list;
|
||||||
|
ConfigFileIOHandler.save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,31 @@ import java.util.ArrayList;
|
|||||||
|
|
||||||
public class StreamConfigSorter {
|
public class StreamConfigSorter {
|
||||||
public static ArrayList<StreamConfigItem> sortStreamItemArrayList(ArrayList<StreamConfigItem> list) {
|
public static ArrayList<StreamConfigItem> sortStreamItemArrayList(ArrayList<StreamConfigItem> list) {
|
||||||
|
switch (ConfigFileInstanceHandler.getConfig().getSortStreamsBy()) {
|
||||||
|
case 1: return sortByStatus(list);
|
||||||
|
case 2: return sortByViewerCountAsc(list);
|
||||||
|
case 3: return sortByViewerCountDesc(list);
|
||||||
|
case 4: return sortByNameAsc(list);
|
||||||
|
default: return sortByStatus(list);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ArrayList<StreamConfigItem> sortByViewerCountAsc(ArrayList<StreamConfigItem> list) {
|
||||||
|
// TODO: implement
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ArrayList<StreamConfigItem> sortByViewerCountDesc(ArrayList<StreamConfigItem> list) {
|
||||||
|
// TODO: implement
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ArrayList<StreamConfigItem> sortByNameAsc(ArrayList<StreamConfigItem> list) {
|
||||||
|
// TODO: implement
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ArrayList<StreamConfigItem> sortByStatus(ArrayList<StreamConfigItem> list) {
|
||||||
ArrayList<StreamConfigItem> result = new ArrayList<StreamConfigItem>();
|
ArrayList<StreamConfigItem> result = new ArrayList<StreamConfigItem>();
|
||||||
for (int i = 0; i<list.size(); i++) {
|
for (int i = 0; i<list.size(); i++) {
|
||||||
if (list.get(i).getStatus()) {
|
if (list.get(i).getStatus()) {
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
package com.ixab.GUI;
|
package com.ixab.GUI;
|
||||||
|
|
||||||
|
import com.ixab.Logging.Logger;
|
||||||
|
|
||||||
public class ErrorMessageGate {
|
public class ErrorMessageGate {
|
||||||
public static void setErrorText(String s) {
|
public static void setErrorText(String s) {
|
||||||
|
Logger.print(s);
|
||||||
MainWindow mw = MainWindowGate.getMainWindow();
|
MainWindow mw = MainWindowGate.getMainWindow();
|
||||||
mw.getErrorLabel().setText(s);
|
mw.getErrorLabel().setText(s);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import com.ixab.ConfigHandling.StreamConfigItem;
|
|||||||
import com.ixab.ConfigHandling.StreamConfigSorter;
|
import com.ixab.ConfigHandling.StreamConfigSorter;
|
||||||
import com.ixab.Logging.Logger;
|
import com.ixab.Logging.Logger;
|
||||||
import com.ixab.StreamHandling.StreamOpener;
|
import com.ixab.StreamHandling.StreamOpener;
|
||||||
import javafx.event.EventDispatcher;
|
import com.sun.xml.internal.ws.policy.privateutil.PolicyUtils;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.event.*;
|
import java.awt.event.*;
|
||||||
@@ -63,9 +63,7 @@ public class MainWindow {
|
|||||||
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;
|
|
||||||
refreshStreamsComboBox();
|
refreshStreamsComboBox();
|
||||||
lockStreamInfoGetter = false;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
comboBoxStreams.addActionListener(new ActionListener() {
|
comboBoxStreams.addActionListener(new ActionListener() {
|
||||||
@@ -74,6 +72,7 @@ public class MainWindow {
|
|||||||
if (!lockStreamInfoGetter) {
|
if (!lockStreamInfoGetter) {
|
||||||
updateStreamDetails();
|
updateStreamDetails();
|
||||||
}
|
}
|
||||||
|
ConfigFileInstanceHandler.getConfig().setLastSelectedStream(comboBoxStreams.getSelectedIndex());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
buttonReloadAllStreamData.addActionListener(new ActionListener() {
|
buttonReloadAllStreamData.addActionListener(new ActionListener() {
|
||||||
@@ -115,6 +114,12 @@ public class MainWindow {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
comboBoxQuality.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
ConfigFileInstanceHandler.getConfig().setLastSelectedQuality(comboBoxQuality.getSelectedIndex());
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
private void startUpdaterThread() {
|
private void startUpdaterThread() {
|
||||||
if (updateThread != null) {
|
if (updateThread != null) {
|
||||||
@@ -189,12 +194,11 @@ 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() {
|
||||||
|
lockStreamInfoGetter = true;
|
||||||
Object o = comboBoxStreams.getSelectedItem();
|
Object o = comboBoxStreams.getSelectedItem();
|
||||||
comboBoxStreams.removeAllItems();
|
comboBoxStreams.removeAllItems();
|
||||||
for (StreamConfigItem stream :
|
for (StreamConfigItem stream :
|
||||||
@@ -204,12 +208,30 @@ public class MainWindow {
|
|||||||
if (o != null) {
|
if (o != null) {
|
||||||
comboBoxStreams.setSelectedItem(o);
|
comboBoxStreams.setSelectedItem(o);
|
||||||
} else if (comboBoxStreams.getItemCount()>0) {
|
} else if (comboBoxStreams.getItemCount()>0) {
|
||||||
|
if (ConfigFileInstanceHandler.getConfig().getLastSelectedStream() == -1) {
|
||||||
comboBoxStreams.setSelectedIndex(0);
|
comboBoxStreams.setSelectedIndex(0);
|
||||||
|
} else {
|
||||||
|
comboBoxStreams.setSelectedIndex(ConfigFileInstanceHandler.getConfig().getLastSelectedStream());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (o == null && comboBoxStreams.getItemCount()>0) {
|
||||||
|
comboBoxStreams.setSelectedIndex(ConfigFileInstanceHandler.getConfig().getLastSelectedStream());
|
||||||
|
}
|
||||||
|
lockStreamInfoGetter = false;
|
||||||
|
}
|
||||||
private void refreshQualityComboBox() {
|
private void refreshQualityComboBox() {
|
||||||
|
Object o = comboBoxQuality.getSelectedItem();
|
||||||
comboBoxQuality.removeAllItems();
|
comboBoxQuality.removeAllItems();
|
||||||
comboBoxQuality.addItem("best"); comboBoxQuality.addItem("high"); comboBoxQuality.addItem("medium"); comboBoxQuality.addItem("low"); comboBoxQuality.addItem("mobile");
|
comboBoxQuality.addItem("best"); comboBoxQuality.addItem("high"); comboBoxQuality.addItem("medium"); comboBoxQuality.addItem("low"); comboBoxQuality.addItem("mobile");
|
||||||
|
if (o != null) {
|
||||||
|
comboBoxQuality.setSelectedItem(o);
|
||||||
|
}
|
||||||
|
if (ConfigFileInstanceHandler.getConfig().getLastSelectedQuality() == -1) {
|
||||||
|
ConfigFileInstanceHandler.getConfig().setLastSelectedQuality(comboBoxQuality.getSelectedIndex());
|
||||||
|
} else {
|
||||||
|
comboBoxQuality.setSelectedIndex(ConfigFileInstanceHandler.getConfig().getLastSelectedQuality());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
JFrame frame = new JFrame("jLSLauncher "+ com.ixab.Main.getVersion());
|
JFrame frame = new JFrame("jLSLauncher "+ com.ixab.Main.getVersion());
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ public class StreamOpener extends Thread {
|
|||||||
}
|
}
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
|
Logger.print("Starting stream livestreamer for "+this.streamName+" at "+this.quality+" quality");
|
||||||
Runtime rt = Runtime.getRuntime();
|
Runtime rt = Runtime.getRuntime();
|
||||||
Process pr = rt.exec(this.c.getLSPath()+" twitch.tv/"+this.streamName+" "+this.quality);
|
Process pr = rt.exec(this.c.getLSPath()+" twitch.tv/"+this.streamName+" "+this.quality);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user