Skip to content

StreamVault is a TV-first free IPTV player for Android TV built with Kotlin, Jetpack Compose, Room, Hilt, and Media3.

Page EPG startup for large categories

David Nashasha8d2e7ffa999
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/epg/EpgViewModel.kt b/app/src/main/java/com/streamvault/app/ui/screens/epg/EpgViewModel.kt
index b1a9ad89..dfffe556 100644
--- a/app/src/main/java/com/streamvault/app/ui/screens/epg/EpgViewModel.kt
+++ b/app/src/main/java/com/streamvault/app/ui/screens/epg/EpgViewModel.kt
@@ -1181,8 +1181,8 @@ class EpgViewModel @Inject constructor(
request: GuideBaseRequest
) = when (request.resolvedCategoryId) {
ChannelRepository.ALL_CHANNELS_ID -> combine(
- channelRepository.getChannelsByNumber(providerId, request.resolvedCategoryId),
- channelRepository.getChannelsWithoutErrors(providerId, request.resolvedCategoryId),
+ channelRepository.getChannelsByCategoryPage(providerId, request.resolvedCategoryId, MAX_CHANNELS),
+ channelRepository.getChannelsWithoutErrorsPage(providerId, request.resolvedCategoryId, MAX_CHANNELS),
favoriteRepository.getFavorites(providerId, ContentType.LIVE)
) { channelsByNumber, healthyChannels, favorites ->
val favoriteIds = favorites.map { it.contentId }.toSet()
@@ -1203,8 +1203,8 @@ class EpgViewModel @Inject constructor(
.flatMapLatest { ids -> loadGuideChannelsByOrderedIds(ids, providerId) }
else -> combine(
- channelRepository.getChannelsByNumber(providerId, request.resolvedCategoryId),
- channelRepository.getChannelsWithoutErrors(providerId, request.resolvedCategoryId),
+ channelRepository.getChannelsByCategoryPage(providerId, request.resolvedCategoryId, MAX_CHANNELS),
+ channelRepository.getChannelsWithoutErrorsPage(providerId, request.resolvedCategoryId, MAX_CHANNELS),
favoriteRepository.getFavorites(providerId, ContentType.LIVE)
) { channelsByNumber, healthyChannels, favorites ->
val favoriteIds = favorites.map { it.contentId }.toSet()
@@ -1330,7 +1330,6 @@ class EpgViewModel @Inject constructor(
) {
guideFallbackJob?.cancel()
if (channels.isEmpty()) {
- guideFallbackJob = null
return
}
diff --git a/app/src/test/java/com/streamvault/app/ui/screens/epg/EpgViewModelTest.kt b/app/src/test/java/com/streamvault/app/ui/screens/epg/EpgViewModelTest.kt
index 0ad9d4a3..7a021d3c 100644
--- a/app/src/test/java/com/streamvault/app/ui/screens/epg/EpgViewModelTest.kt
+++ b/app/src/test/java/com/streamvault/app/ui/screens/epg/EpgViewModelTest.kt
@@ -86,6 +86,8 @@ class EpgViewModelTest {
whenever(favoriteRepository.getGroups(any<List<Long>>(), eq(ContentType.LIVE))).thenReturn(flowOf(emptyList()))
whenever(favoriteRepository.getFavorites(any<Long>(), eq(ContentType.LIVE))).thenReturn(flowOf(emptyList()))
whenever(favoriteRepository.getFavorites(any<List<Long>>(), eq(ContentType.LIVE))).thenReturn(flowOf(emptyList()))
+ whenever(channelRepository.getChannelsByCategoryPage(any(), any(), any())).thenReturn(flowOf(emptyList()))
+ whenever(channelRepository.getChannelsWithoutErrorsPage(any(), any(), any())).thenReturn(flowOf(emptyList()))
whenever(recordingManager.observeRecordingItems()).thenReturn(flowOf(emptyList()))
}
@@ -150,8 +152,8 @@ class EpgViewModelTest {
whenever(parentalControlManager.unlockedCategoriesForProvider(provider.id)).thenReturn(flowOf(emptySet()))
whenever(channelRepository.getCategories(provider.id)).thenReturn(flowOf(listOf(Category(id = 10L, name = "News"))))
whenever(channelRepository.getChannels(provider.id)).thenReturn(flowOf(channels))
- whenever(channelRepository.getChannelsByNumber(provider.id, ChannelRepository.ALL_CHANNELS_ID)).thenReturn(flowOf(channels))
- whenever(channelRepository.getChannelsWithoutErrors(provider.id, ChannelRepository.ALL_CHANNELS_ID)).thenReturn(flowOf(channels))
+ whenever(channelRepository.getChannelsByCategoryPage(provider.id, ChannelRepository.ALL_CHANNELS_ID, EpgViewModel.MAX_CHANNELS)).thenReturn(flowOf(channels))
+ whenever(channelRepository.getChannelsWithoutErrorsPage(provider.id, ChannelRepository.ALL_CHANNELS_ID, EpgViewModel.MAX_CHANNELS)).thenReturn(flowOf(channels))
whenever(favoriteRepository.getFavorites(provider.id, ContentType.LIVE)).thenReturn(flowOf(emptyList()))
whenever(preferencesRepository.guideDensity).thenReturn(flowOf(null))
whenever(preferencesRepository.guideChannelMode).thenReturn(flowOf(null))
@@ -205,10 +207,10 @@ class EpgViewModelTest {
whenever(channelRepository.getCategories(provider.id)).thenReturn(flowOf(listOf(Category(id = 10L, name = "News"))))
whenever(channelRepository.getChannels(provider.id)).thenReturn(flowOf(channels))
whenever(channelRepository.getChannelsByCategory(provider.id, 10L)).thenReturn(flowOf(channels))
- whenever(channelRepository.getChannelsByNumber(provider.id, ChannelRepository.ALL_CHANNELS_ID)).thenReturn(flowOf(channels))
- whenever(channelRepository.getChannelsByNumber(provider.id, 10L)).thenReturn(flowOf(channels))
- whenever(channelRepository.getChannelsWithoutErrors(provider.id, ChannelRepository.ALL_CHANNELS_ID)).thenReturn(flowOf(channels))
- whenever(channelRepository.getChannelsWithoutErrors(provider.id, 10L)).thenReturn(flowOf(channels))
+ whenever(channelRepository.getChannelsByCategoryPage(provider.id, ChannelRepository.ALL_CHANNELS_ID, EpgViewModel.MAX_CHANNELS)).thenReturn(flowOf(channels))
+ whenever(channelRepository.getChannelsByCategoryPage(provider.id, 10L, EpgViewModel.MAX_CHANNELS)).thenReturn(flowOf(channels))
+ whenever(channelRepository.getChannelsWithoutErrorsPage(provider.id, ChannelRepository.ALL_CHANNELS_ID, EpgViewModel.MAX_CHANNELS)).thenReturn(flowOf(channels))
+ whenever(channelRepository.getChannelsWithoutErrorsPage(provider.id, 10L, EpgViewModel.MAX_CHANNELS)).thenReturn(flowOf(channels))
whenever(favoriteRepository.getFavorites(provider.id, ContentType.LIVE)).thenReturn(flowOf(emptyList()))
whenever(preferencesRepository.guideDensity).thenReturn(flowOf(null))
whenever(preferencesRepository.guideChannelMode).thenReturn(flowOf(null))
@@ -289,16 +291,16 @@ class EpgViewModelTest {
whenever(preferencesRepository.getCategorySortMode(provider.id, ContentType.LIVE)).thenReturn(flowOf(CategorySortMode.DEFAULT))
whenever(parentalControlManager.unlockedCategoriesForProvider(provider.id)).thenReturn(flowOf(emptySet()))
whenever(channelRepository.getCategories(provider.id)).thenReturn(flowOf(listOf(Category(id = 10L, name = "News"))))
- whenever(channelRepository.getChannelsByNumber(provider.id, ChannelRepository.ALL_CHANNELS_ID)).thenReturn(
+ whenever(channelRepository.getChannelsByCategoryPage(provider.id, ChannelRepository.ALL_CHANNELS_ID, EpgViewModel.MAX_CHANNELS)).thenReturn(
flowOf(listOf(healthyChannel, unhealthyFavorite))
)
- whenever(channelRepository.getChannelsWithoutErrors(provider.id, ChannelRepository.ALL_CHANNELS_ID)).thenReturn(
+ whenever(channelRepository.getChannelsWithoutErrorsPage(provider.id, ChannelRepository.ALL_CHANNELS_ID, EpgViewModel.MAX_CHANNELS)).thenReturn(
flowOf(listOf(healthyChannel))
)
- whenever(channelRepository.getChannelsByNumber(provider.id, 10L)).thenReturn(
+ whenever(channelRepository.getChannelsByCategoryPage(provider.id, 10L, EpgViewModel.MAX_CHANNELS)).thenReturn(
flowOf(listOf(healthyChannel, unhealthyFavorite))
)
- whenever(channelRepository.getChannelsWithoutErrors(provider.id, 10L)).thenReturn(
+ whenever(channelRepository.getChannelsWithoutErrorsPage(provider.id, 10L, EpgViewModel.MAX_CHANNELS)).thenReturn(
flowOf(listOf(healthyChannel))
)
whenever(favoriteRepository.getFavorites(provider.id, ContentType.LIVE)).thenReturn(
@@ -352,8 +354,8 @@ class EpgViewModelTest {
whenever(preferencesRepository.getCategorySortMode(provider.id, ContentType.LIVE)).thenReturn(flowOf(CategorySortMode.DEFAULT))
whenever(parentalControlManager.unlockedCategoriesForProvider(provider.id)).thenReturn(flowOf(emptySet()))
whenever(channelRepository.getCategories(provider.id)).thenReturn(flowOf(listOf(Category(id = 10L, name = "News", count = 1))))
- whenever(channelRepository.getChannelsByNumber(provider.id, ChannelRepository.ALL_CHANNELS_ID)).thenReturn(flowOf(channels))
- whenever(channelRepository.getChannelsWithoutErrors(provider.id, ChannelRepository.ALL_CHANNELS_ID)).thenReturn(flowOf(channels))
+ whenever(channelRepository.getChannelsByCategoryPage(provider.id, ChannelRepository.ALL_CHANNELS_ID, EpgViewModel.MAX_CHANNELS)).thenReturn(flowOf(channels))
+ whenever(channelRepository.getChannelsWithoutErrorsPage(provider.id, ChannelRepository.ALL_CHANNELS_ID, EpgViewModel.MAX_CHANNELS)).thenReturn(flowOf(channels))
whenever(favoriteRepository.getFavorites(provider.id, ContentType.LIVE)).thenReturn(flowOf(emptyList()))
whenever(preferencesRepository.guideDensity).thenReturn(flowOf(null))
whenever(preferencesRepository.guideChannelMode).thenReturn(flowOf(null))
@@ -441,7 +443,7 @@ class EpgViewModelTest {
whenever(channelRepository.getChannelsByIds(listOf(providerOneChannel.id, providerTwoChannel.id))).thenReturn(
flowOf(listOf(providerOneChannel, providerTwoChannel))
)
- whenever(favoriteRepository.getFavorites(argThat<List<Long>> { this == listOf(1L, 2L) }, eq(ContentType.LIVE))).thenReturn(
+ whenever(favoriteRepository.getFavorites(any<List<Long>>(), eq(ContentType.LIVE))).thenReturn(
flowOf(
listOf(
Favorite(providerId = 1L, contentId = providerOneChannel.id, contentType = ContentType.LIVE, position = 0),
diff --git a/data/src/main/java/com/streamvault/data/local/dao/Daos.kt b/data/src/main/java/com/streamvault/data/local/dao/Daos.kt
index a301d6b3..fc1a1194 100644
--- a/data/src/main/java/com/streamvault/data/local/dao/Daos.kt
+++ b/data/src/main/java/com/streamvault/data/local/dao/Daos.kt
@@ -92,6 +92,19 @@ abstract class ChannelDao {
)
abstract fun getByProviderWithoutErrors(providerId: Long): Flow<List<ChannelBrowseEntity>>
+ @Query(
+ """
+ SELECT id, stream_id, name, logo_url, group_title, category_id, category_name, stream_url,
+ epg_channel_id, number, catch_up_supported, catch_up_days, catchUpSource,
+ provider_id, is_adult, is_user_protected, logical_group_id, error_count
+ FROM channels
+ WHERE provider_id = :providerId AND error_count = 0
+ ORDER BY number ASC
+ LIMIT :limit
+ """
+ )
+ abstract fun getByProviderWithoutErrorsBrowsePage(providerId: Long, limit: Int): Flow<List<ChannelBrowseEntity>>
+
@Query(
"""
SELECT id, stream_id, name, logo_url, group_title, category_id, category_name, stream_url,
@@ -145,6 +158,23 @@ abstract class ChannelDao {
)
abstract fun getByCategoryWithoutErrors(providerId: Long, categoryId: Long): Flow<List<ChannelBrowseEntity>>
+ @Query(
+ """
+ SELECT id, stream_id, name, logo_url, group_title, category_id, category_name, stream_url,
+ epg_channel_id, number, catch_up_supported, catch_up_days, catchUpSource,
+ provider_id, is_adult, is_user_protected, logical_group_id, error_count
+ FROM channels
+ WHERE provider_id = :providerId AND category_id = :categoryId AND error_count = 0
+ ORDER BY number ASC
+ LIMIT :limit
+ """
+ )
+ abstract fun getByCategoryWithoutErrorsBrowsePage(
+ providerId: Long,
+ categoryId: Long,
+ limit: Int
+ ): Flow<List<ChannelBrowseEntity>>
+
@Query("SELECT * FROM channels WHERE provider_id = :providerId AND category_id = :categoryId ORDER BY number ASC LIMIT :limit OFFSET :offset")
abstract fun getByCategoryPage(providerId: Long, categoryId: Long, limit: Int, offset: Int): Flow<List<ChannelEntity>>
diff --git a/data/src/main/java/com/streamvault/data/repository/ChannelRepositoryImpl.kt b/data/src/main/java/com/streamvault/data/repository/ChannelRepositoryImpl.kt
index 220c1028..566f238d 100644
--- a/data/src/main/java/com/streamvault/data/repository/ChannelRepositoryImpl.kt
+++ b/data/src/main/java/com/streamvault/data/repository/ChannelRepositoryImpl.kt
@@ -97,6 +97,14 @@ class ChannelRepositoryImpl @Inject constructor(
observeChannels(channelFlowWithoutErrors(providerId, categoryId), providerId)
.map(::sortChannelsByNumber)
+ override fun getChannelsWithoutErrorsPage(
+ providerId: Long,
+ categoryId: Long,
+ limit: Int
+ ): Flow<List<Channel>> =
+ observeChannels(channelFlowWithoutErrorsPage(providerId, categoryId, limit), providerId)
+ .map(::sortChannelsByNumber)
+
override fun searchChannelsByCategory(providerId: Long, categoryId: Long, query: String): Flow<List<Channel>> =
searchChannelEntities(providerId, categoryId, query, CATEGORY_SEARCH_LIMIT)
.let { flow -> observeChannels(flow, providerId) }
@@ -608,6 +616,17 @@ class ChannelRepositoryImpl @Inject constructor(
channelDao.getByCategoryWithoutErrors(providerId, categoryId)
}
+ private fun channelFlowWithoutErrorsPage(
+ providerId: Long,
+ categoryId: Long,
+ limit: Int
+ ): Flow<List<ChannelBrowseEntity>> =
+ if (categoryId == ChannelRepository.ALL_CHANNELS_ID) {
+ channelDao.getByProviderWithoutErrorsBrowsePage(providerId, limit)
+ } else {
+ channelDao.getByCategoryWithoutErrorsBrowsePage(providerId, categoryId, limit)
+ }
+
private fun safeSearchFlow(source: Flow<List<ChannelBrowseEntity>>): Flow<List<ChannelBrowseEntity>> =
source.catch { error ->
if (error is SQLiteException) {
diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md
index fa1f7b6f..b44fb15a 100644
--- a/docs/CHANGELOG.md
+++ b/docs/CHANGELOG.md
@@ -3,11 +3,18 @@
All notable product changes are recorded in this document.
## [1.0.7] - 2026-04-20
+### Added
+
+- Added Stalker Portal provider support.
+
### Fixed
+- Fixed TV Guide startup loading full large categories before first render.
- Fixed startup crashes on some Android 9 devices when secure preference storage fails to initialize.
- Fixed Picture-in-Picture setup on devices that report invalid or unsupported video aspect ratios.
-- Fixed crash on launch for users upgrading from 1.0.4 (or earlier) who had previously deleted a provider. Because SQLite foreign-key enforcement was never enabled at the database layer, `ON DELETE CASCADE` never fired when a provider was removed. Channels, movies, and series belonging to that provider remained in the database with a now-invalid `provider_id`. When the 1.0.5 migration ran to attach favorites to their provider, it resolved each favorite's provider by looking up the content row — which still existed — and carried the orphaned `provider_id` into the new table. The subsequent FK integrity check then found the violation and threw an `IllegalStateException`, crashing the app on every subsequent launch. The fix purges orphaned content rows at the start of that migration so any favorites that referenced them are silently dropped instead of producing an unresolvable FK violation.
+- Fixed launch crashes for some upgrades from 1.0.4 or earlier caused by orphaned provider content left behind by older deletes.
+- Fixed first-frame video freezes on some devices in fullscreen, live preview, and multiview playback.
+- Fixed some playback failures not retrying after video had already started.
---
diff --git a/domain/src/main/java/com/streamvault/domain/repository/ChannelRepository.kt b/domain/src/main/java/com/streamvault/domain/repository/ChannelRepository.kt
index 91676898..13351cdb 100644
--- a/domain/src/main/java/com/streamvault/domain/repository/ChannelRepository.kt
+++ b/domain/src/main/java/com/streamvault/domain/repository/ChannelRepository.kt
@@ -12,6 +12,7 @@ interface ChannelRepository {
fun getChannelsByCategoryPage(providerId: Long, categoryId: Long, limit: Int): Flow<List<Channel>>
fun getChannelsByNumber(providerId: Long, categoryId: Long = ALL_CHANNELS_ID): Flow<List<Channel>>
fun getChannelsWithoutErrors(providerId: Long, categoryId: Long = ALL_CHANNELS_ID): Flow<List<Channel>>
+ fun getChannelsWithoutErrorsPage(providerId: Long, categoryId: Long = ALL_CHANNELS_ID, limit: Int): Flow<List<Channel>>
fun searchChannelsByCategory(providerId: Long, categoryId: Long, query: String): Flow<List<Channel>>
fun searchChannelsByCategoryPaged(providerId: Long, categoryId: Long, query: String, limit: Int): Flow<List<Channel>>
fun getCategories(providerId: Long): Flow<List<Category>>
diff --git a/domain/src/test/java/com/streamvault/domain/usecase/SearchContentTest.kt b/domain/src/test/java/com/streamvault/domain/usecase/SearchContentTest.kt
index bdb5e752..84bd26bf 100644
--- a/domain/src/test/java/com/streamvault/domain/usecase/SearchContentTest.kt
+++ b/domain/src/test/java/com/streamvault/domain/usecase/SearchContentTest.kt
@@ -122,6 +122,7 @@ private class FakeChannelRepository(
override fun getChannelsByCategoryPage(providerId: Long, categoryId: Long, limit: Int): Flow<List<Channel>> = unsupported()
override fun getChannelsByNumber(providerId: Long, categoryId: Long): Flow<List<Channel>> = unsupported()
override fun getChannelsWithoutErrors(providerId: Long, categoryId: Long): Flow<List<Channel>> = unsupported()
+ override fun getChannelsWithoutErrorsPage(providerId: Long, categoryId: Long, limit: Int): Flow<List<Channel>> = unsupported()
override fun searchChannelsByCategory(providerId: Long, categoryId: Long, query: String): Flow<List<Channel>> = unsupported()
override fun searchChannelsByCategoryPaged(providerId: Long, categoryId: Long, query: String, limit: Int): Flow<List<Channel>> = unsupported()
override fun getCategories(providerId: Long): Flow<List<Category>> = unsupported()