Fixed crash when primary dns is custom in test
This commit is contained in:
parent
4a9affef54
commit
aa0cbe1a0d
@ -55,7 +55,7 @@ public class DnsTestFragment extends Fragment {
|
||||
final Spinner spinnerServerChoice = (Spinner) view.findViewById(R.id.spinner_server_choice);
|
||||
ArrayAdapter spinnerArrayAdapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_list_item_1, DnsServerHelper.getNames(Daedalus.getInstance()));
|
||||
spinnerServerChoice.setAdapter(spinnerArrayAdapter);
|
||||
spinnerServerChoice.setSelection(Integer.parseInt(DnsServerHelper.getPrimary()));
|
||||
spinnerServerChoice.setSelection(DnsServerHelper.getPosition(DnsServerHelper.getPrimary()));
|
||||
|
||||
final AutoCompleteTextView textViewTestUrl = (AutoCompleteTextView) view.findViewById(R.id.autoCompleteTextView_test_url);
|
||||
ArrayAdapter autoCompleteArrayAdapter = new ArrayAdapter<>(Daedalus.getInstance(), android.R.layout.simple_list_item_1, Daedalus.DEFAULT_TEST_DOMAINS);
|
||||
|
@ -46,6 +46,20 @@ public class DnsServerHelper {
|
||||
return defaultPort;
|
||||
}
|
||||
|
||||
public static int getPosition(String id) {
|
||||
int intId = Integer.parseInt(id);
|
||||
if (intId < Daedalus.DNS_SERVERS.size()) {
|
||||
return intId;
|
||||
}
|
||||
|
||||
for (int i = 0; i < Daedalus.configurations.getCustomDnsServers().size(); i++) {
|
||||
if (Daedalus.configurations.getCustomDnsServers().get(i).getId().equals(id)) {
|
||||
return i + Daedalus.DNS_SERVERS.size();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static String getPrimary() {
|
||||
return String.valueOf(DnsServerHelper.checkServerId(Integer.parseInt(Daedalus.getPrefs().getString("primary_server", "0"))));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user