Skip to content

Commit

Permalink
Merge pull request #11621 from u7656655/fixing-ui-crash-11468
Browse files Browse the repository at this point in the history
Fix UI crash when user navigates away before the download dialog appears
  • Loading branch information
TobiGr authored Nov 2, 2024
2 parents 64ad05d + f4baf46 commit 90404a2
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,10 @@ public enum StreamDialogDefaultEntry {
DOWNLOAD(R.string.download, (fragment, item) ->
fetchStreamInfoAndSaveToDatabase(fragment.requireContext(), item.getServiceId(),
item.getUrl(), info -> {
if (fragment.getContext() != null) {
// Ensure the fragment is attached and its state hasn't been saved to avoid
// showing dialog during lifecycle changes or when the activity is paused,
// e.g. by selecting the download option and opening a different fragment.
if (fragment.isAdded() && !fragment.isStateSaved()) {
final DownloadDialog downloadDialog =
new DownloadDialog(fragment.requireContext(), info);
downloadDialog.show(fragment.getChildFragmentManager(),
Expand Down

0 comments on commit 90404a2

Please sign in to comment.