mirror of
https://codeberg.org/r4v3r23/mysu.git
synced 2024-11-09 20:53:47 +01:00
Fix some issues with editing nodes
This commit is contained in:
parent
bc004857ee
commit
c8ed32e5b0
@ -86,7 +86,7 @@ public class AddNodeBottomSheetDialog extends BottomSheetDialogFragment {
|
|||||||
|
|
||||||
JSONObject jsonObject = new JSONObject();
|
JSONObject jsonObject = new JSONObject();
|
||||||
try {
|
try {
|
||||||
if (!user.isEmpty() && !pass.isEmpty()) {
|
if (!user.isEmpty()) {
|
||||||
jsonObject.put("username", user);
|
jsonObject.put("username", user);
|
||||||
jsonObject.put("password", pass);
|
jsonObject.put("password", pass);
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ public class EditNodeBottomSheetDialog extends BottomSheetDialogFragment {
|
|||||||
Node node = Node.fromJson(nodeJson);
|
Node node = Node.fromJson(nodeJson);
|
||||||
if(node == null) return;
|
if(node == null) return;
|
||||||
addressEditText.setText(node.getHost());
|
addressEditText.setText(node.getHost());
|
||||||
portEditText.setText(node.getRpcPort());
|
portEditText.setText(""+node.getRpcPort());
|
||||||
nodeNameEditText.setText(node.getName());
|
nodeNameEditText.setText(node.getName());
|
||||||
usernameEditText.setText(node.getUsername());
|
usernameEditText.setText(node.getUsername());
|
||||||
if(!node.getPassword().isEmpty()) {
|
if(!node.getPassword().isEmpty()) {
|
||||||
@ -91,7 +91,8 @@ public class EditNodeBottomSheetDialog extends BottomSheetDialogFragment {
|
|||||||
dismiss();
|
dismiss();
|
||||||
});
|
});
|
||||||
doneEditingButton.setOnClickListener(view1 -> {
|
doneEditingButton.setOnClickListener(view1 -> {
|
||||||
String nodeAddress = addressEditText.getText().toString();
|
String nodeAddr = addressEditText.getText().toString();
|
||||||
|
String portString = portEditText.getText().toString();
|
||||||
String nodeName = nodeNameEditText.getText().toString();
|
String nodeName = nodeNameEditText.getText().toString();
|
||||||
String user = usernameEditText.getText().toString();
|
String user = usernameEditText.getText().toString();
|
||||||
String pass = passwordEditText.getText().toString();
|
String pass = passwordEditText.getText().toString();
|
||||||
@ -99,7 +100,7 @@ public class EditNodeBottomSheetDialog extends BottomSheetDialogFragment {
|
|||||||
if(nodeName.isEmpty()) {
|
if(nodeName.isEmpty()) {
|
||||||
Toast.makeText(getContext(), "Enter node name", Toast.LENGTH_SHORT).show();
|
Toast.makeText(getContext(), "Enter node name", Toast.LENGTH_SHORT).show();
|
||||||
return;
|
return;
|
||||||
} else if(nodeAddress.isEmpty()) {
|
} else if(nodeAddr.isEmpty() || portString.isEmpty()) {
|
||||||
Toast.makeText(getContext(), "Enter node address", Toast.LENGTH_SHORT).show();
|
Toast.makeText(getContext(), "Enter node address", Toast.LENGTH_SHORT).show();
|
||||||
return;
|
return;
|
||||||
} else if(!user.isEmpty() && pass.isEmpty()) {
|
} else if(!user.isEmpty() && pass.isEmpty()) {
|
||||||
@ -108,14 +109,13 @@ public class EditNodeBottomSheetDialog extends BottomSheetDialogFragment {
|
|||||||
}
|
}
|
||||||
JSONObject jsonObject = new JSONObject();
|
JSONObject jsonObject = new JSONObject();
|
||||||
try {
|
try {
|
||||||
if (!user.isEmpty() && !pass.isEmpty()) {
|
if (!user.isEmpty()) {
|
||||||
jsonObject.put("username", user);
|
jsonObject.put("username", user);
|
||||||
jsonObject.put("password", pass);
|
jsonObject.put("password", pass);
|
||||||
}
|
}
|
||||||
String[] nodeParts = nodeAddress.split(":");
|
|
||||||
|
|
||||||
jsonObject.put("host", nodeParts[0]);
|
jsonObject.put("host", nodeAddr);
|
||||||
jsonObject.put("rpcPort", nodeParts[1]);
|
jsonObject.put("rpcPort", Integer.parseInt(portString));
|
||||||
jsonObject.put("network", "mainnet");
|
jsonObject.put("network", "mainnet");
|
||||||
jsonObject.put("name", nodeName);
|
jsonObject.put("name", nodeName);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user