@@ -71,6 +71,7 @@ import org.schabi.newpipe.ktx.slideUp
7171import org.schabi.newpipe.local.feed.item.StreamItem
7272import org.schabi.newpipe.local.feed.service.FeedLoadService
7373import org.schabi.newpipe.local.subscription.SubscriptionManager
74+ import org.schabi.newpipe.player.playqueue.SinglePlayQueue
7475import org.schabi.newpipe.ui.components.menu.LongPressAction
7576import org.schabi.newpipe.ui.components.menu.LongPressable
7677import org.schabi.newpipe.ui.components.menu.openLongPressMenuInActivity
@@ -382,7 +383,7 @@ class FeedFragment : BaseStateFragment<FeedState>() {
382383 private val listenerStreamItem = object : OnItemClickListener , OnItemLongClickListener {
383384 override fun onItemClick (item : Item <* >, view : View ) {
384385 if (item is StreamItem && ! isRefreshing) {
385- val stream = item.streamWithState. stream
386+ val stream = item.stream
386387 NavigationHelper .openVideoDetailFragment(
387388 requireContext(), fm,
388389 stream.serviceId, stream.url, stream.title, null , false
@@ -394,9 +395,31 @@ class FeedFragment : BaseStateFragment<FeedState>() {
394395 if (item is StreamItem && ! isRefreshing) {
395396 openLongPressMenuInActivity(
396397 requireActivity(),
397- LongPressable .fromStreamEntity(item.streamWithState.stream),
398- // TODO queueFromHere: allow playing the whole feed starting from one stream
399- LongPressAction .fromStreamEntity(item.streamWithState.stream, null ),
398+ LongPressable .fromStreamEntity(item.stream),
399+ LongPressAction .fromStreamEntity(
400+ item = item.stream,
401+ queueFromHere = {
402+ val items = (viewModel.stateLiveData.value as ? FeedState .LoadedState )
403+ ?.items
404+
405+ if (items != null ) {
406+ val index = items.indexOf(item)
407+ if (index >= 0 ) {
408+ return @fromStreamEntity SinglePlayQueue (
409+ items.map { it.stream.toStreamInfoItem() },
410+ index
411+ )
412+ }
413+ }
414+
415+ // when long-pressing on an item the state should be LoadedState and the
416+ // item list should contain the long-pressed item, so the following
417+ // statement should be unreachable, but let's return a SinglePlayQueue
418+ // just in case
419+ Log .w(TAG , " Could not get full list of items on long press" )
420+ return @fromStreamEntity SinglePlayQueue (item.stream.toStreamInfoItem())
421+ },
422+ ),
400423 )
401424 return true
402425 }
@@ -566,7 +589,7 @@ class FeedFragment : BaseStateFragment<FeedState>() {
566589 }
567590 if (doCheck) {
568591 // If the uploadDate is null or true we should highlight the item
569- if (item.streamWithState. stream.uploadDate?.isAfter(updateTime) != false ) {
592+ if (item.stream.uploadDate?.isAfter(updateTime) != false ) {
570593 highlightCount++
571594
572595 typeface = Typeface .DEFAULT_BOLD
0 commit comments