mirror of
https://github.com/oxyroid/M3UAndroid.git
synced 2025-05-17 19:35:58 +08:00
feat: pager gallery.
This commit is contained in:
@ -165,7 +165,6 @@ data class PlaylistWithChannels(
|
||||
val channels: List<Channel>
|
||||
)
|
||||
|
||||
@Immutable
|
||||
data class PlaylistWithCount(
|
||||
@Embedded
|
||||
val playlist: Playlist,
|
||||
@ -173,6 +172,10 @@ data class PlaylistWithCount(
|
||||
val count: Int
|
||||
)
|
||||
|
||||
fun Iterable<PlaylistWithCount>.toMap(): Map<Playlist, Int> = associate {
|
||||
it.playlist to it.count
|
||||
}
|
||||
|
||||
private object DataSourceSerializer : KSerializer<DataSource> {
|
||||
override fun deserialize(decoder: Decoder): DataSource {
|
||||
return DataSource.of(decoder.decodeString())
|
||||
|
@ -57,7 +57,7 @@ interface PlaylistRepository {
|
||||
|
||||
suspend fun onUpdatePlaylistUserAgent(url: String, userAgent: String?)
|
||||
|
||||
fun observeAllCounts(): Flow<List<PlaylistWithCount>>
|
||||
fun observeAllCounts(): Flow<Map<Playlist, Int>>
|
||||
|
||||
suspend fun readEpisodesOrThrow(series: Channel): List<XtreamChannelInfo.Episode>
|
||||
|
||||
|
@ -28,6 +28,7 @@ import com.m3u.data.database.model.Playlist
|
||||
import com.m3u.data.database.model.PlaylistWithChannels
|
||||
import com.m3u.data.database.model.PlaylistWithCount
|
||||
import com.m3u.data.database.model.fromLocal
|
||||
import com.m3u.data.database.model.toMap
|
||||
import com.m3u.data.parser.m3u.M3UData
|
||||
import com.m3u.data.parser.m3u.M3UParser
|
||||
import com.m3u.data.parser.m3u.toChannel
|
||||
@ -577,9 +578,10 @@ internal class PlaylistRepositoryImpl @Inject constructor(
|
||||
playlistDao.updateUserAgent(url, userAgent)
|
||||
}
|
||||
|
||||
override fun observeAllCounts(): Flow<List<PlaylistWithCount>> =
|
||||
override fun observeAllCounts(): Flow<Map<Playlist, Int>> =
|
||||
playlistDao.observeAllCounts()
|
||||
.catch { emit(emptyList()) }
|
||||
.map { it.toMap() }
|
||||
.catch { emit(emptyMap()) }
|
||||
|
||||
override suspend fun readEpisodesOrThrow(series: Channel): List<XtreamChannelInfo.Episode> {
|
||||
val playlist = checkNotNull(get(series.playlistUrl)) { "playlist is not exist" }
|
||||
|
Reference in New Issue
Block a user