diff --git a/src/com/ixab/GUI/SettingsWindow.form b/src/com/ixab/GUI/SettingsWindow.form index 7d5b4e8..fe1767b 100644 --- a/src/com/ixab/GUI/SettingsWindow.form +++ b/src/com/ixab/GUI/SettingsWindow.form @@ -49,7 +49,7 @@ - + @@ -59,7 +59,7 @@ - + @@ -67,7 +67,7 @@ - + @@ -75,7 +75,7 @@ - + @@ -83,7 +83,7 @@ - + @@ -91,28 +91,23 @@ - + - - - - - - + - + - + @@ -122,7 +117,7 @@ - + diff --git a/src/com/ixab/GUI/SettingsWindow.java b/src/com/ixab/GUI/SettingsWindow.java index 1e11e17..9d82cfe 100644 --- a/src/com/ixab/GUI/SettingsWindow.java +++ b/src/com/ixab/GUI/SettingsWindow.java @@ -61,8 +61,29 @@ public class SettingsWindow extends JDialog { buttonImportUserData.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { - UserInfo.initUserFollowData(twitchBenutzernameTextField.getText()); - UserInfo.getFollowedChannelNames(); + final String old = buttonImportUserData.getText(); + buttonImportUserData.setText("bitte warten..."); + Runnable r = new Runnable() { + @Override + public void run() { + if (UserInfo.initUserFollowData(twitchBenutzernameTextField.getText(), 0)) { + UserInfo.getFollowedChannelNames(); + // TODO: prüfe ob channel schon vorhanden sind + for (String name : + UserInfo.getFollowedChannelNames()) { + ConfigFileInstanceHandler.getConfig().addStream(name); + } + ConfigFileIOHandler.save(ConfigFileInstanceHandler.getConfig()); + MainWindowGate.getMainWindow().lockStreamInfoGetter = true; + MainWindowGate.getMainWindow().initStreamsComboBox(); + MainWindowGate.getMainWindow().lockStreamInfoGetter = false; + } + buttonImportUserData.setText(old); + ErrorMessageGate.setErrorText("Streams von "+twitchBenutzernameTextField.getText()+" hinzugefügt."); + } + }; + Thread t = new Thread(r); + t.start(); } }); twitchBenutzernameTextField.addFocusListener(new FocusAdapter() { diff --git a/src/com/ixab/UserInfoHandling/UserInfo.java b/src/com/ixab/UserInfoHandling/UserInfo.java index 0ec5338..ceef3ba 100644 --- a/src/com/ixab/UserInfoHandling/UserInfo.java +++ b/src/com/ixab/UserInfoHandling/UserInfo.java @@ -2,6 +2,7 @@ package com.ixab.UserInfoHandling; import com.ixab.GUI.ErrorMessageGate; import org.json.JSONArray; +import org.json.JSONException; import org.json.JSONObject; import java.io.*; @@ -10,19 +11,30 @@ import java.net.URL; import java.util.ArrayList; public class UserInfo { - private static JSONArray userFollowData; + private static JSONArray userFollowData; // TODO: change this to an arraylist of multiple jsonarrays private static String userFollowCount; private static int getFollowCount() { - return Integer.getInteger(userFollowCount); + return Integer.parseInt(userFollowCount); } public static ArrayList getFollowedChannelNames() { ArrayList names = new ArrayList(); - System.out.println(userFollowData.toString()); // TODO: implement something to work with + for (int i = 0; i100, weil dann mehrere jsonarrays benötigt werden. if (result == "null") { userFollowData = null;