Hide channel name in channel tabs for shorts and livestreams

This commit is contained in:
Bnyro 2023-06-19 15:02:57 +02:00
parent 274a1baca6
commit 3d55aba2d1
2 changed files with 16 additions and 14 deletions

View File

@ -24,7 +24,9 @@ import com.github.libretube.ui.sheets.VideoOptionsBottomSheet
import com.github.libretube.ui.viewholders.SearchViewHolder import com.github.libretube.ui.viewholders.SearchViewHolder
import com.github.libretube.util.TextUtils import com.github.libretube.util.TextUtils
class SearchAdapter : ListAdapter<ContentItem, SearchViewHolder>(SearchCallback) { class SearchAdapter(
private val isChannelAdapter: Boolean = false
) : ListAdapter<ContentItem, SearchViewHolder>(SearchCallback) {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): SearchViewHolder { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): SearchViewHolder {
val layoutInflater = LayoutInflater.from(parent.context) val layoutInflater = LayoutInflater.from(parent.context)
@ -71,10 +73,7 @@ class SearchAdapter : ListAdapter<ContentItem, SearchViewHolder>(SearchCallback)
binding.apply { binding.apply {
ImageHelper.loadImage(item.thumbnail, thumbnail) ImageHelper.loadImage(item.thumbnail, thumbnail)
thumbnailDuration.setFormattedDuration(item.duration, item.isShort) thumbnailDuration.setFormattedDuration(item.duration, item.isShort)
ImageHelper.loadImage(item.uploaderAvatar, channelImage)
videoTitle.text = item.title videoTitle.text = item.title
// only display the additional info if not in a channel tab
if (item.isShort != true || item.uploaderAvatar != null) {
val viewsString = item.views.takeIf { it != -1L }?.formatShort().orEmpty() val viewsString = item.views.takeIf { it != -1L }?.formatShort().orEmpty()
val uploadDate = item.uploaded?.takeIf { it > 0 }?.let { val uploadDate = item.uploaded?.takeIf { it > 0 }?.let {
" ${TextUtils.SEPARATOR} ${TextUtils.formatRelativeDate(root.context, it)}" " ${TextUtils.SEPARATOR} ${TextUtils.formatRelativeDate(root.context, it)}"
@ -84,7 +83,10 @@ class SearchAdapter : ListAdapter<ContentItem, SearchViewHolder>(SearchCallback)
viewsString, viewsString,
uploadDate, uploadDate,
) )
// only display channel related info if not in a channel tab
if (!isChannelAdapter) {
channelName.text = item.uploaderName channelName.text = item.uploaderName
ImageHelper.loadImage(item.uploaderAvatar, channelImage)
} }
root.setOnClickListener { root.setOnClickListener {
NavigationHelper.navigateVideo(root.context, item.url) NavigationHelper.navigateVideo(root.context, item.url)

View File

@ -245,7 +245,7 @@ class ChannelFragment : Fragment() {
} }
val binding = _binding ?: return@launch val binding = _binding ?: return@launch
val adapter = SearchAdapter() val adapter = SearchAdapter(true)
binding.channelRecView.adapter = adapter binding.channelRecView.adapter = adapter
adapter.submitList(response.content) adapter.submitList(response.content)