Localize date in search results

This commit is contained in:
Bnyro 2023-06-02 16:15:35 +02:00
parent eef1c65f66
commit ac48c95d12
2 changed files with 6 additions and 5 deletions

View File

@ -7,18 +7,17 @@ data class ContentItem(
val url: String,
val type: String,
val thumbnail: String,
val uploaderName: String? = null,
val uploaded: Long? = null,
val shortDescription: String? = null,
// Video only attributes
val title: String? = null,
val uploaderUrl: String? = null,
val uploaderAvatar: String? = null,
val uploadedDate: String? = null,
val duration: Long = -1,
val views: Long = -1,
val isShort: Boolean? = null,
val uploaderVerified: Boolean? = null,
val uploaderName: String? = null,
val uploaded: Long? = null,
val shortDescription: String? = null,
// Channel and Playlist attributes
val name: String? = null,
val description: String? = null,

View File

@ -76,7 +76,9 @@ 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.uploadedDate?.let { " ${TextUtils.SEPARATOR} $it" }.orEmpty()
val uploadDate = item.uploaded?.let {
" ${TextUtils.SEPARATOR} ${TextUtils.formatRelativeDate(root.context, it)}"
}.orEmpty()
videoInfo.text = root.context.getString(
R.string.normal_views,
viewsString,