ChooseRichDocumentsTemplate: avoid IOOBE if there is no dot in field

Signed-off-by: Álvaro Brey <alvaro.brey@nextcloud.com>
This commit is contained in:
Álvaro Brey 2022-06-16 12:14:51 +02:00
parent 82d86b978b
commit b7f7388802
No known key found for this signature in database
GPG key ID: 2585783189A62105

View file

@ -249,7 +249,11 @@ public class ChooseRichDocumentsTemplateDialogFragment extends DialogFragment im
if (name.isEmpty() || name.equalsIgnoreCase(DOT + template.getExtension())) {
binding.filename.setText(String.format("%s.%s", template.getName(), template.getExtension()));
}
binding.filename.setSelection(binding.filename.getText().toString().lastIndexOf('.'));
final int dotIndex = binding.filename.getText().toString().lastIndexOf('.');
if (dotIndex >= 0) {
binding.filename.setSelection(dotIndex);
}
}
private void checkEnablingCreateButton() {