mirror of
https://codeberg.org/anoncontributorxmr/mysu.git
synced 2024-11-29 10:43:15 +00:00
Cleanup and add comment
This commit is contained in:
parent
9e70f64e39
commit
f95683aed2
2 changed files with 12 additions and 6 deletions
|
@ -73,6 +73,7 @@ public class NodeSelectionBottomSheetDialog extends BottomSheetDialogFragment im
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
|
// if stored node is old string format, try parse and upgrade, if fail then remove
|
||||||
try {
|
try {
|
||||||
String nodeString = jsonArray.getString(i);
|
String nodeString = jsonArray.getString(i);
|
||||||
Node node = Node.fromString(nodeString);
|
Node node = Node.fromString(nodeString);
|
||||||
|
|
|
@ -45,6 +45,12 @@ public class PrefService extends ServiceBase {
|
||||||
JSONObject nodeJson = new JSONObject(nodeString);
|
JSONObject nodeJson = new JSONObject(nodeString);
|
||||||
return Node.fromJson(nodeJson);
|
return Node.fromJson(nodeJson);
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
|
// stored node is not json format, upgrade if possible
|
||||||
|
return upgradeOldNode(nodeString);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Node upgradeOldNode(String nodeString) {
|
||||||
if(!nodeString.isEmpty()) {
|
if(!nodeString.isEmpty()) {
|
||||||
Node node = Node.fromString(nodeString);
|
Node node = Node.fromString(nodeString);
|
||||||
if(node != null) {
|
if(node != null) {
|
||||||
|
@ -52,7 +58,6 @@ public class PrefService extends ServiceBase {
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue