From 1ed4928f40f2e5297e265a1f732f7ee624b71b89 Mon Sep 17 00:00:00 2001 From: Elva Kang Date: Thu, 24 Oct 2024 11:47:23 +1100 Subject: [PATCH] Add comment for fragment lifecycle checks before showing DownloadDialog --- .../newpipe/info_list/dialog/StreamDialogDefaultEntry.java | 2 ++ 1 file changed, 2 insertions(+) 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 6b9e38b98..a486bdc3a 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 @@ -113,6 +113,8 @@ public enum StreamDialogDefaultEntry { DOWNLOAD(R.string.download, (fragment, item) -> fetchStreamInfoAndSaveToDatabase(fragment.requireContext(), item.getServiceId(), item.getUrl(), info -> { + // Ensure the fragment is attached and its state hasn't been saved to avoid + // showing the dialog during lifecycle changes or when the activity is paused. if (fragment.isAdded() && !fragment.isStateSaved()) { final DownloadDialog downloadDialog = new DownloadDialog(fragment.requireContext(), info);