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

View file

@ -1,5 +1,6 @@
package com.github.damontecres.wholphin.ui.detail.livetv package com.github.damontecres.wholphin.ui.detail.livetv
import android.text.format.DateUtils
import androidx.compose.foundation.background import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box 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.focus.focusRequester import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.Dialog 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.LoadingState
import com.github.damontecres.wholphin.util.seasonEpisode import com.github.damontecres.wholphin.util.seasonEpisode
import java.time.LocalDateTime import java.time.LocalDateTime
import java.time.ZoneId
@Composable @Composable
fun ProgramDialog( fun ProgramDialog(
@ -45,6 +48,7 @@ fun ProgramDialog(
onRecord: (series: Boolean) -> Unit, onRecord: (series: Boolean) -> Unit,
onCancelRecord: (series: Boolean) -> Unit, onCancelRecord: (series: Boolean) -> Unit,
) { ) {
val context = LocalContext.current
Dialog( Dialog(
onDismissRequest = onDismissRequest, 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 -> dto.overview?.let { overview ->
Text( Text(
text = overview, text = overview,