mirror of
https://github.com/JustinZeus/Wholphin.git
synced 2026-07-08 15:50:16 +02:00
Handle fake programs better
This commit is contained in:
parent
9dd3813b35
commit
5656703080
2 changed files with 30 additions and 6 deletions
|
|
@ -124,6 +124,7 @@ class LiveTvViewModel
|
||||||
},
|
},
|
||||||
isRecording = dto.timerId.isNotNullOrBlank(),
|
isRecording = dto.timerId.isNotNullOrBlank(),
|
||||||
isSeriesRecording = dto.seriesTimerId.isNotNullOrBlank(),
|
isSeriesRecording = dto.seriesTimerId.isNotNullOrBlank(),
|
||||||
|
isFake = false,
|
||||||
)
|
)
|
||||||
}.filter { it.startHours >= 0 && it.endHours >= 0 } // TODO shouldn't need to filter client side
|
}.filter { it.startHours >= 0 && it.endHours >= 0 } // TODO shouldn't need to filter client side
|
||||||
|
|
||||||
|
|
@ -148,6 +149,7 @@ class LiveTvViewModel
|
||||||
seasonEpisode = null,
|
seasonEpisode = null,
|
||||||
isRecording = false,
|
isRecording = false,
|
||||||
isSeriesRecording = false,
|
isSeriesRecording = false,
|
||||||
|
isFake = true,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
put(channel.id, fakePrograms)
|
put(channel.id, fakePrograms)
|
||||||
|
|
@ -303,4 +305,5 @@ data class TvProgram(
|
||||||
val seasonEpisode: SeasonEpisode?,
|
val seasonEpisode: SeasonEpisode?,
|
||||||
val isRecording: Boolean,
|
val isRecording: Boolean,
|
||||||
val isSeriesRecording: Boolean,
|
val isSeriesRecording: Boolean,
|
||||||
|
val isFake: Boolean,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.github.damontecres.wholphin.ui.detail.livetv
|
package com.github.damontecres.wholphin.ui.detail.livetv
|
||||||
|
|
||||||
import android.text.format.DateUtils
|
import android.text.format.DateUtils
|
||||||
|
import android.widget.Toast
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.focusable
|
import androidx.compose.foundation.focusable
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
|
|
@ -92,6 +93,7 @@ fun TvGuideGrid(
|
||||||
-> LoadingPage(modifier)
|
-> LoadingPage(modifier)
|
||||||
|
|
||||||
LoadingState.Success -> {
|
LoadingState.Success -> {
|
||||||
|
val context = LocalContext.current
|
||||||
val fetchedItem by viewModel.fetchedItem.observeAsState(null)
|
val fetchedItem by viewModel.fetchedItem.observeAsState(null)
|
||||||
val loadingItem by viewModel.fetchingItem.observeAsState(LoadingState.Pending)
|
val loadingItem by viewModel.fetchingItem.observeAsState(LoadingState.Pending)
|
||||||
var showItemDialog by remember { mutableStateOf<Int?>(null) }
|
var showItemDialog by remember { mutableStateOf<Int?>(null) }
|
||||||
|
|
@ -108,8 +110,24 @@ fun TvGuideGrid(
|
||||||
programs = programsByChannel,
|
programs = programsByChannel,
|
||||||
start = viewModel.start,
|
start = viewModel.start,
|
||||||
onClick = { index, program ->
|
onClick = { index, program ->
|
||||||
viewModel.getItem(program.id)
|
if (program.isFake) {
|
||||||
showItemDialog = index
|
val now = LocalDateTime.now()
|
||||||
|
if (now.isAfter(program.start) && now.isBefore(program.end)) {
|
||||||
|
viewModel.navigationManager.navigateTo(
|
||||||
|
Destination.Playback(
|
||||||
|
itemId = program.channelId,
|
||||||
|
positionMs = 0L,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
Toast
|
||||||
|
.makeText(context, "No guide data found!", Toast.LENGTH_SHORT)
|
||||||
|
.show()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
viewModel.getItem(program.id)
|
||||||
|
showItemDialog = index
|
||||||
|
}
|
||||||
},
|
},
|
||||||
modifier =
|
modifier =
|
||||||
Modifier
|
Modifier
|
||||||
|
|
@ -174,12 +192,14 @@ fun ProgramDialog(
|
||||||
Dialog(
|
Dialog(
|
||||||
onDismissRequest = onDismissRequest,
|
onDismissRequest = onDismissRequest,
|
||||||
) {
|
) {
|
||||||
|
val focusRequester = remember { FocusRequester() }
|
||||||
Box(
|
Box(
|
||||||
modifier =
|
modifier =
|
||||||
Modifier.background(
|
Modifier
|
||||||
MaterialTheme.colorScheme.surfaceColorAtElevation(10.dp),
|
.background(
|
||||||
shape = RoundedCornerShape(16.dp),
|
MaterialTheme.colorScheme.surfaceColorAtElevation(10.dp),
|
||||||
),
|
shape = RoundedCornerShape(16.dp),
|
||||||
|
).focusRequester(focusRequester),
|
||||||
) {
|
) {
|
||||||
Column(
|
Column(
|
||||||
verticalArrangement = Arrangement.spacedBy(8.dp),
|
verticalArrangement = Arrangement.spacedBy(8.dp),
|
||||||
|
|
@ -204,6 +224,7 @@ fun ProgramDialog(
|
||||||
val dto = item.data
|
val dto = item.data
|
||||||
val isRecording = dto.timerId.isNotNullOrBlank()
|
val isRecording = dto.timerId.isNotNullOrBlank()
|
||||||
val isSeriesRecording = dto.seriesTimerId.isNotNullOrBlank()
|
val isSeriesRecording = dto.seriesTimerId.isNotNullOrBlank()
|
||||||
|
LaunchedEffect(Unit) { focusRequester.tryRequestFocus() }
|
||||||
Text(
|
Text(
|
||||||
text = item.name ?: "",
|
text = item.name ?: "",
|
||||||
color = MaterialTheme.colorScheme.onSurface,
|
color = MaterialTheme.colorScheme.onSurface,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue