mirror of
https://codeberg.org/anoncontributorxmr/mysu.git
synced 2024-11-10 05:03:26 +01:00
Cleanup and add comment
This commit is contained in:
parent
9e70f64e39
commit
f95683aed2
@ -73,6 +73,7 @@ public class NodeSelectionBottomSheetDialog extends BottomSheetDialogFragment im
|
||||
}
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
// if stored node is old string format, try parse and upgrade, if fail then remove
|
||||
try {
|
||||
String nodeString = jsonArray.getString(i);
|
||||
Node node = Node.fromString(nodeString);
|
||||
|
@ -45,12 +45,17 @@ public class PrefService extends ServiceBase {
|
||||
JSONObject nodeJson = new JSONObject(nodeString);
|
||||
return Node.fromJson(nodeJson);
|
||||
} catch (JSONException e) {
|
||||
if(!nodeString.isEmpty()) {
|
||||
Node node = Node.fromString(nodeString);
|
||||
if(node != null) {
|
||||
edit().putString(Constants.PREF_NODE_2, node.toJson().toString()).apply();
|
||||
return node;
|
||||
}
|
||||
// stored node is not json format, upgrade if possible
|
||||
return upgradeOldNode(nodeString);
|
||||
}
|
||||
}
|
||||
|
||||
private Node upgradeOldNode(String nodeString) {
|
||||
if(!nodeString.isEmpty()) {
|
||||
Node node = Node.fromString(nodeString);
|
||||
if(node != null) {
|
||||
edit().putString(Constants.PREF_NODE_2, node.toJson().toString()).apply();
|
||||
return node;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
Loading…
Reference in New Issue
Block a user