From 781a69d60d3a64fb67f319a4900e161714557a6d Mon Sep 17 00:00:00 2001 From: u7310752 Date: Wed, 16 Oct 2024 20:52:43 +1100 Subject: [PATCH 1/3] Chanegd related videos enqueue modal to attach to parent fragment instead --- .../list/videos/RelatedItemsFragment.java | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/videos/RelatedItemsFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/videos/RelatedItemsFragment.java index e46937ede3d..a7ca549fb0f 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/videos/RelatedItemsFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/videos/RelatedItemsFragment.java @@ -10,6 +10,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.fragment.app.Fragment; import androidx.preference.PreferenceManager; import org.schabi.newpipe.R; @@ -18,8 +19,10 @@ import org.schabi.newpipe.extractor.InfoItem; import org.schabi.newpipe.extractor.ListExtractor; import org.schabi.newpipe.extractor.stream.StreamInfo; +import org.schabi.newpipe.extractor.stream.StreamInfoItem; import org.schabi.newpipe.fragments.list.BaseListInfoFragment; import org.schabi.newpipe.info_list.ItemViewMode; +import org.schabi.newpipe.info_list.dialog.InfoItemDialog; import org.schabi.newpipe.ktx.ViewUtils; import java.io.Serializable; @@ -173,4 +176,30 @@ protected ItemViewMode getItemViewMode() { } return mode; } + + @Override + protected void showInfoItemDialog(final StreamInfoItem item) { + try { + final Fragment parentFragment = getParentFragment(); + if (parentFragment != null) { + new InfoItemDialog.Builder( + parentFragment.getActivity(), + parentFragment.getContext(), + parentFragment, + item + ).create().show(); + } else { + new InfoItemDialog.Builder( + getActivity(), + getContext(), + this, + item) + .create().show(); + } + + } catch (final IllegalArgumentException e) { + InfoItemDialog.Builder.reportErrorDuringInitialization(e, item); + } + } + } From b14f65804d811d8ee311fcb79694cf404741cda7 Mon Sep 17 00:00:00 2001 From: rmtilde Date: Wed, 16 Oct 2024 23:58:32 +1100 Subject: [PATCH 2/3] Added comments to explain changes --- .../newpipe/fragments/list/videos/RelatedItemsFragment.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/videos/RelatedItemsFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/videos/RelatedItemsFragment.java index a7ca549fb0f..6dc9a0cb484 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/videos/RelatedItemsFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/videos/RelatedItemsFragment.java @@ -181,6 +181,9 @@ protected ItemViewMode getItemViewMode() { protected void showInfoItemDialog(final StreamInfoItem item) { try { final Fragment parentFragment = getParentFragment(); + + // Try and attach the InfoItemDialog to the parent fragment of the RelatedItemsFragment + // so that its context is not lost when the RelatedItemsFragment is reinitialized. if (parentFragment != null) { new InfoItemDialog.Builder( parentFragment.getActivity(), From 66ec596f67755cdd7d6fdd10a705f0d86eca5b7a Mon Sep 17 00:00:00 2001 From: rmtilde Date: Sun, 3 Nov 2024 18:26:38 +1100 Subject: [PATCH 3/3] Update app/src/main/java/org/schabi/newpipe/fragments/list/videos/RelatedItemsFragment.java Co-authored-by: Tobi --- .../list/videos/RelatedItemsFragment.java | 26 +++++++------------ 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/videos/RelatedItemsFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/videos/RelatedItemsFragment.java index 6dc9a0cb484..39d145b1d07 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/videos/RelatedItemsFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/videos/RelatedItemsFragment.java @@ -179,29 +179,23 @@ protected ItemViewMode getItemViewMode() { @Override protected void showInfoItemDialog(final StreamInfoItem item) { - try { - final Fragment parentFragment = getParentFragment(); - - // Try and attach the InfoItemDialog to the parent fragment of the RelatedItemsFragment - // so that its context is not lost when the RelatedItemsFragment is reinitialized. - if (parentFragment != null) { + // Try and attach the InfoItemDialog to the parent fragment of the RelatedItemsFragment + // so that its context is not lost when the RelatedItemsFragment is reinitialized, + // e.g. when a new stream is loaded in a parent VideoDetailFragment. + final Fragment parentFragment = getParentFragment(); + if (parentFragment != null) { + try { new InfoItemDialog.Builder( parentFragment.getActivity(), parentFragment.getContext(), parentFragment, item ).create().show(); - } else { - new InfoItemDialog.Builder( - getActivity(), - getContext(), - this, - item) - .create().show(); + } catch (final IllegalArgumentException e) { + InfoItemDialog.Builder.reportErrorDuringInitialization(e, item); } - - } catch (final IllegalArgumentException e) { - InfoItemDialog.Builder.reportErrorDuringInitialization(e, item); + } else { + super.showInfoItemDialog(item); } }