Update app/src/main/java/org/schabi/newpipe/fragments/list/videos/RelatedItemsFragment.java

Co-authored-by: Tobi <TobiGr@users.noreply.github.com>
This commit is contained in:
rmtilde 2024-11-03 18:26:38 +11:00 committed by GitHub
parent 1996c1176c
commit 66ec596f67
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 10 additions and 16 deletions

View File

@ -179,30 +179,24 @@ public class RelatedItemsFragment extends BaseListInfoFragment<InfoItem, Related
@Override @Override
protected void showInfoItemDialog(final StreamInfoItem item) { protected void showInfoItemDialog(final StreamInfoItem item) {
try {
final Fragment parentFragment = getParentFragment();
// Try and attach the InfoItemDialog to the parent fragment of the RelatedItemsFragment // Try and attach the InfoItemDialog to the parent fragment of the RelatedItemsFragment
// so that its context is not lost when the RelatedItemsFragment is reinitialized. // 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) { if (parentFragment != null) {
try {
new InfoItemDialog.Builder( new InfoItemDialog.Builder(
parentFragment.getActivity(), parentFragment.getActivity(),
parentFragment.getContext(), parentFragment.getContext(),
parentFragment, parentFragment,
item item
).create().show(); ).create().show();
} else {
new InfoItemDialog.Builder(
getActivity(),
getContext(),
this,
item)
.create().show();
}
} catch (final IllegalArgumentException e) { } catch (final IllegalArgumentException e) {
InfoItemDialog.Builder.reportErrorDuringInitialization(e, item); InfoItemDialog.Builder.reportErrorDuringInitialization(e, item);
} }
} else {
super.showInfoItemDialog(item);
}
} }
} }