Fix NPE in ChooseTemplateDialogFragment.checkEnablingCreateButton

This method can be called before positiveButton is initialized

Signed-off-by: Álvaro Brey <alvaro.brey@nextcloud.com>
This commit is contained in:
Álvaro Brey 2022-05-31 09:14:27 +02:00 committed by Álvaro Brey (Rebase PR Action)
parent 82daff8797
commit 3ce883466b

View file

@ -286,11 +286,13 @@ public class ChooseTemplateDialogFragment extends DialogFragment implements View
} }
private void checkEnablingCreateButton() { private void checkEnablingCreateButton() {
Template selectedTemplate = adapter.getSelectedTemplate(); if (positiveButton != null) {
String name = binding.filename.getText().toString(); Template selectedTemplate = adapter.getSelectedTemplate();
String name = binding.filename.getText().toString();
positiveButton.setEnabled(selectedTemplate != null && !name.isEmpty() && positiveButton.setEnabled(selectedTemplate != null && !name.isEmpty() &&
!name.equalsIgnoreCase(DOT + selectedTemplate.getExtension())); !name.equalsIgnoreCase(DOT + selectedTemplate.getExtension()));
}
} }
private static class CreateFileFromTemplateTask extends AsyncTask<Void, Void, String> { private static class CreateFileFromTemplateTask extends AsyncTask<Void, Void, String> {