1
0
mirror of https://github.com/TeamNewPipe/NewPipe.git synced 2024-11-21 10:32:33 +01:00

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

View File

@ -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);