Skip to content

Commit

Permalink
Update project
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelbel committed Aug 6, 2024
1 parent f9d66fd commit 34b8bcf
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class DetailsViewModel(
private val movieId: MovieId = savedStateHandle.require("movieId")

private val _detailsState = MutableStateFlow<ScreenState>(ScreenState.Loading)
val detailsState = _detailsState.asStateFlow()
val detailsState: StateFlow<ScreenState> get() = _detailsState.asStateFlow()

val networkStatus: StateFlow<NetworkStatus> = networkManager.status
.stateIn(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package org.michaelbel.movies.details
import androidx.lifecycle.SavedStateHandle
import androidx.lifecycle.viewModelScope
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.launch
import org.michaelbel.movies.common.viewmodel.BaseViewModel
Expand All @@ -20,7 +21,7 @@ class DetailsViewModel(
private val movieId: MovieId = savedStateHandle["movieId"] ?: 0

private val _detailsState = MutableStateFlow<ScreenState>(ScreenState.Loading)
val detailsState = _detailsState.asStateFlow()
val detailsState: StateFlow<ScreenState> get() = _detailsState.asStateFlow()

init {
println("movieList=$movieList, movieId=$movieId")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package org.michaelbel.movies.details
import androidx.lifecycle.SavedStateHandle
import androidx.lifecycle.viewModelScope
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.launch
import org.michaelbel.movies.common.ktx.require
Expand All @@ -21,7 +22,7 @@ class DetailsViewModel(
private val movieId: MovieId = savedStateHandle.require("movieId")

private val _detailsState = MutableStateFlow<ScreenState>(ScreenState.Loading)
val detailsState = _detailsState.asStateFlow()
val detailsState: StateFlow<ScreenState> get() = _detailsState.asStateFlow()

init {
println("movieList=$movieList, movieId=$movieId")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class FeedViewModel(
.cachedIn(this)

private var _notificationsPermissionRequired: MutableStateFlow<Boolean> = MutableStateFlow(false)
val notificationsPermissionRequired: StateFlow<Boolean> = _notificationsPermissionRequired.asStateFlow()
val notificationsPermissionRequired: StateFlow<Boolean> get() = _notificationsPermissionRequired.asStateFlow()

var isAuthFailureSnackbarShowed: Boolean by mutableStateOf(false)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class GalleryViewModel(
)

private val _workInfoFlow: MutableStateFlow<WorkInfo?> = MutableStateFlow(null)
val workInfoFlow: StateFlow<WorkInfo?> = _workInfoFlow.asStateFlow()
val workInfoFlow: StateFlow<WorkInfo?> get() = _workInfoFlow.asStateFlow()

init {
loadMovieImages(movieId.toInt())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ class MainViewModel(
): BaseViewModel() {

private val _authenticateFlow = Channel<Unit>(Channel.BUFFERED)
val authenticateFlow: Flow<Unit> = _authenticateFlow.receiveAsFlow()
val authenticateFlow: Flow<Unit> get() = _authenticateFlow.receiveAsFlow()

private val _cancelFlow = Channel<Unit>(Channel.BUFFERED)
val cancelFlow: Flow<Unit> = _cancelFlow.receiveAsFlow()
val cancelFlow: Flow<Unit> get() = _cancelFlow.receiveAsFlow()

private val _splashLoading = MutableStateFlow(true)
val splashLoading: StateFlow<Boolean> = _splashLoading.asStateFlow()
val splashLoading: StateFlow<Boolean> get() = _splashLoading.asStateFlow()

val themeData: StateFlow<ThemeData> = interactor.themeData
.stateIn(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ class SearchViewModel(
)

private val _query: MutableStateFlow<String> = MutableStateFlow("")
private val query: StateFlow<String> = _query.asStateFlow()
private val query: StateFlow<String> get() = _query.asStateFlow()

val isSearchActive: StateFlow<Boolean> = interactor.isSearchActive

val pagingDataFlow: Flow<PagingData<MoviePojo>> = query
.flatMapLatest { query -> movieBlockingInteractor.moviesPagingData(query) }
.flatMapLatest(movieBlockingInteractor::moviesPagingData)
.cachedIn(this)

init {
Expand Down

0 comments on commit 34b8bcf

Please sign in to comment.