-
-
Notifications
You must be signed in to change notification settings - Fork 402
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Provider filter: use compose to create provider filter view.
- Loading branch information
1 parent
1cd3de3
commit 9da4b43
Showing
6 changed files
with
114 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
app/src/main/java/com/battlelancer/seriesguide/shows/ShowsDistillationViewModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// Copyright 2024 Uwe Trottmann | ||
|
||
package com.battlelancer.seriesguide.shows | ||
|
||
import android.app.Application | ||
import androidx.lifecycle.AndroidViewModel | ||
import androidx.lifecycle.viewModelScope | ||
import com.battlelancer.seriesguide.provider.SgRoomDatabase | ||
import com.battlelancer.seriesguide.streaming.SgWatchProvider | ||
import kotlinx.coroutines.flow.SharingStarted | ||
import kotlinx.coroutines.flow.StateFlow | ||
import kotlinx.coroutines.flow.map | ||
import kotlinx.coroutines.flow.stateIn | ||
|
||
class ShowsDistillationViewModel(application: Application) : AndroidViewModel(application) { | ||
|
||
val showsDistillationUiState: StateFlow<ShowsDistillationUiState> = | ||
SgRoomDatabase.getInstance(application).sgWatchProviderHelper() | ||
.allWatchProvidersFlow(SgWatchProvider.Type.SHOWS.id) | ||
.map { ShowsDistillationUiState(it) } | ||
.stateIn( | ||
scope = viewModelScope, | ||
started = SharingStarted.WhileSubscribed(), | ||
initialValue = ShowsDistillationUiState() | ||
) | ||
|
||
} | ||
|
||
data class ShowsDistillationUiState( | ||
val watchProviders: List<SgWatchProvider> = listOf() | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.