diff --git a/app/src/main/java/org/schabi/newpipe/download/DownloadDialog.java b/app/src/main/java/org/schabi/newpipe/download/DownloadDialog.java index 42b2c695c..2975fe43a 100644 --- a/app/src/main/java/org/schabi/newpipe/download/DownloadDialog.java +++ b/app/src/main/java/org/schabi/newpipe/download/DownloadDialog.java @@ -159,7 +159,7 @@ public class DownloadDialog extends DialogFragment * @param context the context to use just to obtain preferences and strings (will not be stored) * @param info the info from which to obtain downloadable streams and other info (e.g. title) */ - public DownloadDialog(final Context context, @NonNull final StreamInfo info) { + public DownloadDialog(@NonNull final Context context, @NonNull final StreamInfo info) { this.currentInfo = info; // TODO: Adapt this code when the downloader support other types of stream deliveries diff --git a/app/src/main/java/org/schabi/newpipe/info_list/dialog/StreamDialogDefaultEntry.java b/app/src/main/java/org/schabi/newpipe/info_list/dialog/StreamDialogDefaultEntry.java index 1265e9767..c67880d0e 100644 --- a/app/src/main/java/org/schabi/newpipe/info_list/dialog/StreamDialogDefaultEntry.java +++ b/app/src/main/java/org/schabi/newpipe/info_list/dialog/StreamDialogDefaultEntry.java @@ -112,12 +112,19 @@ public enum StreamDialogDefaultEntry { ShareUtils.shareText(fragment.requireContext(), item.getName(), item.getUrl(), item.getThumbnailUrl())), + /** + * Opens a {@link DownloadDialog} after fetching some stream info. + * If the user quits the current fragment, it will not open a DownloadDialog. + */ DOWNLOAD(R.string.download, (fragment, item) -> fetchStreamInfoAndSaveToDatabase(fragment.requireContext(), item.getServiceId(), item.getUrl(), info -> { - final DownloadDialog downloadDialog = - new DownloadDialog(fragment.requireContext(), info); - downloadDialog.show(fragment.getChildFragmentManager(), "downloadDialog"); + if (fragment.getContext() != null) { + final DownloadDialog downloadDialog = + new DownloadDialog(fragment.requireContext(), info); + downloadDialog.show(fragment.getChildFragmentManager(), + "downloadDialog"); + } }) ),