From e00a7151fce1f63dd7c507d0bd65c5df526c148d Mon Sep 17 00:00:00 2001 From: Robert Kolner Date: Thu, 14 Feb 2013 12:56:13 +0100 Subject: [PATCH] Fixed a 'bug' which made some events not be shown in program. --- .../studentersamfundet/app/JSONParserProgram.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/com/studentersamfundet/app/JSONParserProgram.java b/src/com/studentersamfundet/app/JSONParserProgram.java index bffa502..1aae2f6 100644 --- a/src/com/studentersamfundet/app/JSONParserProgram.java +++ b/src/com/studentersamfundet/app/JSONParserProgram.java @@ -69,11 +69,15 @@ public class JSONParserProgram implements IParser { date = custom.getJSONArray("_neuf_events_starttime").getString(0); JSONArray attachments = tempJSON.getJSONArray("attachments"); - JSONObject images = attachments.getJSONObject(0).getJSONObject("images"); - - image = images.getJSONObject("full").getString("url"); - thumb = images.getJSONObject("thumbnail").getString("url"); - + if (attachments == null || attachments.length() == 0) { + image = tempJSON.getString("thumbnail"); + thumb = tempJSON.getString("thumbnail"); + } else { + JSONObject images = attachments.getJSONObject(0).getJSONObject("images"); + image = images.getJSONObject("full").getString("url"); + thumb = images.getJSONObject("thumbnail").getString("url"); + } + // This is as ugly as it gets. Refactor? dh.insertEvent(id, title,