| 
1 | 1 | package org.schabi.newpipe.fragments.list.channel;  | 
2 | 2 | 
 
  | 
 | 3 | +import static org.schabi.newpipe.ui.components.menu.LongPressMenuKt.openLongPressMenuInActivity;  | 
 | 4 | + | 
3 | 5 | import android.os.Bundle;  | 
4 | 6 | import android.util.Log;  | 
5 | 7 | import android.view.LayoutInflater;  | 
 | 
26 | 28 | import org.schabi.newpipe.fragments.list.playlist.PlaylistControlViewHolder;  | 
27 | 29 | import org.schabi.newpipe.player.playqueue.ChannelTabPlayQueue;  | 
28 | 30 | import org.schabi.newpipe.player.playqueue.PlayQueue;  | 
 | 31 | +import org.schabi.newpipe.ui.components.menu.LongPressAction;  | 
 | 32 | +import org.schabi.newpipe.ui.components.menu.LongPressable;  | 
29 | 33 | import org.schabi.newpipe.ui.emptystate.EmptyStateUtil;  | 
30 | 34 | import org.schabi.newpipe.util.ChannelTabHelper;  | 
31 | 35 | import org.schabi.newpipe.util.ExtractorHelper;  | 
32 | 36 | import org.schabi.newpipe.util.PlayButtonHelper;  | 
33 | 37 | 
 
  | 
34 | 38 | import java.util.List;  | 
 | 39 | +import java.util.function.Function;  | 
35 | 40 | import java.util.function.Supplier;  | 
36 | 41 | import java.util.stream.Collectors;  | 
37 | 42 | 
 
  | 
@@ -165,13 +170,30 @@ public void handleResult(@NonNull final ChannelTabInfo result) {  | 
165 | 170 |     }  | 
166 | 171 | 
 
  | 
167 | 172 |     @Override  | 
168 |  | -    public PlayQueue getPlayQueue() {  | 
 | 173 | +    protected void showInfoItemDialog(final StreamInfoItem item) {  | 
 | 174 | +        openLongPressMenuInActivity(  | 
 | 175 | +                requireActivity(),  | 
 | 176 | +                LongPressable.fromStreamInfoItem(item),  | 
 | 177 | +                LongPressAction.fromStreamInfoItem(item, () -> getPlayQueueStartingAt(item))  | 
 | 178 | +        );  | 
 | 179 | +    }  | 
 | 180 | + | 
 | 181 | +    private PlayQueue getPlayQueueStartingAt(final StreamInfoItem infoItem) {  | 
 | 182 | +        return getPlayQueue(streamItems -> Math.max(streamItems.indexOf(infoItem), 0));  | 
 | 183 | +    }  | 
 | 184 | + | 
 | 185 | +    public PlayQueue getPlayQueue(final Function<List<StreamInfoItem>, Integer> index) {  | 
169 | 186 |         final List<StreamInfoItem> streamItems = infoListAdapter.getItemsList().stream()  | 
170 | 187 |                 .filter(StreamInfoItem.class::isInstance)  | 
171 | 188 |                 .map(StreamInfoItem.class::cast)  | 
172 | 189 |                 .collect(Collectors.toList());  | 
173 | 190 | 
 
  | 
174 | 191 |         return new ChannelTabPlayQueue(currentInfo.getServiceId(), tabHandler,  | 
175 |  | -                currentInfo.getNextPage(), streamItems, 0);  | 
 | 192 | +                currentInfo.getNextPage(), streamItems, index.apply(streamItems));  | 
 | 193 | +    }  | 
 | 194 | + | 
 | 195 | +    @Override  | 
 | 196 | +    public PlayQueue getPlayQueue() {  | 
 | 197 | +        return getPlayQueue(streamItems -> 0);  | 
176 | 198 |     }  | 
177 | 199 | }  | 
0 commit comments