Commit 9627e86d authored by Matyáš Latner's avatar Matyáš Latner
Browse files

#13 Fixed NullPointerException in ControlServerConnection

parent de9d3e1e
......@@ -250,16 +250,18 @@ public class ControlServerConnection
JSONArray jsonArray = sendRequest(hostUrl, requestData, null);
try {
final JSONObject newsItem = jsonArray.getJSONObject(0);
Long time = newsItem.getLong("time");
if (jsonArray != null) {
try {
final JSONObject newsItem = jsonArray.getJSONObject(0);
Long time = newsItem.getLong("time");
return time;
} catch (JSONException e) {
e.printStackTrace();
return null;
return time;
} catch (JSONException e) {
e.printStackTrace();
}
}
return null;
}
public JSONArray requestNews(final long lastNewsUid)
......@@ -516,7 +518,13 @@ public class ControlServerConnection
{
hasError = false;
long time = requestTime();
Long time = requestTime();
if (time == null) {
hasError = true;
errorMsg = "Cannot obtain time from server!";
return null;
}
final URI hostUrl = getUri(Config.RMBT_SETTINGS_HOST_URL);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment