diff --git a/app/src/main/java/com/github/libretube/ui/adapters/SearchAdapter.kt b/app/src/main/java/com/github/libretube/ui/adapters/SearchAdapter.kt index 6d24ffc20..3316291b0 100644 --- a/app/src/main/java/com/github/libretube/ui/adapters/SearchAdapter.kt +++ b/app/src/main/java/com/github/libretube/ui/adapters/SearchAdapter.kt @@ -76,7 +76,7 @@ class SearchAdapter : ListAdapter(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( 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 5e3593e34..9f1056925 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 @@ -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) }