File tree Expand file tree Collapse file tree
app/src/main/java/org/schabi/newpipe/download Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -115,7 +115,7 @@ public class DownloadDialog extends DialogFragment
115115 private StoredDirectoryHelper mainStorageVideo = null ;
116116 private DownloadManager downloadManager = null ;
117117 private ActionMenuItemView okButton = null ;
118- private Context context ;
118+ private Context context = null ;
119119 private boolean askForSavePath ;
120120
121121 private AudioTrackAdapter audioTrackAdapter ;
@@ -209,6 +209,8 @@ public void onCreate(@Nullable final Bundle savedInstanceState) {
209209 return ;
210210 }
211211
212+ // context will remain null if dismiss() was called above, allowing to check whether the
213+ // dialog is being dismissed in onViewCreated()
212214 context = getContext ();
213215
214216 setStyle (STYLE_NO_TITLE , ThemeHelper .getDialogTheme (context ));
@@ -293,6 +295,9 @@ public void onViewCreated(@NonNull final View view,
293295 @ Nullable final Bundle savedInstanceState ) {
294296 super .onViewCreated (view , savedInstanceState );
295297 dialogBinding = DownloadDialogBinding .bind (view );
298+ if (context == null ) {
299+ return ; // the dialog is being dismissed, see the call to dismiss() in onCreate()
300+ }
296301
297302 dialogBinding .fileName .setText (FilenameUtils .createFilename (getContext (),
298303 currentInfo .getName ()));
You can’t perform that action at this time.
0 commit comments