mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-27 23:40:33 +05:30
Merge pull request #7286 from Bnyro/master
fix: video sort order not preserved when starting video from sorted playlist
This commit is contained in:
commit
1d0ce3bdda
@ -105,7 +105,6 @@ object ImportHelper {
|
|||||||
*/
|
*/
|
||||||
@OptIn(ExperimentalSerializationApi::class)
|
@OptIn(ExperimentalSerializationApi::class)
|
||||||
suspend fun exportSubscriptions(activity: Activity, uri: Uri, importFormat: ImportFormat) {
|
suspend fun exportSubscriptions(activity: Activity, uri: Uri, importFormat: ImportFormat) {
|
||||||
val token = PreferenceHelper.getToken()
|
|
||||||
val subs = SubscriptionHelper.getSubscriptions()
|
val subs = SubscriptionHelper.getSubscriptions()
|
||||||
|
|
||||||
when (importFormat) {
|
when (importFormat) {
|
||||||
|
@ -13,6 +13,7 @@ import androidx.core.view.updatePadding
|
|||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.github.libretube.R
|
import com.github.libretube.R
|
||||||
import com.github.libretube.api.PlaylistsHelper
|
import com.github.libretube.api.PlaylistsHelper
|
||||||
|
import com.github.libretube.api.obj.Playlists
|
||||||
import com.github.libretube.api.obj.StreamItem
|
import com.github.libretube.api.obj.StreamItem
|
||||||
import com.github.libretube.constants.IntentData
|
import com.github.libretube.constants.IntentData
|
||||||
import com.github.libretube.databinding.VideoRowBinding
|
import com.github.libretube.databinding.VideoRowBinding
|
||||||
@ -45,7 +46,8 @@ class PlaylistAdapter(
|
|||||||
val originalFeed: MutableList<StreamItem>,
|
val originalFeed: MutableList<StreamItem>,
|
||||||
private val sortedFeed: MutableList<StreamItem>,
|
private val sortedFeed: MutableList<StreamItem>,
|
||||||
private val playlistId: String,
|
private val playlistId: String,
|
||||||
private val playlistType: PlaylistType
|
private val playlistType: PlaylistType,
|
||||||
|
private val onVideoClick: (StreamItem) -> Unit
|
||||||
) : RecyclerView.Adapter<PlaylistViewHolder>() {
|
) : RecyclerView.Adapter<PlaylistViewHolder>() {
|
||||||
|
|
||||||
private var visibleCount = minOf(20, sortedFeed.size)
|
private var visibleCount = minOf(20, sortedFeed.size)
|
||||||
@ -92,7 +94,7 @@ class PlaylistAdapter(
|
|||||||
thumbnailDuration.setFormattedDuration(streamItem.duration ?: -1, streamItem.isShort, streamItem.uploaded)
|
thumbnailDuration.setFormattedDuration(streamItem.duration ?: -1, streamItem.isShort, streamItem.uploaded)
|
||||||
|
|
||||||
root.setOnClickListener {
|
root.setOnClickListener {
|
||||||
NavigationHelper.navigateVideo(root.context, streamItem.url, playlistId)
|
onVideoClick(streamItem)
|
||||||
}
|
}
|
||||||
|
|
||||||
val activity = (root.context as BaseActivity)
|
val activity = (root.context as BaseActivity)
|
||||||
|
@ -32,6 +32,7 @@ import com.github.libretube.extensions.TAG
|
|||||||
import com.github.libretube.extensions.ceilHalf
|
import com.github.libretube.extensions.ceilHalf
|
||||||
import com.github.libretube.extensions.dpToPx
|
import com.github.libretube.extensions.dpToPx
|
||||||
import com.github.libretube.extensions.setOnDismissListener
|
import com.github.libretube.extensions.setOnDismissListener
|
||||||
|
import com.github.libretube.extensions.toID
|
||||||
import com.github.libretube.extensions.toastFromMainDispatcher
|
import com.github.libretube.extensions.toastFromMainDispatcher
|
||||||
import com.github.libretube.helpers.ImageHelper
|
import com.github.libretube.helpers.ImageHelper
|
||||||
import com.github.libretube.helpers.NavigationHelper
|
import com.github.libretube.helpers.NavigationHelper
|
||||||
@ -206,17 +207,7 @@ class PlaylistFragment : DynamicLayoutManagerFragment(R.layout.fragment_playlist
|
|||||||
binding.playAll.isGone = true
|
binding.playAll.isGone = true
|
||||||
} else {
|
} else {
|
||||||
binding.playAll.setOnClickListener {
|
binding.playAll.setOnClickListener {
|
||||||
if (playlistFeed.isEmpty()) return@setOnClickListener
|
startVideoItemPlayback(getSortedVideos().first())
|
||||||
|
|
||||||
val sortedStreams = getSortedVideos()
|
|
||||||
PlayingQueue.setStreams(sortedStreams)
|
|
||||||
|
|
||||||
NavigationHelper.navigateVideo(
|
|
||||||
requireContext(),
|
|
||||||
sortedStreams.first().url,
|
|
||||||
playlistId = playlistId,
|
|
||||||
keepQueue = true
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -243,7 +234,8 @@ class PlaylistFragment : DynamicLayoutManagerFragment(R.layout.fragment_playlist
|
|||||||
binding.bookmark.text = getString(R.string.shuffle)
|
binding.bookmark.text = getString(R.string.shuffle)
|
||||||
binding.bookmark.setOnClickListener {
|
binding.bookmark.setOnClickListener {
|
||||||
val queue = playlistFeed.shuffled()
|
val queue = playlistFeed.shuffled()
|
||||||
PlayingQueue.add(*queue.toTypedArray())
|
PlayingQueue.setStreams(queue)
|
||||||
|
|
||||||
NavigationHelper.navigateVideo(
|
NavigationHelper.navigateVideo(
|
||||||
requireContext(),
|
requireContext(),
|
||||||
queue.firstOrNull()?.url,
|
queue.firstOrNull()?.url,
|
||||||
@ -276,6 +268,20 @@ class PlaylistFragment : DynamicLayoutManagerFragment(R.layout.fragment_playlist
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun startVideoItemPlayback(streamItem: StreamItem) {
|
||||||
|
if (playlistFeed.isEmpty()) return
|
||||||
|
|
||||||
|
val sortedStreams = getSortedVideos()
|
||||||
|
PlayingQueue.setStreams(sortedStreams)
|
||||||
|
|
||||||
|
NavigationHelper.navigateVideo(
|
||||||
|
requireContext(),
|
||||||
|
streamItem.url?.toID(),
|
||||||
|
playlistId = playlistId,
|
||||||
|
keepQueue = true
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If the playlist is bookmarked, update its content if modified by the uploader
|
* If the playlist is bookmarked, update its content if modified by the uploader
|
||||||
*/
|
*/
|
||||||
@ -324,7 +330,9 @@ class PlaylistFragment : DynamicLayoutManagerFragment(R.layout.fragment_playlist
|
|||||||
videos.toMutableList(),
|
videos.toMutableList(),
|
||||||
playlistId,
|
playlistId,
|
||||||
playlistType
|
playlistType
|
||||||
)
|
) { streamItem ->
|
||||||
|
startVideoItemPlayback(streamItem)
|
||||||
|
}
|
||||||
// TODO make sure the adapter is set once in onViewCreated
|
// TODO make sure the adapter is set once in onViewCreated
|
||||||
binding.playlistRecView.adapter = playlistAdapter
|
binding.playlistRecView.adapter = playlistAdapter
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user