From 37cb75b9f008e412df837ac29ca3f8aa41e20f07 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Wed, 11 Oct 2023 09:11:15 +0200 Subject: [PATCH] fix: remove view count from continue watching section --- .../libretube/ui/adapters/VideosAdapter.kt | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/com/github/libretube/ui/adapters/VideosAdapter.kt b/app/src/main/java/com/github/libretube/ui/adapters/VideosAdapter.kt index f22ad24f3..ce8ec06c7 100644 --- a/app/src/main/java/com/github/libretube/ui/adapters/VideosAdapter.kt +++ b/app/src/main/java/com/github/libretube/ui/adapters/VideosAdapter.kt @@ -113,14 +113,15 @@ class VideosAdapter( } val context = ( - holder.videoRowBinding ?: holder.trendingRowBinding + holder.videoRowBinding ?: holder.trendingRowBinding ?: holder.allCaughtUpBinding - )!!.root.context + )!!.root.context val activity = (context as BaseActivity) val fragmentManager = activity.supportFragmentManager - val uploadDate = - video.uploaded.takeIf { it > 0 }?.let { TextUtils.formatRelativeDate(context, it) } + val uploadDateStr = video.uploaded.takeIf { it > 0 } + ?.let { TextUtils.formatRelativeDate(context, it) } + ?.toString() // Trending layout holder.trendingRowBinding?.apply { @@ -134,12 +135,16 @@ class VideosAdapter( } textViewTitle.text = video.title - textViewChannel.text = root.context.getString( - R.string.trending_views, - video.uploaderName, - video.views.formatShort(), - uploadDate?.toString().orEmpty() - ) + textViewChannel.text = if ((video.views ?: 0L) > 0L) { + root.context.getString( + R.string.trending_views, + video.uploaderName, + video.views.formatShort(), + uploadDateStr + ) + } else { + "${video.uploaderName} ${TextUtils.SEPARATOR} $uploadDateStr" + } video.duration?.let { thumbnailDuration.setFormattedDuration(it, video.isShort) } channelImage.setOnClickListener { NavigationHelper.navigateChannel(root.context, video.uploaderUrl) @@ -171,7 +176,7 @@ class VideosAdapter( videoInfo.text = root.context.getString( R.string.normal_views, video.views.formatShort(), - uploadDate?.let { " ${TextUtils.SEPARATOR} $it" } + uploadDateStr?.let { " ${TextUtils.SEPARATOR} $it" } ) thumbnailDuration.text = video.duration?.let { DateUtils.formatElapsedTime(it) }