1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2024-11-22 10:15:16 +01:00

Fix NPE, since dismissing a dialog still calls onViewCreated()

This commit is contained in:
Stypox 2024-03-28 11:35:21 +01:00
parent d3afde8789
commit 5d9adce40d
No known key found for this signature in database
GPG Key ID: 4BDF1B40A49FDD23

View File

@ -115,7 +115,7 @@ public class DownloadDialog extends DialogFragment
private StoredDirectoryHelper mainStorageVideo = null;
private DownloadManager downloadManager = null;
private ActionMenuItemView okButton = null;
private Context context;
private Context context = null;
private boolean askForSavePath;
private AudioTrackAdapter audioTrackAdapter;
@ -209,6 +209,8 @@ public class DownloadDialog extends DialogFragment
return;
}
// context will remain null if dismiss() was called above, allowing to check whether the
// dialog is being dismissed in onViewCreated()
context = getContext();
setStyle(STYLE_NO_TITLE, ThemeHelper.getDialogTheme(context));
@ -293,6 +295,9 @@ public class DownloadDialog extends DialogFragment
@Nullable final Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
dialogBinding = DownloadDialogBinding.bind(view);
if (context == null) {
return; // the dialog is being dismissed, see the call to dismiss() in onCreate()
}
dialogBinding.fileName.setText(FilenameUtils.createFilename(getContext(),
currentInfo.getName()));