don't crash when first run without network connection

This commit is contained in:
Eric House 2015-08-03 05:25:10 -07:00
parent 013e0e3a4c
commit 3064420c78
2 changed files with 43 additions and 38 deletions

View file

@ -1140,6 +1140,7 @@ public class DictsDelegate extends ListDelegateBase
JSONObject theOne = null;
String langName = null;
String json = NetUtils.runPost( post, new JSONObject() );
if ( null != json ) {
try {
JSONObject obj = new JSONObject( json );
JSONArray langs = obj.optJSONArray( "langs" );
@ -1163,7 +1164,8 @@ public class DictsDelegate extends ListDelegateBase
break;
} else {
int nWords = dict.getInt( "nWords" );
if ( null == theOne || nWords > theOneNWords ) {
if ( null == theOne
|| nWords > theOneNWords ) {
theOne = dict;
theOneNWords = nWords;
}
@ -1185,6 +1187,7 @@ public class DictsDelegate extends ListDelegateBase
DbgUtils.loge( ex );
theOne = null;
}
}
if ( null != theOne ) {
name = theOne.optString( "xwd" );

View file

@ -234,6 +234,8 @@ public class NetUtils {
}
} catch( java.io.UnsupportedEncodingException uee ) {
DbgUtils.loge( uee );
} catch( java.net.UnknownHostException uhe ) {
DbgUtils.loge( uhe );
} catch( java.io.IOException ioe ) {
DbgUtils.loge( ioe );
}