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

View File

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

View File

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

View File

@ -143,9 +143,10 @@ class DescriptionLayout(
} }
private fun localizeDate(streams: Streams): String { 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 val date = streams.uploadTimestamp.toLocalDateTime(TimeZone.currentSystemDefault()).date
return TextUtils.SEPARATOR + TextUtils.localizeDate(date) return TextUtils.SEPARATOR + TextUtils.localizeDate(date)
} }