Tiny News fix up

This commit is contained in:
Sebastian Seedorf
2019-10-18 18:05:13 +02:00
parent 46851a4627
commit 69a0fcb3a3
2 changed files with 9 additions and 6 deletions

View File

@@ -16,6 +16,7 @@ import de.sebse.fuplanner.tools.UtilsDate;
import de.sebse.fuplanner.tools.network.NetworkCallback; import de.sebse.fuplanner.tools.network.NetworkCallback;
import de.sebse.fuplanner.tools.network.NetworkError; import de.sebse.fuplanner.tools.network.NetworkError;
import de.sebse.fuplanner.tools.network.NetworkErrorCallback; import de.sebse.fuplanner.tools.network.NetworkErrorCallback;
import de.sebse.fuplanner.tools.types.News;
import de.sebse.fuplanner.tools.types.NewsList; import de.sebse.fuplanner.tools.types.NewsList;
public class NewsManager { public class NewsManager {
@@ -52,21 +53,23 @@ public class NewsManager {
for (int i = news.length() - 1; i >= 0; i--) { for (int i = news.length() - 1; i >= 0; i--) {
try { try {
String title = news.getJSONObject(i).optString("title_" + language, null); String title = news.getJSONObject(i).getString("title_" + language);
//noinspection ConstantConditions
if (title == null) if (title == null)
title = news.getJSONObject(i).getString("title"); title = news.getJSONObject(i).getString("title");
String categoryString = news.getJSONObject(i).getString("category"); String categoryString = news.getJSONObject(i).getString("category");
int category; int category;
if (categoryString.equals("CATEGORY_TRICKS")) if (categoryString.equals("CATEGORY_TRICKS"))
category = de.sebse.fuplanner.tools.types.News.CATEGORY_TRICKS; category = News.CATEGORY_TRICKS;
else else
category = de.sebse.fuplanner.tools.types.News.CATEGORY_UPDATE; category = News.CATEGORY_UPDATE;
String dateString = news.getJSONObject(i).getString("date"); String dateString = news.getJSONObject(i).getString("date");
long date = UtilsDate.stringToMillis(dateString, "dd.MM.yyyy"); long date = UtilsDate.stringToMillis(dateString, "dd.MM.yyyy");
String text = news.getJSONObject(i).optString("text_" + language, null); String text = news.getJSONObject(i).getString("title_" + language);
//noinspection ConstantConditions
if (text == null) if (text == null)
text = news.getJSONObject(i).getString("text"); text = news.getJSONObject(i).getString("text");
de.sebse.fuplanner.tools.types.News event = new de.sebse.fuplanner.tools.types.News(title, category, date, text); News event = new News(title, category, date, text);
dates.add(event); dates.add(event);
} catch (JSONException e) { } catch (JSONException e) {
e.printStackTrace(); e.printStackTrace();

View File

@@ -22,7 +22,7 @@
"date": "18.11.2018", "date": "18.11.2018",
"category": "CATEGORY_UPDATE", "category": "CATEGORY_UPDATE",
"text": "Currently, the data is not automatically synchronized with the KVV. You can trigger a manual sync by simply dragging the view down. An exception is the timetable. Here you can update with the three points in the top right.", "text": "Currently, the data is not automatically synchronized with the KVV. You can trigger a manual sync by simply dragging the view down. An exception is the timetable. Here you can update with the three points in the top right.",
"text_de": "Derzeit werden die Daten noch nicht automatisch mit dem KVV synchronisiert. Eine manuelle Synchronisierung kannst Du auslösen, indem Du die Ansicht einfach nach unten ziehst. Eine Ausnahme bildet der Stundenplan. Hier kannst Du über die drei Punkte oben rechts aktualisieren." "text_de": "Derzeit werden die Daten nicht automatisch mit dem KVV synchronisiert. Eine manuelle Synchronisierung kannst Du auslösen, indem Du die Ansicht einfach nach unten ziehst. Eine Ausnahme bildet der Stundenplan. Hier kannst Du über die drei Punkte oben rechts aktualisieren."
}, },
{ {
"title": "Resources", "title": "Resources",