Skip to content

Commit 90404a2

Browse files
authored
Merge pull request #11621 from u7656655/fixing-ui-crash-11468
Fix UI crash when user navigates away before the download dialog appears
2 parents 64ad05d + f4baf46 commit 90404a2

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

app/src/main/java/org/schabi/newpipe/info_list/dialog/StreamDialogDefaultEntry.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,10 @@ public enum StreamDialogDefaultEntry {
113113
DOWNLOAD(R.string.download, (fragment, item) ->
114114
fetchStreamInfoAndSaveToDatabase(fragment.requireContext(), item.getServiceId(),
115115
item.getUrl(), info -> {
116-
if (fragment.getContext() != null) {
116+
// Ensure the fragment is attached and its state hasn't been saved to avoid
117+
// showing dialog during lifecycle changes or when the activity is paused,
118+
// e.g. by selecting the download option and opening a different fragment.
119+
if (fragment.isAdded() && !fragment.isStateSaved()) {
117120
final DownloadDialog downloadDialog =
118121
new DownloadDialog(fragment.requireContext(), info);
119122
downloadDialog.show(fragment.getChildFragmentManager(),

0 commit comments

Comments
 (0)