Add comment for fragment lifecycle checks before showing DownloadDialog

This commit is contained in:
Elva Kang 2024-10-24 11:47:23 +11:00
parent 63bc982cb2
commit 1ed4928f40
1 changed files with 2 additions and 0 deletions

View File

@ -113,6 +113,8 @@ public enum StreamDialogDefaultEntry {
DOWNLOAD(R.string.download, (fragment, item) -> DOWNLOAD(R.string.download, (fragment, item) ->
fetchStreamInfoAndSaveToDatabase(fragment.requireContext(), item.getServiceId(), fetchStreamInfoAndSaveToDatabase(fragment.requireContext(), item.getServiceId(),
item.getUrl(), info -> { 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()) { if (fragment.isAdded() && !fragment.isStateSaved()) {
final DownloadDialog downloadDialog = final DownloadDialog downloadDialog =
new DownloadDialog(fragment.requireContext(), info); new DownloadDialog(fragment.requireContext(), info);