Merge pull request #4047 from Bnyro/master

Hide channel name in channel tabs for shorts and livestreams
This commit is contained in:
Bnyro 2023-06-19 15:02:38 +02:00 committed by GitHub
commit ec7ad77200
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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,20 +73,20 @@ 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 val viewsString = item.views.takeIf { it != -1L }?.formatShort().orEmpty()
if (item.isShort != true || item.uploaderAvatar != null) { val uploadDate = item.uploaded?.takeIf { it > 0 }?.let {
val viewsString = item.views.takeIf { it != -1L }?.formatShort().orEmpty() " ${TextUtils.SEPARATOR} ${TextUtils.formatRelativeDate(root.context, it)}"
val uploadDate = item.uploaded?.takeIf { it > 0 }?.let { }.orEmpty()
" ${TextUtils.SEPARATOR} ${TextUtils.formatRelativeDate(root.context, it)}" videoInfo.text = root.context.getString(
}.orEmpty() R.string.normal_views,
videoInfo.text = root.context.getString( viewsString,
R.string.normal_views, uploadDate,
viewsString, )
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)