From ac48c95d125024e056433156fe62168cc793166b Mon Sep 17 00:00:00 2001 From: Bnyro Date: Fri, 2 Jun 2023 16:15:35 +0200 Subject: [PATCH] Localize date in search results --- .../main/java/com/github/libretube/api/obj/ContentItem.kt | 7 +++---- .../java/com/github/libretube/ui/adapters/SearchAdapter.kt | 4 +++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/github/libretube/api/obj/ContentItem.kt b/app/src/main/java/com/github/libretube/api/obj/ContentItem.kt index e2b19dbbb..b6a553e31 100644 --- a/app/src/main/java/com/github/libretube/api/obj/ContentItem.kt +++ b/app/src/main/java/com/github/libretube/api/obj/ContentItem.kt @@ -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, 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 2310043f0..6d24ffc20 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,9 @@ 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.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,