Letme/give-me-coinsMonitoringApp — pull request #11 by justinmuller (2013-11-30 07:12:32+00:00)
Title: Prevent `JSONException`

Prevent a `JSONException` from being thrown when unexpected JSON is encountered:

`{"alive":"1","last_share_timestamp":null,"hashrate":"int","username":"String"}`
`{"alive":"1","hashrate":"int","username":"String"}`

This `JSONException` was being caught, and resulted in debug statements being printed to `logcat`:
`D/JSONHelper(xxxxx): long json error org.json.JSONException: No value for last_share_timestamp`
`D/JSONHelper(xxxxx): long json error org.json.JSONException: Value null at last_share_timestamp of type org.json.JSONObject$1 cannot be converted to long`

Here is a stacktrace demonstrating one instance of this issue:
`org.json.JSONException: Value null at last_share_timestamp of type org.json.JSONObject$1 cannot be converted to long
at give_me_coins.dashboard.JSONHelper.getVal(JSONHelper.java:143)
at give_me_coins.dashboard.GiveMeCoinsWorkerInfo.(GiveMeCoinsWorkerInfo.java:82)
at give_me_coins.dashboard.GiveMeCoinsInfo.(GiveMeCoinsInfo.java:102)
at give_me_coins.dashboard.GetInfoWorker.onProgressUpdate(GetInfoWorker.java:150)
at give_me_coins.dashboard.GetInfoWorker.onProgressUpdate(GetInfoWorker.java:23)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:647)
.
.
Caused by: org.json.JSONException: Value null at last_share_timestamp of type org.json.JSONObject$1 cannot be converted to long
at org.json.JSON.typeMismatch(JSON.java:100)
at org.json.JSONObject.getLong(JSONObject.java:480)
at give_me_coins.dashboard.JSONHelper.getVal(JSONHelper.java:139)`