1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-23 18:02:15 -05:00

Don't use enum ordinal as array index

This fixes a crash when setting up WebDAV accounts.
This commit is contained in:
cketti 2014-04-27 03:29:06 +02:00
parent da74253f7b
commit 51aa34d52b

View File

@ -261,8 +261,11 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
securityTypesAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
mSecurityTypeView.setAdapter(securityTypesAdapter);
int index = getSecurityTypePosition(mConnectionSecurityChoices,
settings.connectionSecurity);
// Select currently configured security type
mSecurityTypeView.setSelection(settings.connectionSecurity.ordinal(), false);
mSecurityTypeView.setSelection(index, false);
/*
* Updates the port when the user changes the security type. This allows
@ -469,4 +472,13 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
Toast toast = Toast.makeText(getApplication(), toastText, Toast.LENGTH_LONG);
toast.show();
}
private int getSecurityTypePosition(ConnectionSecurity[] haystack, ConnectionSecurity needle) {
for (int i = 0; i < haystack.length; i++) {
if (haystack[i] == needle) {
return i;
}
}
return 0;
}
}