Skip to content

Commit

Permalink
Update app/src/main/java/org/schabi/newpipe/fragments/list/videos/Rel…
Browse files Browse the repository at this point in the history
…atedItemsFragment.java

Co-authored-by: Tobi <[email protected]>
  • Loading branch information
rmtilde and TobiGr authored Nov 3, 2024
1 parent 1996c11 commit 66ec596
Showing 1 changed file with 10 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down

0 comments on commit 66ec596

Please sign in to comment.