widget: if final json request fails, do not crash

This commit is contained in:
Andrew Dolgov 2013-05-29 21:19:22 +04:00
parent 068bc6bb81
commit d363cb5346

View File

@ -78,16 +78,20 @@ public class WidgetUpdateService extends Service {
@Override
protected void onPostExecute(JsonElement result) {
if (result != null) {
JsonObject content = result.getAsJsonObject();
try {
JsonObject content = result.getAsJsonObject();
if (content != null) {
int unread = content.get("unread").getAsInt();
if (content != null) {
int unread = content.get("unread").getAsInt();
view.setViewVisibility(R.id.progress, View.GONE);
view.setTextViewText(R.id.counter, String.valueOf(unread));
manager.updateAppWidget(thisWidget, view);
view.setViewVisibility(R.id.progress, View.GONE);
view.setTextViewText(R.id.counter, String.valueOf(unread));
manager.updateAppWidget(thisWidget, view);
return;
return;
}
} catch (Exception e) {
e.printStackTrace();
}
}