Format upload date in downloads view.

This commit is contained in:
Isira Seneviratne 2023-03-07 09:35:50 +05:30
parent 938dca2c9f
commit 77b9923a36
3 changed files with 5 additions and 3 deletions

View File

@ -2,6 +2,7 @@ package com.github.libretube.db.obj
import androidx.room.Entity import androidx.room.Entity
import androidx.room.PrimaryKey import androidx.room.PrimaryKey
import kotlinx.datetime.LocalDate
@Entity(tableName = "download") @Entity(tableName = "download")
data class Download( data class Download(
@ -10,6 +11,6 @@ data class Download(
val title: String = "", val title: String = "",
val description: String = "", val description: String = "",
val uploader: String = "", val uploader: String = "",
val uploadDate: String? = null, val uploadDate: LocalDate? = null,
val thumbnailPath: String? = null val thumbnailPath: String? = null
) )

View File

@ -103,7 +103,7 @@ class DownloadService : LifecycleService() {
streams.title, streams.title,
streams.description, streams.description,
streams.uploader, streams.uploader,
streams.uploadDate.toString(), streams.uploadDate,
thumbnailTargetFile.absolutePath thumbnailTargetFile.absolutePath
) )
Database.downloadDao().insertDownload(download) Database.downloadDao().insertDownload(download)

View File

@ -16,6 +16,7 @@ import com.github.libretube.extensions.formatAsFileSize
import com.github.libretube.helpers.ImageHelper import com.github.libretube.helpers.ImageHelper
import com.github.libretube.ui.activities.OfflinePlayerActivity import com.github.libretube.ui.activities.OfflinePlayerActivity
import com.github.libretube.ui.viewholders.DownloadsViewHolder import com.github.libretube.ui.viewholders.DownloadsViewHolder
import com.github.libretube.util.TextUtils
import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.dialog.MaterialAlertDialogBuilder
import java.io.File import java.io.File
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
@ -42,7 +43,7 @@ class DownloadsAdapter(
holder.binding.apply { holder.binding.apply {
title.text = download.title title.text = download.title
uploaderName.text = download.uploader uploaderName.text = download.uploader
videoInfo.text = download.uploadDate videoInfo.text = download.uploadDate?.let { TextUtils.localizeDate(it) }
val downloadSize = items.sumOf { it.downloadSize } val downloadSize = items.sumOf { it.downloadSize }
val currentSize = items.sumOf { File(it.path).length() } val currentSize = items.sumOf { File(it.path).length() }