mirror of
https://github.com/syncthing/syncthing-android.git
synced 2024-11-23 04:41:16 +00:00
Check if JSON string is null before parsing.
This commit is contained in:
parent
41943502d4
commit
ae8dc76ba9
1 changed files with 10 additions and 1 deletions
|
@ -218,6 +218,9 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener,
|
||||||
new GetTask(mHttpsCertPath) {
|
new GetTask(mHttpsCertPath) {
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(String s) {
|
protected void onPostExecute(String s) {
|
||||||
|
if (s == null)
|
||||||
|
return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
JSONObject json = new JSONObject(s);
|
JSONObject json = new JSONObject(s);
|
||||||
mVersion = json.getString("version");
|
mVersion = json.getString("version");
|
||||||
|
@ -986,11 +989,14 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener,
|
||||||
/**
|
/**
|
||||||
* Normalizes a given device ID.
|
* Normalizes a given device ID.
|
||||||
*/
|
*/
|
||||||
public void normalizeDeviceId(String id, final OnDeviceIdNormalizedListener listener) {
|
public void normalizeDeviceId(final String id, final OnDeviceIdNormalizedListener listener) {
|
||||||
new GetTask(mHttpsCertPath) {
|
new GetTask(mHttpsCertPath) {
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(String s) {
|
protected void onPostExecute(String s) {
|
||||||
super.onPostExecute(s);
|
super.onPostExecute(s);
|
||||||
|
if (s == null)
|
||||||
|
return;
|
||||||
|
|
||||||
String normalized = null;
|
String normalized = null;
|
||||||
String error = null;
|
String error = null;
|
||||||
try {
|
try {
|
||||||
|
@ -1127,6 +1133,9 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener,
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(String s) {
|
protected void onPostExecute(String s) {
|
||||||
try {
|
try {
|
||||||
|
if (s == null)
|
||||||
|
return;
|
||||||
|
|
||||||
listener.onReceiveUsageReport(new JSONObject(s).toString(4));
|
listener.onReceiveUsageReport(new JSONObject(s).toString(4));
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
throw new RuntimeException("Failed to prettify usage report", e);
|
throw new RuntimeException("Failed to prettify usage report", e);
|
||||||
|
|
Loading…
Reference in a new issue