From 3ce883466b942ea73696d6a4b367253372ba343b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Brey?= Date: Tue, 31 May 2022 09:14:27 +0200 Subject: [PATCH] Fix NPE in ChooseTemplateDialogFragment.checkEnablingCreateButton MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This method can be called before positiveButton is initialized Signed-off-by: Álvaro Brey --- .../ui/dialog/ChooseTemplateDialogFragment.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/owncloud/android/ui/dialog/ChooseTemplateDialogFragment.java b/app/src/main/java/com/owncloud/android/ui/dialog/ChooseTemplateDialogFragment.java index 761984390d..336b869052 100644 --- a/app/src/main/java/com/owncloud/android/ui/dialog/ChooseTemplateDialogFragment.java +++ b/app/src/main/java/com/owncloud/android/ui/dialog/ChooseTemplateDialogFragment.java @@ -286,11 +286,13 @@ public class ChooseTemplateDialogFragment extends DialogFragment implements View } private void checkEnablingCreateButton() { - Template selectedTemplate = adapter.getSelectedTemplate(); - String name = binding.filename.getText().toString(); + if (positiveButton != null) { + Template selectedTemplate = adapter.getSelectedTemplate(); + String name = binding.filename.getText().toString(); - positiveButton.setEnabled(selectedTemplate != null && !name.isEmpty() && - !name.equalsIgnoreCase(DOT + selectedTemplate.getExtension())); + positiveButton.setEnabled(selectedTemplate != null && !name.isEmpty() && + !name.equalsIgnoreCase(DOT + selectedTemplate.getExtension())); + } } private static class CreateFileFromTemplateTask extends AsyncTask {