|
10 | 10 |
|
11 | 11 | import androidx.annotation.NonNull; |
12 | 12 | import androidx.annotation.Nullable; |
| 13 | +import androidx.fragment.app.Fragment; |
13 | 14 | import androidx.preference.PreferenceManager; |
14 | 15 |
|
15 | 16 | import org.schabi.newpipe.R; |
|
18 | 19 | import org.schabi.newpipe.extractor.InfoItem; |
19 | 20 | import org.schabi.newpipe.extractor.ListExtractor; |
20 | 21 | import org.schabi.newpipe.extractor.stream.StreamInfo; |
| 22 | +import org.schabi.newpipe.extractor.stream.StreamInfoItem; |
21 | 23 | import org.schabi.newpipe.fragments.list.BaseListInfoFragment; |
22 | 24 | import org.schabi.newpipe.info_list.ItemViewMode; |
| 25 | +import org.schabi.newpipe.info_list.dialog.InfoItemDialog; |
23 | 26 | import org.schabi.newpipe.ktx.ViewUtils; |
24 | 27 |
|
25 | 28 | import java.io.Serializable; |
@@ -173,4 +176,33 @@ protected ItemViewMode getItemViewMode() { |
173 | 176 | } |
174 | 177 | return mode; |
175 | 178 | } |
| 179 | + |
| 180 | + @Override |
| 181 | + protected void showInfoItemDialog(final StreamInfoItem item) { |
| 182 | + try { |
| 183 | + final Fragment parentFragment = getParentFragment(); |
| 184 | + |
| 185 | + // Try and attach the InfoItemDialog to the parent fragment of the RelatedItemsFragment |
| 186 | + // so that its context is not lost when the RelatedItemsFragment is reinitialized. |
| 187 | + if (parentFragment != null) { |
| 188 | + new InfoItemDialog.Builder( |
| 189 | + parentFragment.getActivity(), |
| 190 | + parentFragment.getContext(), |
| 191 | + parentFragment, |
| 192 | + item |
| 193 | + ).create().show(); |
| 194 | + } else { |
| 195 | + new InfoItemDialog.Builder( |
| 196 | + getActivity(), |
| 197 | + getContext(), |
| 198 | + this, |
| 199 | + item) |
| 200 | + .create().show(); |
| 201 | + } |
| 202 | + |
| 203 | + } catch (final IllegalArgumentException e) { |
| 204 | + InfoItemDialog.Builder.reportErrorDuringInitialization(e, item); |
| 205 | + } |
| 206 | + } |
| 207 | + |
176 | 208 | } |
0 commit comments