Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ object ImportHelper {
*/
@OptIn(ExperimentalSerializationApi::class)
suspend fun exportSubscriptions(activity: Activity, uri: Uri, importFormat: ImportFormat) {
val token = PreferenceHelper.getToken()
val subs = SubscriptionHelper.getSubscriptions()

when (importFormat) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import androidx.core.view.updatePadding
import androidx.recyclerview.widget.RecyclerView
import com.github.libretube.R
import com.github.libretube.api.PlaylistsHelper
import com.github.libretube.api.obj.Playlists
import com.github.libretube.api.obj.StreamItem
import com.github.libretube.constants.IntentData
import com.github.libretube.databinding.VideoRowBinding
Expand Down Expand Up @@ -45,7 +46,8 @@ class PlaylistAdapter(
val originalFeed: MutableList<StreamItem>,
private val sortedFeed: MutableList<StreamItem>,
private val playlistId: String,
private val playlistType: PlaylistType
private val playlistType: PlaylistType,
private val onVideoClick: (StreamItem) -> Unit
) : RecyclerView.Adapter<PlaylistViewHolder>() {

private var visibleCount = minOf(20, sortedFeed.size)
Expand Down Expand Up @@ -92,7 +94,7 @@ class PlaylistAdapter(
thumbnailDuration.setFormattedDuration(streamItem.duration ?: -1, streamItem.isShort, streamItem.uploaded)

root.setOnClickListener {
NavigationHelper.navigateVideo(root.context, streamItem.url, playlistId)
onVideoClick(streamItem)
}

val activity = (root.context as BaseActivity)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import com.github.libretube.extensions.TAG
import com.github.libretube.extensions.ceilHalf
import com.github.libretube.extensions.dpToPx
import com.github.libretube.extensions.setOnDismissListener
import com.github.libretube.extensions.toID
import com.github.libretube.extensions.toastFromMainDispatcher
import com.github.libretube.helpers.ImageHelper
import com.github.libretube.helpers.NavigationHelper
Expand Down Expand Up @@ -206,17 +207,7 @@ class PlaylistFragment : DynamicLayoutManagerFragment(R.layout.fragment_playlist
binding.playAll.isGone = true
} else {
binding.playAll.setOnClickListener {
if (playlistFeed.isEmpty()) return@setOnClickListener

val sortedStreams = getSortedVideos()
PlayingQueue.setStreams(sortedStreams)

NavigationHelper.navigateVideo(
requireContext(),
sortedStreams.first().url,
playlistId = playlistId,
keepQueue = true
)
startVideoItemPlayback(getSortedVideos().first())
}
}

Expand All @@ -243,7 +234,8 @@ class PlaylistFragment : DynamicLayoutManagerFragment(R.layout.fragment_playlist
binding.bookmark.text = getString(R.string.shuffle)
binding.bookmark.setOnClickListener {
val queue = playlistFeed.shuffled()
PlayingQueue.add(*queue.toTypedArray())
PlayingQueue.setStreams(queue)

NavigationHelper.navigateVideo(
requireContext(),
queue.firstOrNull()?.url,
Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -324,7 +330,9 @@ class PlaylistFragment : DynamicLayoutManagerFragment(R.layout.fragment_playlist
videos.toMutableList(),
playlistId,
playlistType
)
) { streamItem ->
startVideoItemPlayback(streamItem)
}
// TODO make sure the adapter is set once in onViewCreated
binding.playlistRecView.adapter = playlistAdapter

Expand Down
Loading