Merge pull request #3905 from Bnyro/master

Hide upload date for live videos
This commit is contained in:
Bnyro 2023-06-03 11:36:41 +02:00 committed by GitHub
commit 7e5f20610b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 5 deletions

View File

@ -76,7 +76,7 @@ class SearchAdapter : ListAdapter<ContentItem, SearchViewHolder>(SearchCallback)
// 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 uploadDate = item.uploaded?.let {
val uploadDate = item.uploaded?.takeIf { it > 0 }?.let {
" ${TextUtils.SEPARATOR} ${TextUtils.formatRelativeDate(root.context, it)}"
}.orEmpty()
videoInfo.text = root.context.getString(

View File

@ -77,6 +77,7 @@ class VideosAdapter(
viewType == CAUGHT_UP_TYPE -> VideosViewHolder(
AllCaughtUpRowBinding.inflate(layoutInflater, parent, false),
)
forceMode in listOf(
ForceMode.TRENDING,
ForceMode.RELATED,
@ -84,13 +85,16 @@ class VideosAdapter(
) -> VideosViewHolder(
TrendingRowBinding.inflate(layoutInflater, parent, false),
)
forceMode == ForceMode.CHANNEL -> VideosViewHolder(
VideoRowBinding.inflate(layoutInflater, parent, false),
)
PreferenceHelper.getBoolean(
PreferenceKeys.ALTERNATIVE_VIDEOS_LAYOUT,
false,
) -> VideosViewHolder(VideoRowBinding.inflate(layoutInflater, parent, false))
else -> VideosViewHolder(TrendingRowBinding.inflate(layoutInflater, parent, false))
}
}
@ -107,6 +111,12 @@ class VideosAdapter(
.setWatchProgressLength(it, video.duration ?: 0L)
}
val context = (holder.videoRowBinding ?: holder.trendingRowBinding
?: holder.allCaughtUpBinding)!!.root.context
val uploadDate =
video.uploaded?.takeIf { it > 0 }?.let { TextUtils.formatRelativeDate(context, it) }
?.toString().orEmpty()
// Trending layout
holder.trendingRowBinding?.apply {
// set a fixed width for better visuals
@ -123,7 +133,7 @@ class VideosAdapter(
R.string.trending_views,
video.uploaderName,
video.views.formatShort(),
video.uploaded?.let { TextUtils.formatRelativeDate(root.context, it) },
uploadDate,
)
video.duration?.let { thumbnailDuration.setFormattedDuration(it, video.isShort) }
channelImage.setOnClickListener {
@ -154,9 +164,7 @@ class VideosAdapter(
videoInfo.text = root.context.getString(
R.string.normal_views,
video.views.formatShort(),
video.uploaded?.let {
TextUtils.SEPARATOR + TextUtils.formatRelativeDate(root.context, it)
},
uploadDate,
)
thumbnailDuration.text = video.duration?.let { DateUtils.formatElapsedTime(it) }