add null check and display custom nodes first

This commit is contained in:
pokkst 2022-09-17 04:36:57 -05:00
parent 4657132067
commit e197cc038d
No known key found for this signature in database
GPG key ID: 90C2ED85E67A50FF

View file

@ -58,21 +58,23 @@ public class NodeSelectionBottomSheetDialog extends BottomSheetDialogFragment im
dismiss(); dismiss();
}); });
for(DefaultNodes defaultNode : DefaultNodes.values()) {
nodes.add(Node.fromString(defaultNode.getUri()));
}
try { try {
String nodesArray = PrefService.getInstance().getString(Constants.PREF_CUSTOM_NODES, "[]"); String nodesArray = PrefService.getInstance().getString(Constants.PREF_CUSTOM_NODES, "[]");
JSONArray jsonArray = new JSONArray(nodesArray); JSONArray jsonArray = new JSONArray(nodesArray);
for(int i = 0; i < jsonArray.length(); i++) { for(int i = 0; i < jsonArray.length(); i++) {
String nodeString = jsonArray.getString(i); String nodeString = jsonArray.getString(i);
Node node = Node.fromString(nodeString); Node node = Node.fromString(nodeString);
nodes.add(node); if(node != null) {
nodes.add(node);
}
} }
} catch (JSONException e) { } catch (JSONException e) {
e.printStackTrace(); e.printStackTrace();
} }
for(DefaultNodes defaultNode : DefaultNodes.values()) {
nodes.add(Node.fromString(defaultNode.getUri()));
}
adapter.submitList(nodes); adapter.submitList(nodes);
} }