Merge pull request #3204 from Bnyro/master

Remove playlists from the playing queue
This commit is contained in:
Bnyro 2023-02-27 18:42:14 +01:00 committed by GitHub
commit edf32b078e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 12 additions and 24 deletions

View File

@ -4,7 +4,6 @@ import android.annotation.SuppressLint
import android.content.Context import android.content.Context
import android.text.format.DateUtils import android.text.format.DateUtils
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.core.view.updateLayoutParams import androidx.core.view.updateLayoutParams
import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.GridLayoutManager
@ -96,11 +95,6 @@ class VideosAdapter(
} }
} }
private fun hideItemView(holder: VideosViewHolder) {
holder.itemView.visibility = View.GONE
holder.itemView.layoutParams = RecyclerView.LayoutParams(0, 0)
}
@SuppressLint("SetTextI18n") @SuppressLint("SetTextI18n")
override fun onBindViewHolder(holder: VideosViewHolder, position: Int) { override fun onBindViewHolder(holder: VideosViewHolder, position: Int) {
val video = streamItems[position] val video = streamItems[position]
@ -108,12 +102,6 @@ class VideosAdapter(
val videoId = video.url?.toID() val videoId = video.url?.toID()
val videoName = video.title val videoName = video.title
// hide the item if there was an extractor error
if (video.title == null && video.type != "caught") {
hideItemView(holder)
return
}
videoId?.let { videoId?.let {
(holder.trendingRowBinding?.watchProgress ?: holder.videoRowBinding!!.watchProgress) (holder.trendingRowBinding?.watchProgress ?: holder.videoRowBinding!!.watchProgress)
.setWatchProgressLength(it, video.duration ?: 0L) .setWatchProgressLength(it, video.duration ?: 0L)

View File

@ -45,7 +45,7 @@ class ChannelFragment : Fragment() {
private var onScrollEnd: () -> Unit = {} private var onScrollEnd: () -> Unit = {}
val possibleTabs = listOf( private val possibleTabs = listOf(
ChannelTabs.Channels, ChannelTabs.Channels,
ChannelTabs.Playlists, ChannelTabs.Playlists,
ChannelTabs.Livestreams, ChannelTabs.Livestreams,

View File

@ -980,7 +980,7 @@ class PlayerFragment : Fragment(R.layout.fragment_player), OnlinePlayerOptions {
} }
} }
} }
initializeRelatedVideos(streams.relatedStreams) initializeRelatedVideos(streams.relatedStreams.filter { !it.title.isNullOrBlank() })
// set video description // set video description
val description = streams.description val description = streams.description

View File

@ -128,7 +128,7 @@ class PlaylistFragment : Fragment() {
binding.playlistInfo.text = binding.playlistInfo.text =
(if (response.uploader != null) response.uploader + TextUtils.SEPARATOR else "") + (if (response.uploader != null) response.uploader + TextUtils.SEPARATOR else "") +
getString(R.string.videoCount, response.videos.toString()) getString(R.string.videoCount, response.videos.toString())
// show playlist options // show playlist options
binding.optionsMenu.setOnClickListener { binding.optionsMenu.setOnClickListener {
@ -197,12 +197,12 @@ class PlaylistFragment : Fragment() {
val info = binding.playlistInfo.text.split(TextUtils.SEPARATOR) val info = binding.playlistInfo.text.split(TextUtils.SEPARATOR)
binding.playlistInfo.text = ( binding.playlistInfo.text = (
if (info.size == 2) { if (info.size == 2) {
info[0] + TextUtils.SEPARATOR info[0] + TextUtils.SEPARATOR
} else { } else {
"" ""
} }
) + getString( ) + getString(
R.string.videoCount, R.string.videoCount,
playlistAdapter!!.itemCount.toString() playlistAdapter!!.itemCount.toString()
) )

View File

@ -17,9 +17,9 @@ import com.github.libretube.helpers.LocaleHelper
import com.github.libretube.ui.activities.SettingsActivity import com.github.libretube.ui.activities.SettingsActivity
import com.github.libretube.ui.adapters.VideosAdapter import com.github.libretube.ui.adapters.VideosAdapter
import com.google.android.material.snackbar.Snackbar import com.google.android.material.snackbar.Snackbar
import java.io.IOException
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
import java.io.IOException
import retrofit2.HttpException import retrofit2.HttpException
class TrendsFragment : Fragment() { class TrendsFragment : Fragment() {

View File

@ -30,7 +30,7 @@ object PlayingQueue {
fun add(vararg streamItem: StreamItem) { fun add(vararg streamItem: StreamItem) {
for (stream in streamItem) { for (stream in streamItem) {
if (currentStream?.url?.toID() == stream.url?.toID()) continue if (currentStream?.url?.toID() == stream.url?.toID() || stream.title.isNullOrBlank()) continue
// remove if already present // remove if already present
queue.remove(stream) queue.remove(stream)
queue.add(stream) queue.add(stream)
@ -119,7 +119,7 @@ object PlayingQueue {
playlistNextPage!! playlistNextPage!!
).apply { ).apply {
add( add(
*this.relatedStreams.orEmpty().toTypedArray() *this.relatedStreams.toTypedArray()
) )
playlistNextPage = this.nextpage playlistNextPage = this.nextpage
} }