diff options
author | Scott Jackson <daneren2005@gmail.com> | 2015-10-05 17:24:54 -0700 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2015-10-05 17:24:54 -0700 |
commit | be6aab9849e16c279d480c32bd478361f41047fe (patch) | |
tree | 27a4158b99ffbbcb0364afe7f6e8b66c72cd22c4 /app/src | |
parent | 4e4963ed23413543e2bc1b95343e8b34d913207d (diff) | |
download | dsub-be6aab9849e16c279d480c32bd478361f41047fe.tar.gz dsub-be6aab9849e16c279d480c32bd478361f41047fe.tar.bz2 dsub-be6aab9849e16c279d480c32bd478361f41047fe.zip |
#560 Fix parseInt failing on empty string
Diffstat (limited to 'app/src')
-rw-r--r-- | app/src/main/java/github/daneren2005/dsub/service/parser/AbstractParser.java | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/app/src/main/java/github/daneren2005/dsub/service/parser/AbstractParser.java b/app/src/main/java/github/daneren2005/dsub/service/parser/AbstractParser.java index 9ecbba52..664adcfb 100644 --- a/app/src/main/java/github/daneren2005/dsub/service/parser/AbstractParser.java +++ b/app/src/main/java/github/daneren2005/dsub/service/parser/AbstractParser.java @@ -23,6 +23,7 @@ import java.io.Reader; import org.xmlpull.v1.XmlPullParser; import android.content.Context; +import android.util.Log; import android.util.Xml; import github.daneren2005.dsub.R; import github.daneren2005.dsub.domain.ServerInfo; @@ -34,7 +35,7 @@ import github.daneren2005.dsub.util.Util; * @author Sindre Mehus */ public abstract class AbstractParser { - + private static final String TAG = AbstractParser.class.getSimpleName(); protected final Context context; protected final int instance; private XmlPullParser parser; @@ -101,7 +102,12 @@ public abstract class AbstractParser { protected Integer getInteger(String name) { String s = get(name); - return s == null ? null : Integer.valueOf(s); + try { + return (s == null || "".equals(s)) ? null : Integer.valueOf(s); + } catch(Exception e) { + Log.w(TAG, "Failed to parse " + s + " into integer"); + return null; + } } protected Long getLong(String name) { |