mirror of
https://github.com/syncthing/syncthing-android.git
synced 2024-11-26 14:21:16 +00:00
Fix parsing connectionServiceStatus (#49)
* Catch failures on gson-parsing SystemInfo * Fix parsing connectionServiceStatus on recent syncthing version * Add SystemStatusConnectionServiceStatusElement to model
This commit is contained in:
parent
8a5e5d7e47
commit
bdce748ac4
3 changed files with 23 additions and 3 deletions
|
@ -9,7 +9,7 @@ import java.util.Map;
|
|||
public class SystemStatus {
|
||||
public long alloc;
|
||||
public double cpuPercent;
|
||||
public Map<String, Map<String, List<String>>> connectionServiceStatus;
|
||||
public Map<String, SystemStatusConnectionServiceStatusElement> connectionServiceStatus;
|
||||
public boolean discoveryEnabled;
|
||||
public Map<String, String> discoveryErrors;
|
||||
public int discoveryMethods;
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
package com.nutomic.syncthingandroid.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* REST API endpoint "/rest/system/status"
|
||||
* Part of JSON answer in field {@link SystemStatus#connectionServiceStatus}
|
||||
*/
|
||||
public class SystemStatusConnectionServiceStatusElement {
|
||||
public String error;
|
||||
public List<String> lanAddresses;
|
||||
public List<String> wanAddresses;
|
||||
}
|
|
@ -505,8 +505,15 @@ public class RestApi {
|
|||
* Requests and parses information about current system status and resource usage.
|
||||
*/
|
||||
public void getSystemStatus(OnResultListener1<SystemStatus> listener) {
|
||||
new GetRequest(mContext, mUrl, GetRequest.URI_SYSTEM_STATUS, mApiKey, null, result ->
|
||||
listener.onResult(new Gson().fromJson(result, SystemStatus.class)));
|
||||
new GetRequest(mContext, mUrl, GetRequest.URI_SYSTEM_STATUS, mApiKey, null, result -> {
|
||||
SystemStatus systemStatus;
|
||||
try {
|
||||
systemStatus = new Gson().fromJson(result, SystemStatus.class);
|
||||
listener.onResult(systemStatus);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "getSystemStatus: Parsing REST API result failed. result=" + result);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public boolean isConfigLoaded() {
|
||||
|
|
Loading…
Reference in a new issue