Show time on dialog

This commit is contained in:
Damontecres 2025-10-21 22:39:34 -04:00
parent 7f95dc44ac
commit 59e2a5dc32
No known key found for this signature in database
2 changed files with 28 additions and 5 deletions

View file

@ -11,7 +11,6 @@ import com.github.damontecres.wholphin.ui.nav.NavigationManager
import com.github.damontecres.wholphin.ui.setValueOnMain
import com.github.damontecres.wholphin.ui.toServerString
import com.github.damontecres.wholphin.util.ExceptionHandler
import com.github.damontecres.wholphin.util.GetProgramsDtoHandler
import com.github.damontecres.wholphin.util.LoadingExceptionHandler
import com.github.damontecres.wholphin.util.LoadingState
import dagger.hilt.android.lifecycle.HiltViewModel
@ -28,6 +27,7 @@ import org.jellyfin.sdk.model.api.ImageType
import org.jellyfin.sdk.model.api.ItemSortBy
import org.jellyfin.sdk.model.api.TimerInfoDto
import org.jellyfin.sdk.model.api.request.GetLiveTvChannelsRequest
import org.jellyfin.sdk.model.api.request.GetLiveTvProgramsRequest
import org.jellyfin.sdk.model.extensions.ticks
import timber.log.Timber
import java.time.LocalDateTime
@ -94,16 +94,17 @@ class LiveTvViewModel
mutex.withLock {
val maxStartDate = start.plusHours(MAX_HOURS).minusMinutes(1)
val minEndDate = start.plusMinutes(1L)
val request =
GetProgramsDto(
GetLiveTvProgramsRequest(
maxStartDate = maxStartDate,
minEndDate = minEndDate,
channelIds = channels.map { it.id },
sortBy = listOf(ItemSortBy.START_DATE),
)
val programs =
GetProgramsDtoHandler
.execute(api, request)
api.liveTvApi
.getLiveTvPrograms(request)
.content.items
.map { dto ->
TvProgram(
@ -126,7 +127,7 @@ class LiveTvViewModel
isSeriesRecording = dto.seriesTimerId.isNotNullOrBlank(),
isFake = false,
)
}.filter { it.startHours >= 0 && it.endHours >= 0 } // TODO shouldn't need to filter client side
}
val programsByChannel = programs.groupBy { it.channelId }
val emptyChannels = channels.filter { programsByChannel[it.id].orEmpty().isEmpty() }

View file

@ -1,5 +1,6 @@
package com.github.damontecres.wholphin.ui.detail.livetv
import android.text.format.DateUtils
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
@ -19,6 +20,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.Dialog
@ -35,6 +37,7 @@ import com.github.damontecres.wholphin.ui.tryRequestFocus
import com.github.damontecres.wholphin.util.LoadingState
import com.github.damontecres.wholphin.util.seasonEpisode
import java.time.LocalDateTime
import java.time.ZoneId
@Composable
fun ProgramDialog(
@ -45,6 +48,7 @@ fun ProgramDialog(
onRecord: (series: Boolean) -> Unit,
onCancelRecord: (series: Boolean) -> Unit,
) {
val context = LocalContext.current
Dialog(
onDismissRequest = onDismissRequest,
) {
@ -98,6 +102,24 @@ fun ProgramDialog(
)
}
}
val time =
DateUtils.formatDateRange(
context,
dto.startDate!!
.atZone(ZoneId.systemDefault())
.toInstant()
.epochSecond * 1000,
dto.endDate!!
.atZone(ZoneId.systemDefault())
.toInstant()
.epochSecond * 1000,
DateUtils.FORMAT_SHOW_TIME,
)
Text(
text = time,
color = MaterialTheme.colorScheme.onSurface,
style = MaterialTheme.typography.titleSmall,
)
dto.overview?.let { overview ->
Text(
text = overview,