@@ -73,6 +73,7 @@ import org.schabi.newpipe.ktx.slideUp
7373import org.schabi.newpipe.local.feed.item.StreamItem
7474import org.schabi.newpipe.local.feed.service.FeedLoadService
7575import org.schabi.newpipe.local.subscription.SubscriptionManager
76+ import org.schabi.newpipe.player.playqueue.SinglePlayQueue
7677import org.schabi.newpipe.ui.components.menu.LongPressAction
7778import org.schabi.newpipe.ui.components.menu.LongPressable
7879import org.schabi.newpipe.ui.components.menu.openLongPressMenuInActivity
@@ -384,7 +385,7 @@ class FeedFragment : BaseStateFragment<FeedState>() {
384385 private val listenerStreamItem = object : OnItemClickListener , OnItemLongClickListener {
385386 override fun onItemClick (item : Item <* >, view : View ) {
386387 if (item is StreamItem && ! isRefreshing) {
387- val stream = item.streamWithState. stream
388+ val stream = item.stream
388389 NavigationHelper .openVideoDetailFragment(
389390 requireContext(),
390391 fm,
@@ -401,9 +402,31 @@ class FeedFragment : BaseStateFragment<FeedState>() {
401402 if (item is StreamItem && ! isRefreshing) {
402403 openLongPressMenuInActivity(
403404 requireActivity(),
404- LongPressable .fromStreamEntity(item.streamWithState.stream),
405- // TODO queueFromHere: allow playing the whole feed starting from one stream
406- LongPressAction .fromStreamEntity(item.streamWithState.stream, null ),
405+ LongPressable .fromStreamEntity(item.stream),
406+ LongPressAction .fromStreamEntity(
407+ item = item.stream,
408+ queueFromHere = {
409+ val items = (viewModel.stateLiveData.value as ? FeedState .LoadedState )
410+ ?.items
411+
412+ if (items != null ) {
413+ val index = items.indexOf(item)
414+ if (index >= 0 ) {
415+ return @fromStreamEntity SinglePlayQueue (
416+ items.map { it.stream.toStreamInfoItem() },
417+ index
418+ )
419+ }
420+ }
421+
422+ // when long-pressing on an item the state should be LoadedState and the
423+ // item list should contain the long-pressed item, so the following
424+ // statement should be unreachable, but let's return a SinglePlayQueue
425+ // just in case
426+ Log .w(TAG , " Could not get full list of items on long press" )
427+ return @fromStreamEntity SinglePlayQueue (item.stream.toStreamInfoItem())
428+ },
429+ ),
407430 )
408431 return true
409432 }
@@ -575,7 +598,7 @@ class FeedFragment : BaseStateFragment<FeedState>() {
575598 }
576599 if (doCheck) {
577600 // If the uploadDate is null or true we should highlight the item
578- if (item.streamWithState. stream.uploadDate?.isAfter(updateTime) != false ) {
601+ if (item.stream.uploadDate?.isAfter(updateTime) != false ) {
579602 highlightCount++
580603
581604 typeface = Typeface .DEFAULT_BOLD
0 commit comments