News Manager silent error fix
This commit is contained in:
@@ -53,10 +53,19 @@ 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).getString("title_" + language);
|
String title;
|
||||||
//noinspection ConstantConditions
|
if (news.getJSONObject(i).has("title_" + language)) {
|
||||||
if (title == null)
|
title = news.getJSONObject(i).getString("title_" + language);
|
||||||
|
} else {
|
||||||
title = news.getJSONObject(i).getString("title");
|
title = news.getJSONObject(i).getString("title");
|
||||||
|
}
|
||||||
|
String text;
|
||||||
|
if (news.getJSONObject(i).has("text_" + language)) {
|
||||||
|
text = news.getJSONObject(i).getString("text_" + language);
|
||||||
|
} else {
|
||||||
|
text = news.getJSONObject(i).getString("text");
|
||||||
|
}
|
||||||
|
|
||||||
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"))
|
||||||
@@ -65,10 +74,6 @@ public class NewsManager {
|
|||||||
category = 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).getString("title_" + language);
|
|
||||||
//noinspection ConstantConditions
|
|
||||||
if (text == null)
|
|
||||||
text = news.getJSONObject(i).getString("text");
|
|
||||||
News event = new 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) {
|
||||||
|
|||||||
Reference in New Issue
Block a user