removed 'catch' added check for null

This commit is contained in:
daniel oeh 2012-07-24 18:15:30 +02:00
parent b51aaf2a92
commit 6321136271
1 changed files with 38 additions and 35 deletions

View File

@ -28,6 +28,7 @@ public class TypeGetter {
public Type getType(Feed feed) throws UnsupportedFeedtypeException { public Type getType(Feed feed) throws UnsupportedFeedtypeException {
XmlPullParserFactory factory; XmlPullParserFactory factory;
if (feed.getFile_url() != null) {
try { try {
factory = XmlPullParserFactory.newInstance(); factory = XmlPullParserFactory.newInstance();
factory.setNamespaceAware(true); factory.setNamespaceAware(true);
@ -39,15 +40,18 @@ public class TypeGetter {
if (eventType == XmlPullParser.START_TAG) { if (eventType == XmlPullParser.START_TAG) {
String tag = xpp.getName(); String tag = xpp.getName();
if (tag.equals(ATOM_ROOT)) { if (tag.equals(ATOM_ROOT)) {
if (AppConfig.DEBUG) Log.d(TAG, "Recognized type Atom"); if (AppConfig.DEBUG)
Log.d(TAG, "Recognized type Atom");
return Type.ATOM; return Type.ATOM;
} else if (tag.equals(RSS_ROOT) } else if (tag.equals(RSS_ROOT)
&& (xpp.getAttributeValue(null, "version") && (xpp.getAttributeValue(null, "version")
.equals("2.0"))) { .equals("2.0"))) {
if (AppConfig.DEBUG) Log.d(TAG, "Recognized type RSS 2.0"); if (AppConfig.DEBUG)
Log.d(TAG, "Recognized type RSS 2.0");
return Type.RSS20; return Type.RSS20;
} else { } else {
if (AppConfig.DEBUG) Log.d(TAG, "Type is invalid"); if (AppConfig.DEBUG)
Log.d(TAG, "Type is invalid");
throw new UnsupportedFeedtypeException(Type.INVALID); throw new UnsupportedFeedtypeException(Type.INVALID);
} }
} else { } else {
@ -60,7 +64,9 @@ public class TypeGetter {
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
if (AppConfig.DEBUG) Log.d(TAG, "Type is invalid"); }
if (AppConfig.DEBUG)
Log.d(TAG, "Type is invalid");
throw new UnsupportedFeedtypeException(Type.INVALID); throw new UnsupportedFeedtypeException(Type.INVALID);
} }
@ -71,9 +77,6 @@ public class TypeGetter {
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
e.printStackTrace(); e.printStackTrace();
return null; return null;
} catch (NullPointerException e) {
e.printStackTrace();
return null;
} }
return reader; return reader;
} }