Check for null game info and catch all exceptions

This commit is contained in:
TwistedUmbrella 2015-07-18 02:36:20 -04:00
parent f21e9382d2
commit 7fecd6ba43
1 changed files with 14 additions and 11 deletions

View File

@ -155,17 +155,20 @@ public class XMLParser extends AsyncTask<String, Integer, String> {
if (gameData != null) {
try {
Document doc = getDomElement(gameData);
Element root = (Element) doc.getElementsByTagName("Game").item(
0);
game_name = getValue(root, "GameTitle");
String details = getValue(root, "Overview");
game_details.put(index, details);
Element images = (Element) root.getElementsByTagName("Images").item(0);
Element boxart = (Element) images.getElementsByTagName("boxart").item(1);
String image = "http://thegamesdb.net/banners/" + getElementValue(boxart);
game_preview.put(index, decodeBitmapIcon(image));
game_icon = new BitmapDrawable(decodeBitmapIcon(image));
} catch (IOException e) {
if (doc.getElementsByTagName("Game") != null) {
Element root = (Element) doc.getElementsByTagName("Game").item(0);
game_name = getValue(root, "GameTitle");
String details = getValue(root, "Overview");
game_details.put(index, details);
Element images = (Element) root.getElementsByTagName("Images").item(0);
Element boxart = (Element) images.getElementsByTagName("boxart").item(1);
String image = "http://thegamesdb.net/banners/" + getElementValue(boxart);
game_preview.put(index, decodeBitmapIcon(image));
game_icon = new BitmapDrawable(decodeBitmapIcon(image));
} else {
initializeDefaults();
}
} catch (Exception e) {
initializeDefaults();
}
} else {