diff --git a/src/main/java/de/p2tools/p2radio/P2RadioController.java b/src/main/java/de/p2tools/p2radio/P2RadioController.java index 8ac5adf..ce13c2e 100644 --- a/src/main/java/de/p2tools/p2radio/P2RadioController.java +++ b/src/main/java/de/p2tools/p2radio/P2RadioController.java @@ -168,12 +168,12 @@ private void initButton() { // ProgInfoDialog if (ProgData.debug) { - final MenuItem miDebug = new MenuItem("Debugtools"); + final MenuItem miDebug = new MenuItem("Debug: Debugtools"); miDebug.setOnAction(event -> { MTPTester mtpTester = new MTPTester(progData); mtpTester.showDialog(); }); - final MenuItem miSave = new MenuItem("alles Speichern"); + final MenuItem miSave = new MenuItem("Debug: Alles Speichern"); miSave.setOnAction(a -> ProgSaveFactory.saveAll()); mHelp.getItems().addAll(new SeparatorMenuItem(), miDebug, miSave); diff --git a/src/main/java/de/p2tools/p2radio/controller/LoadXmlFactory.java b/src/main/java/de/p2tools/p2radio/controller/LoadXmlFactory.java deleted file mode 100644 index 3649d65..0000000 --- a/src/main/java/de/p2tools/p2radio/controller/LoadXmlFactory.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * P2tools Copyright (C) 2018 W. Xaver W.Xaver[at]googlemail.com - * https://www.p2tools.de/ - * - * This program is free software: you can redistribute it and/or modify it under the terms of the - * GNU General Public License as published by the Free Software Foundation, either version 3 of the - * License, or any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without - * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with this program. If - * not, see . - */ - -package de.p2tools.p2radio.controller; - -import de.p2tools.p2Lib.configFile.ConfigFile; -import de.p2tools.p2Lib.configFile.ReadConfigFile; -import de.p2tools.p2Lib.tools.duration.PDuration; -import de.p2tools.p2radio.controller.config.ProgConst; -import de.p2tools.p2radio.controller.config.ProgData; -import de.p2tools.p2radio.controller.config.ProgInfos; - -import java.nio.file.Path; - -public class LoadXmlFactory { - - private LoadXmlFactory() { - } - - public static boolean loadStationList() { - boolean ret; - //XML laden ~650ms - PDuration.counterStart("LoadStationXML"); - final Path pathXml = ProgInfos.getStationFileXml(); - ConfigFile configFile = new ConfigFile(ProgConst.XML_START, pathXml); - configFile.addConfigs(ProgData.getInstance().stationList); - - ReadConfigFile readConfigFile = new ReadConfigFile(); - readConfigFile.addConfigFile(configFile); - ret = readConfigFile.readConfigFile(false); - PDuration.counterStop("LoadStationXML"); - - return ret; - } -} - - diff --git a/src/main/java/de/p2tools/p2radio/controller/ProgLoadFactory.java b/src/main/java/de/p2tools/p2radio/controller/ProgLoadFactory.java index 5181d87..7398495 100644 --- a/src/main/java/de/p2tools/p2radio/controller/ProgLoadFactory.java +++ b/src/main/java/de/p2tools/p2radio/controller/ProgLoadFactory.java @@ -78,7 +78,7 @@ public static void loadStationProgStart(boolean firstProgramStart) { } else { // gespeicherte Senderliste laden, gibt keine Fortschrittsanzeige und kein Abbrechen logList.add("Programmstart, gespeicherte Senderliste laden"); - boolean loadOk = LoadJsonFactory.readList(); + boolean loadOk = SenderLoadFactory.readList(); if (!loadOk || progData.stationList.isTooOld() && ProgConfig.SYSTEM_LOAD_STATION_LIST_EVERY_DAYS.get()) { //wenn die gespeicherte zu alt ist diff --git a/src/main/java/de/p2tools/p2radio/controller/ProgSaveFactory.java b/src/main/java/de/p2tools/p2radio/controller/ProgSaveFactory.java index 4708b99..d99bc22 100644 --- a/src/main/java/de/p2tools/p2radio/controller/ProgSaveFactory.java +++ b/src/main/java/de/p2tools/p2radio/controller/ProgSaveFactory.java @@ -16,23 +16,13 @@ package de.p2tools.p2radio.controller; -import com.fasterxml.jackson.core.JsonEncoding; -import com.fasterxml.jackson.core.JsonFactory; -import com.fasterxml.jackson.core.JsonGenerator; import de.p2tools.p2Lib.configFile.ConfigFile; import de.p2tools.p2Lib.configFile.WriteConfigFile; -import de.p2tools.p2Lib.configFile.config.Config; -import de.p2tools.p2Lib.tools.duration.PDuration; import de.p2tools.p2Lib.tools.log.PLog; import de.p2tools.p2radio.controller.config.ProgConfig; import de.p2tools.p2radio.controller.config.ProgConst; -import de.p2tools.p2radio.controller.config.ProgData; import de.p2tools.p2radio.controller.config.ProgInfos; -import de.p2tools.p2radio.controller.data.station.Station; -import de.p2tools.p2radio.controller.data.station.StationList; -import de.p2tools.p2radio.controller.getNewStationList.radioBrowser.StationFieldNamesWeb; -import java.io.FileOutputStream; import java.nio.file.Path; public class ProgSaveFactory { @@ -43,7 +33,7 @@ private ProgSaveFactory() { public static void saveAll() { PLog.sysLog("save all data"); saveProgConfig(); - saveStationListXml(); + SenderSaveFactory.saveStationListJson(); } public static void saveProgConfig() { @@ -59,61 +49,5 @@ public static void saveProgConfig() { writeConfigFile.writeConfigFile(); } - public static void saveStationListXml() { - //ist die Senderliste - PLog.sysLog("save stationlist"); - final Path path = ProgInfos.getStationFileXml(); - ConfigFile configFile = new ConfigFile(ProgConst.XML_START, path); - configFile.addConfigs(ProgData.getInstance().stationList); - - WriteConfigFile writeConfigFile = new WriteConfigFile(); - writeConfigFile.addConfigFile(configFile); - writeConfigFile.writeConfigFile(false); - } - - public static void saveStationListJson() { - PDuration.counterStart("ProgSaveFactory.saveStationListJson"); - Path file = ProgInfos.getStationFileJson(); - StationList stationList = ProgData.getInstance().stationList; - - try { - try (FileOutputStream fos = new FileOutputStream(file.toFile()); - JsonGenerator jsonGenerator = - new JsonFactory().createGenerator(fos, JsonEncoding.UTF8).useDefaultPrettyPrinter()) { - - jsonGenerator.writeStartArray(); - jsonGenerator.writeStartObject(); - for (Config meta : stationList.getMeta().getConfigsArr()) { - jsonGenerator.writeStringField(meta.getKey(), meta.getActValueString()); - } - jsonGenerator.writeEndObject(); - - for (Station station : stationList) { - jsonGenerator.writeStartObject(); - jsonGenerator.writeStringField(StationFieldNamesWeb.NAME, station.arr[Station.STATION_NAME]); - jsonGenerator.writeStringField(StationFieldNamesWeb.GENRE, station.arr[Station.STATION_GENRE]); - jsonGenerator.writeStringField(StationFieldNamesWeb.CODEC, station.arr[Station.STATION_CODEC]); - jsonGenerator.writeStringField(StationFieldNamesWeb.BITRATE, station.arr[Station.STATION_BITRATE]); - jsonGenerator.writeStringField(StationFieldNamesWeb.COUNTRY, station.arr[Station.STATION_COUNTRY]); - jsonGenerator.writeStringField(StationFieldNamesWeb.COUNTRY_CODE, station.arr[Station.STATION_COUNTRY_CODE]); - jsonGenerator.writeStringField(StationFieldNamesWeb.STATE, station.arr[Station.STATION_STATE]); - jsonGenerator.writeStringField(StationFieldNamesWeb.LANGUAGE, station.arr[Station.STATION_LANGUAGE]); - jsonGenerator.writeStringField(StationFieldNamesWeb.VOTES, station.arr[Station.STATION_VOTES]); - jsonGenerator.writeStringField(StationFieldNamesWeb.CLICK_COUNT, station.arr[Station.STATION_CLICK_COUNT]); - jsonGenerator.writeStringField(StationFieldNamesWeb.CLICK_TREND, station.arr[Station.STATION_CLICK_TREND]); - jsonGenerator.writeStringField(StationFieldNamesWeb.URL, station.arr[Station.STATION_URL]); - jsonGenerator.writeStringField(StationFieldNamesWeb.URL_RESOLVED, station.arr[Station.STATION_URL_RESOLVED]); - jsonGenerator.writeStringField(StationFieldNamesWeb.HOMEPAGE, station.arr[Station.STATION_WEBSITE]); - jsonGenerator.writeStringField(StationFieldNamesWeb.LAST_CHANGE_TIME, station.arr[Station.STATION_DATE]); - jsonGenerator.writeEndObject(); - } - - jsonGenerator.writeEndArray(); - } - } catch (Exception ex) { - PLog.errorLog(846930145, ex, "nach: " + file); - } - PDuration.counterStop("ProgSaveFactory.saveStationListJson"); - } } diff --git a/src/main/java/de/p2tools/p2radio/controller/LoadJsonFactory.java b/src/main/java/de/p2tools/p2radio/controller/SenderLoadFactory.java similarity index 89% rename from src/main/java/de/p2tools/p2radio/controller/LoadJsonFactory.java rename to src/main/java/de/p2tools/p2radio/controller/SenderLoadFactory.java index 892d173..6368d17 100644 --- a/src/main/java/de/p2tools/p2radio/controller/LoadJsonFactory.java +++ b/src/main/java/de/p2tools/p2radio/controller/SenderLoadFactory.java @@ -28,7 +28,6 @@ import de.p2tools.p2radio.controller.config.ProgInfos; import de.p2tools.p2radio.controller.data.station.Station; import de.p2tools.p2radio.controller.data.station.StationList; -import de.p2tools.p2radio.controller.getNewStationList.radioBrowser.StationFieldNamesWeb; import org.apache.commons.lang3.time.FastDateFormat; import org.tukaani.xz.XZInputStream; @@ -40,13 +39,12 @@ import java.util.List; import java.util.zip.ZipInputStream; -public class LoadJsonFactory { +public class SenderLoadFactory { private static final FastDateFormat sdf_date_time = FastDateFormat.getInstance("yyyy-MM-dd HH:mm:ss"); private static int countAll = 0; public static boolean readList() { - //Json laden ~500ms boolean ret = false; final String pathJson = ProgInfos.getStationFileJsonString(); @@ -177,49 +175,49 @@ private static void addValue(Station station, JsonParser jp) throws IOException value = value.trim(); switch (name) { - case StationFieldNamesWeb.NAME: + case SenderSaveFactory.NAME: station.arr[Station.STATION_NAME] = value; break; - case StationFieldNamesWeb.GENRE: + case SenderSaveFactory.GENRE: station.arr[Station.STATION_GENRE] = value; break; - case StationFieldNamesWeb.CODEC: + case SenderSaveFactory.CODEC: station.arr[Station.STATION_CODEC] = value; break; - case StationFieldNamesWeb.BITRATE: + case SenderSaveFactory.BITRATE: station.arr[Station.STATION_BITRATE] = value; break; - case StationFieldNamesWeb.COUNTRY: + case SenderSaveFactory.COUNTRY: station.arr[Station.STATION_COUNTRY] = value; break; - case StationFieldNamesWeb.COUNTRY_CODE: + case SenderSaveFactory.COUNTRY_CODE: station.arr[Station.STATION_COUNTRY_CODE] = value; break; - case StationFieldNamesWeb.STATE: + case SenderSaveFactory.STATE: station.arr[Station.STATION_STATE] = value; break; - case StationFieldNamesWeb.LANGUAGE: + case SenderSaveFactory.LANGUAGE: station.arr[Station.STATION_LANGUAGE] = value; break; - case StationFieldNamesWeb.VOTES: + case SenderSaveFactory.VOTES: station.arr[Station.STATION_VOTES] = value; break; - case StationFieldNamesWeb.CLICK_COUNT: + case SenderSaveFactory.CLICK_COUNT: station.arr[Station.STATION_CLICK_COUNT] = value; break; - case StationFieldNamesWeb.CLICK_TREND: + case SenderSaveFactory.CLICK_TREND: station.arr[Station.STATION_CLICK_TREND] = value; break; - case StationFieldNamesWeb.URL: + case SenderSaveFactory.URL: station.arr[Station.STATION_URL] = value; break; - case StationFieldNamesWeb.URL_RESOLVED: + case SenderSaveFactory.URL_RESOLVED: station.arr[Station.STATION_URL_RESOLVED] = value; break; - case StationFieldNamesWeb.HOMEPAGE: + case SenderSaveFactory.HOMEPAGE: station.arr[Station.STATION_WEBSITE] = value; break; - case StationFieldNamesWeb.LAST_CHANGE_TIME: + case SenderSaveFactory.LAST_CHANGE_TIME: //"2020-08-21 10:40:59" try { PDate pd = new PDate(sdf_date_time.parse(value)); diff --git a/src/main/java/de/p2tools/p2radio/controller/SenderSaveFactory.java b/src/main/java/de/p2tools/p2radio/controller/SenderSaveFactory.java new file mode 100644 index 0000000..c41604c --- /dev/null +++ b/src/main/java/de/p2tools/p2radio/controller/SenderSaveFactory.java @@ -0,0 +1,102 @@ +/* + * P2tools Copyright (C) 2021 W. Xaver W.Xaver[at]googlemail.com + * https://www.p2tools.de/ + * + * This program is free software: you can redistribute it and/or modify it under the terms of the + * GNU General Public License as published by the Free Software Foundation, either version 3 of the + * License, or any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without + * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program. If + * not, see . + */ + + +package de.p2tools.p2radio.controller; + +import com.fasterxml.jackson.core.JsonEncoding; +import com.fasterxml.jackson.core.JsonFactory; +import com.fasterxml.jackson.core.JsonGenerator; +import de.p2tools.p2Lib.configFile.config.Config; +import de.p2tools.p2Lib.tools.duration.PDuration; +import de.p2tools.p2Lib.tools.log.PLog; +import de.p2tools.p2radio.controller.config.ProgData; +import de.p2tools.p2radio.controller.config.ProgInfos; +import de.p2tools.p2radio.controller.data.station.Station; +import de.p2tools.p2radio.controller.data.station.StationList; + +import java.io.FileOutputStream; +import java.nio.file.Path; + +public class SenderSaveFactory { + + public final static String NAME = "name"; + public final static String URL = "url"; + public final static String URL_RESOLVED = "url_resolved"; + public final static String HOMEPAGE = "homepage"; + public final static String GENRE = "tags"; + public final static String COUNTRY = "country"; + public final static String COUNTRY_CODE = "countrycode"; + public final static String STATE = "state"; + public final static String LANGUAGE = "language"; + public final static String VOTES = "votes"; + public final static String LAST_CHANGE_TIME = "lastchangetime"; + public final static String CODEC = "codec"; + public final static String BITRATE = "bitrate"; + public final static String CLICK_COUNT = "clickcount"; + public final static String CLICK_TREND = "clicktrend"; + + private SenderSaveFactory() { + //Json war schneller, beim Lesen und besonders beim Schreiben! + //ProgSaveFactory.saveStationListXml();//370ms + //SenderSaveFactory.saveStationListJson();//90ms + } + + public static void saveStationListJson() { + PDuration.counterStart("ProgSaveFactory.saveStationListJson"); + Path file = ProgInfos.getStationFileJson(); + StationList stationList = ProgData.getInstance().stationList; + + try { + try (FileOutputStream fos = new FileOutputStream(file.toFile()); + JsonGenerator jsonGenerator = + new JsonFactory().createGenerator(fos, JsonEncoding.UTF8).useDefaultPrettyPrinter()) { + + jsonGenerator.writeStartArray(); + jsonGenerator.writeStartObject(); + for (Config meta : stationList.getMeta().getConfigsArr()) { + jsonGenerator.writeStringField(meta.getKey(), meta.getActValueString()); + } + jsonGenerator.writeEndObject(); + + for (Station station : stationList) { + jsonGenerator.writeStartObject(); + jsonGenerator.writeStringField(SenderSaveFactory.NAME, station.arr[Station.STATION_NAME]); + jsonGenerator.writeStringField(SenderSaveFactory.GENRE, station.arr[Station.STATION_GENRE]); + jsonGenerator.writeStringField(SenderSaveFactory.CODEC, station.arr[Station.STATION_CODEC]); + jsonGenerator.writeStringField(SenderSaveFactory.BITRATE, station.arr[Station.STATION_BITRATE]); + jsonGenerator.writeStringField(SenderSaveFactory.COUNTRY, station.arr[Station.STATION_COUNTRY]); + jsonGenerator.writeStringField(SenderSaveFactory.COUNTRY_CODE, station.arr[Station.STATION_COUNTRY_CODE]); + jsonGenerator.writeStringField(SenderSaveFactory.STATE, station.arr[Station.STATION_STATE]); + jsonGenerator.writeStringField(SenderSaveFactory.LANGUAGE, station.arr[Station.STATION_LANGUAGE]); + jsonGenerator.writeStringField(SenderSaveFactory.VOTES, station.arr[Station.STATION_VOTES]); + jsonGenerator.writeStringField(SenderSaveFactory.CLICK_COUNT, station.arr[Station.STATION_CLICK_COUNT]); + jsonGenerator.writeStringField(SenderSaveFactory.CLICK_TREND, station.arr[Station.STATION_CLICK_TREND]); + jsonGenerator.writeStringField(SenderSaveFactory.URL, station.arr[Station.STATION_URL]); + jsonGenerator.writeStringField(SenderSaveFactory.URL_RESOLVED, station.arr[Station.STATION_URL_RESOLVED]); + jsonGenerator.writeStringField(SenderSaveFactory.HOMEPAGE, station.arr[Station.STATION_WEBSITE]); + jsonGenerator.writeStringField(SenderSaveFactory.LAST_CHANGE_TIME, station.arr[Station.STATION_DATE]); + jsonGenerator.writeEndObject(); + } + + jsonGenerator.writeEndArray(); + } + } catch (Exception ex) { + PLog.errorLog(846930145, ex, "nach: " + file); + } + PDuration.counterStop("ProgSaveFactory.saveStationListJson"); + } +} diff --git a/src/main/java/de/p2tools/p2radio/controller/data/start/StartFactory.java b/src/main/java/de/p2tools/p2radio/controller/data/start/StartFactory.java index 834bfdd..38b36b6 100644 --- a/src/main/java/de/p2tools/p2radio/controller/data/start/StartFactory.java +++ b/src/main/java/de/p2tools/p2radio/controller/data/start/StartFactory.java @@ -22,7 +22,6 @@ import de.p2tools.p2radio.controller.data.SetData; import de.p2tools.p2radio.controller.data.favourite.Favourite; import de.p2tools.p2radio.controller.data.station.Station; -import de.p2tools.p2radio.controller.data.station.StationXml; import de.p2tools.p2radio.gui.dialog.NoSetDialogController; public class StartFactory { @@ -100,7 +99,7 @@ private SetData checkSetData(SetData setData) { } private synchronized void startUrlWithProgram(Station station, SetData setData) { - final String url = station.arr[StationXml.STATION_URL]; + final String url = station.getUrl(); if (!url.isEmpty()) { progData.startFactory.stopAll(); ProgConfig.SYSTEM_LAST_PLAYED.setValue(url); diff --git a/src/main/java/de/p2tools/p2radio/controller/data/station/StationFieldNames.java b/src/main/java/de/p2tools/p2radio/controller/data/station/StationFieldNames.java deleted file mode 100644 index a4b23f5..0000000 --- a/src/main/java/de/p2tools/p2radio/controller/data/station/StationFieldNames.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * P2tools Copyright (C) 2021 W. Xaver W.Xaver[at]googlemail.com - * https://www.p2tools.de/ - * - * This program is free software: you can redistribute it and/or modify it under the terms of the - * GNU General Public License as published by the Free Software Foundation, either version 3 of the - * License, or any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without - * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with this program. If - * not, see . - */ - - -package de.p2tools.p2radio.controller.data.station; - -public class StationFieldNames { - - private StationFieldNames() { - } - - public static final String STATION_NO = "Nr"; - public static final String STATION_NAME = "Name"; - public static final String STATION_GENRE = "Genre"; - public static final String STATION_CODEC = "Codec"; - public static final String STATION_BITRATE = "Bitrate"; - public static final String STATION_STATE = "Stadt"; - public static final String STATION_COUNTRY = "Land"; - public static final String STATION_COUNTRY_CODE = "LandCode"; - public static final String STATION_LANGUAGE = "Sprache"; - public static final String STATION_VOTES = "Bewertung"; - public static final String STATION_CLICK_COUNT = "Klickzahl"; - public static final String STATION_CLICK_TREND = "Trend"; - public static final String STATION_URL = "Url"; - public static final String STATION_URL_RESOLVED = "Url Res"; - public static final String STATION_WEBSITE = "Website"; - public static final String STATION_DATE = "Datum"; -} diff --git a/src/main/java/de/p2tools/p2radio/controller/data/station/StationList.java b/src/main/java/de/p2tools/p2radio/controller/data/station/StationList.java index dcf07fd..aecb7a0 100644 --- a/src/main/java/de/p2tools/p2radio/controller/data/station/StationList.java +++ b/src/main/java/de/p2tools/p2radio/controller/data/station/StationList.java @@ -217,7 +217,7 @@ public synchronized void sort() { public synchronized Station getSenderByUrl(final String url) { final Optional opt = - parallelStream().filter(f -> f.arr[StationXml.STATION_URL].equalsIgnoreCase(url)).findAny(); + parallelStream().filter(station -> station.getUrl().equalsIgnoreCase(url)).findAny(); return opt.orElse(null); } diff --git a/src/main/java/de/p2tools/p2radio/controller/data/station/StationProps.java b/src/main/java/de/p2tools/p2radio/controller/data/station/StationProps.java index 6077987..1904526 100644 --- a/src/main/java/de/p2tools/p2radio/controller/data/station/StationProps.java +++ b/src/main/java/de/p2tools/p2radio/controller/data/station/StationProps.java @@ -41,21 +41,21 @@ public class StationProps extends StationXml { @Override public Config[] getConfigsArr() { ArrayList list = new ArrayList<>(); - list.add(new ConfigStringExtra("name", StationFieldNames.STATION_NAME, arr, STATION_NAME)); - list.add(new ConfigStringExtra("genre", StationFieldNames.STATION_GENRE, arr, STATION_GENRE)); - list.add(new ConfigStringExtra("codec", StationFieldNames.STATION_CODEC, arr, STATION_CODEC)); - list.add(new ConfigStringExtra("bitrate", StationFieldNames.STATION_BITRATE, arr, STATION_BITRATE)); - list.add(new ConfigStringExtra("state", StationFieldNames.STATION_STATE, arr, STATION_STATE)); - list.add(new ConfigStringExtra("country", StationFieldNames.STATION_COUNTRY, arr, STATION_COUNTRY)); - list.add(new ConfigStringExtra("countryCode", StationFieldNames.STATION_COUNTRY_CODE, arr, STATION_COUNTRY_CODE)); - list.add(new ConfigStringExtra("language", StationFieldNames.STATION_LANGUAGE, arr, STATION_LANGUAGE)); - list.add(new ConfigStringExtra("votes", StationFieldNames.STATION_VOTES, arr, STATION_VOTES)); - list.add(new ConfigStringExtra("clickCount", StationFieldNames.STATION_CLICK_COUNT, arr, STATION_CLICK_COUNT)); - list.add(new ConfigStringExtra("trend", StationFieldNames.STATION_CLICK_TREND, arr, STATION_CLICK_TREND)); - list.add(new ConfigStringExtra("url", StationFieldNames.STATION_URL, arr, STATION_URL)); - list.add(new ConfigStringExtra("urlR", StationFieldNames.STATION_URL_RESOLVED, arr, STATION_URL_RESOLVED)); - list.add(new ConfigStringExtra("website", StationFieldNames.STATION_WEBSITE, arr, STATION_WEBSITE)); - list.add(new ConfigStringExtra("date", StationFieldNames.STATION_DATE, arr, STATION_DATE)); + list.add(new ConfigStringExtra("name", Station.COLUMN_NAMES[STATION_NAME], arr, STATION_NAME)); + list.add(new ConfigStringExtra("genre", Station.COLUMN_NAMES[STATION_GENRE], arr, STATION_GENRE)); + list.add(new ConfigStringExtra("codec", Station.COLUMN_NAMES[STATION_CODEC], arr, STATION_CODEC)); + list.add(new ConfigStringExtra("bitrate", Station.COLUMN_NAMES[STATION_BITRATE], arr, STATION_BITRATE)); + list.add(new ConfigStringExtra("state", Station.COLUMN_NAMES[STATION_STATE], arr, STATION_STATE)); + list.add(new ConfigStringExtra("country", Station.COLUMN_NAMES[STATION_COUNTRY], arr, STATION_COUNTRY)); + list.add(new ConfigStringExtra("countryCode", Station.COLUMN_NAMES[STATION_COUNTRY_CODE], arr, STATION_COUNTRY_CODE)); + list.add(new ConfigStringExtra("language", Station.COLUMN_NAMES[STATION_LANGUAGE], arr, STATION_LANGUAGE)); + list.add(new ConfigStringExtra("votes", Station.COLUMN_NAMES[STATION_VOTES], arr, STATION_VOTES)); + list.add(new ConfigStringExtra("clickCount", Station.COLUMN_NAMES[STATION_CLICK_COUNT], arr, STATION_CLICK_COUNT)); + list.add(new ConfigStringExtra("trend", Station.COLUMN_NAMES[STATION_CLICK_TREND], arr, STATION_CLICK_TREND)); + list.add(new ConfigStringExtra("url", Station.COLUMN_NAMES[STATION_URL], arr, STATION_URL)); + list.add(new ConfigStringExtra("urlR", Station.COLUMN_NAMES[STATION_URL_RESOLVED], arr, STATION_URL_RESOLVED)); + list.add(new ConfigStringExtra("website", Station.COLUMN_NAMES[STATION_WEBSITE], arr, STATION_WEBSITE)); + list.add(new ConfigStringExtra("date", Station.COLUMN_NAMES[STATION_DATE], arr, STATION_DATE)); return list.toArray(new Config[]{}); } diff --git a/src/main/java/de/p2tools/p2radio/controller/data/station/StationTools.java b/src/main/java/de/p2tools/p2radio/controller/data/station/StationTools.java index ebfa685..18e1a06 100644 --- a/src/main/java/de/p2tools/p2radio/controller/data/station/StationTools.java +++ b/src/main/java/de/p2tools/p2radio/controller/data/station/StationTools.java @@ -45,31 +45,31 @@ public static void saveStation(ArrayList list) { ProgData progData = ProgData.getInstance(); ArrayList addList = new ArrayList<>(); - for (final Station dateStation : list) { + for (final Station station : list) { // erst mal schauen obs den schon gibt - Favourite favourite = progData.favouriteList.getUrlStation(dateStation.arr[Station.STATION_URL]); + Favourite favourite = progData.favouriteList.getUrlStation(station.getUrl()); if (favourite == null) { - addList.add(dateStation); + addList.add(station); } else { // dann ist der Sender schon in der Liste if (list.size() <= 1) { PAlert.BUTTON answer = PAlert.showAlert_yes_no("Anlegen?", "Nochmal anlegen?", "Sender existiert bereits:" + P2LibConst.LINE_SEPARATORx2 + - dateStation.getCountry() + P2LibConst.LINE_SEPARATORx2 + + station.getCountry() + P2LibConst.LINE_SEPARATORx2 + "Nochmal anlegen?"); switch (answer) { case NO: // alles Abbrechen return; case YES: - addList.add(dateStation); + addList.add(station); break; } } else { PAlert.BUTTON answer = PAlert.showAlert_yes_no_cancel("Anlegen?", "Nochmal anlegen?", "Sender existiert bereits:" + P2LibConst.LINE_SEPARATORx2 + - dateStation.getCountry() + P2LibConst.LINE_SEPARATORx2 + + station.getCountry() + P2LibConst.LINE_SEPARATORx2 + "Nochmal anlegen (Ja / Nein)?" + P2LibConst.LINE_SEPARATOR + "Oder alles Abbrechen?"); switch (answer) { @@ -79,7 +79,7 @@ public static void saveStation(ArrayList list) { case NO: continue; case YES: - addList.add(dateStation); + addList.add(station); break; } } diff --git a/src/main/java/de/p2tools/p2radio/controller/getNewStationList/LoadNewStationList.java b/src/main/java/de/p2tools/p2radio/controller/getNewStationList/LoadNewStationList.java index 00c583c..55e60b4 100644 --- a/src/main/java/de/p2tools/p2radio/controller/getNewStationList/LoadNewStationList.java +++ b/src/main/java/de/p2tools/p2radio/controller/getNewStationList/LoadNewStationList.java @@ -19,9 +19,9 @@ import de.p2tools.p2Lib.alert.PAlert; import de.p2tools.p2Lib.tools.duration.PDuration; import de.p2tools.p2Lib.tools.log.PLog; -import de.p2tools.p2radio.controller.LoadJsonFactory; import de.p2tools.p2radio.controller.ProgLoadFactory; -import de.p2tools.p2radio.controller.ProgSaveFactory; +import de.p2tools.p2radio.controller.SenderLoadFactory; +import de.p2tools.p2radio.controller.SenderSaveFactory; import de.p2tools.p2radio.controller.config.ProgData; import de.p2tools.p2radio.controller.config.ProgInfos; import de.p2tools.p2radio.controller.config.pEvent.EventListenerLoadRadioList; @@ -157,7 +157,7 @@ private void afterImportNewStationListFromServer(EventLoadRadioList event) { // dann die alte Liste wieder laden progData.stationList.clear(); setStop(false); - LoadJsonFactory.readList(); + SenderLoadFactory.readList(); // readRadioList.importStationListAuto(progData.stationList); //endlosschleife!! logList.add(""); @@ -173,12 +173,7 @@ private void afterImportNewStationListFromServer(EventLoadRadioList event) { logList.add("Sender schreiben (" + progData.stationList.size() + " Sender) :"); logList.add(" --> Start Schreiben nach: " + ProgInfos.getStationFileJsonString()); - //und noch speichern :) -// PDuration.counterStart("ProgSaveFactory.saveStationList XML"); -// ProgSaveFactory.saveStationListXml();//370ms -// PDuration.counterStop("ProgSaveFactory.saveStationList XML"); - - ProgSaveFactory.saveStationListJson();//90ms + SenderSaveFactory.saveStationListJson(); logList.add(" --> geschrieben!"); logList.add(""); } diff --git a/src/main/java/de/p2tools/p2radio/gui/StationGuiController.java b/src/main/java/de/p2tools/p2radio/gui/StationGuiController.java index cd6be2d..a9e0c3f 100644 --- a/src/main/java/de/p2tools/p2radio/gui/StationGuiController.java +++ b/src/main/java/de/p2tools/p2radio/gui/StationGuiController.java @@ -24,7 +24,6 @@ import de.p2tools.p2radio.controller.data.SetData; import de.p2tools.p2radio.controller.data.station.Station; import de.p2tools.p2radio.controller.data.station.StationTools; -import de.p2tools.p2radio.controller.data.station.StationXml; import de.p2tools.p2radio.gui.tools.table.Table; import javafx.application.Platform; import javafx.beans.property.BooleanProperty; @@ -194,7 +193,7 @@ public Optional getSel(boolean show) { public void selUrl() { final String url = ProgConfig.SYSTEM_LAST_PLAYED.getValue(); Optional optional = tableView.getItems().stream(). - filter(station -> station.arr[StationXml.STATION_URL].equals(url)).findFirst(); + filter(station -> station.getUrl().equals(url)).findFirst(); if (optional.isPresent()) { tableView.getSelectionModel().select(optional.get()); int sel = tableView.getSelectionModel().getSelectedIndex(); diff --git a/src/main/java/de/p2tools/p2radio/gui/dialog/StationInfoDialogController.java b/src/main/java/de/p2tools/p2radio/gui/dialog/StationInfoDialogController.java index 7c0261f..ebd9bc7 100644 --- a/src/main/java/de/p2tools/p2radio/gui/dialog/StationInfoDialogController.java +++ b/src/main/java/de/p2tools/p2radio/gui/dialog/StationInfoDialogController.java @@ -185,7 +185,7 @@ private void setStation() { lblCont[i].setText(station.getClickTrend() + ""); break; case StationXml.STATION_URL: - pHyperlinkUrl.setUrl(station.arr[StationXml.STATION_URL]); + pHyperlinkUrl.setUrl(station.getUrl()); break; case StationXml.STATION_WEBSITE: pHyperlinkWebsite.setUrl(station.arr[StationXml.STATION_WEBSITE]); @@ -298,7 +298,6 @@ private void makeGridPaneBig(GridPane gridPane) { gridPane.add(textTitle[i], 0, row); gridPane.add(ivNew, 1, row++, 3, 1); break; - case StationXml.STATION_URL: gridPane.add(textTitle[i], 0, row); gridPane.add(pHyperlinkUrl, 1, row++, 3, 1); diff --git a/src/main/java/de/p2tools/p2radio/tools/stationListFilter/StationFilterFactory.java b/src/main/java/de/p2tools/p2radio/tools/stationListFilter/StationFilterFactory.java index 9387549..42b7034 100644 --- a/src/main/java/de/p2tools/p2radio/tools/stationListFilter/StationFilterFactory.java +++ b/src/main/java/de/p2tools/p2radio/tools/stationListFilter/StationFilterFactory.java @@ -78,8 +78,8 @@ public static boolean checkCountry(Filter sender, Station station) { } public static boolean checkUrl(Filter url, Station station) { - if (!check(url, station.arr[StationXml.STATION_WEBSITE]) - && !check(url, station.arr[StationXml.STATION_URL])) { + if (!check(url, station.getWebsite()) + && !check(url, station.getUrl())) { return false; } return true; diff --git a/src/main/resources/version.properties b/src/main/resources/version.properties index 7ce3a97..36b0498 100644 --- a/src/main/resources/version.properties +++ b/src/main/resources/version.properties @@ -1,4 +1,4 @@ -#Sun Apr 18 14:24:43 CEST 2021 +#Sun Apr 18 19:58:05 CEST 2021 DATE=18.04.2021 -BUILD=38 +BUILD=40 VERSION=0