Merge pull request #6168 from Bnyro/master

fix: crash when playing video without upload date
This commit is contained in:
Bnyro 2024-06-21 16:28:45 +02:00 committed by GitHub
commit 309427148c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 9 additions and 8 deletions

View File

@ -19,7 +19,8 @@ data class Streams(
@Serializable(SafeInstantSerializer::class)
@SerialName("uploadDate")
val uploadTimestamp: Instant,
val uploadTimestamp: Instant?,
val uploaded: Long? = null,
val uploader: String,
val uploaderUrl: String,
@ -91,9 +92,9 @@ data class Streams(
uploaderName = uploader,
uploaderUrl = uploaderUrl,
uploaderAvatar = uploaderAvatar,
uploadedDate = uploadTimestamp.toLocalDateTime(TimeZone.currentSystemDefault()).date
.toString(),
uploaded = uploadTimestamp.toEpochMilliseconds(),
uploadedDate = uploadTimestamp?.toLocalDateTime(TimeZone.currentSystemDefault())?.date
?.toString(),
uploaded = uploaded ?: uploadTimestamp?.toEpochMilliseconds() ?: 0,
duration = duration,
views = views,
uploaderVerified = uploaderVerified,

View File

@ -120,7 +120,7 @@ class DownloadService : LifecycleService() {
streams.description,
streams.uploader,
streams.duration,
streams.uploadTimestamp.toLocalDateTime(TimeZone.currentSystemDefault()).date,
streams.uploadTimestamp?.toLocalDateTime(TimeZone.currentSystemDefault())?.date,
thumbnailTargetPath
)
Database.downloadDao().insertDownload(download)

View File

@ -681,7 +681,6 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
commentsViewModel.setCommentSheetExpand(null)
updateResolutionOnFullscreenChange(true)
openOrCloseFullscreenDialog(true)
binding.player.updateMarginsByFullscreenMode()
@ -691,7 +690,7 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
fun unsetFullscreen() {
viewModel.isFullscreen.value = false
if (!PlayerHelper.autoFullscreenEnabled) {
if (!PlayerHelper.autoFullscreenEnabled && activity != null) {
mainActivity.requestedOrientation = mainActivity.screenOrientationPref
}

View File

@ -143,9 +143,10 @@ class DescriptionLayout(
}
private fun localizeDate(streams: Streams): String {
if (streams.livestream) return ""
if (streams.livestream || streams.uploadTimestamp == null) return ""
val date = streams.uploadTimestamp.toLocalDateTime(TimeZone.currentSystemDefault()).date
return TextUtils.SEPARATOR + TextUtils.localizeDate(date)
}