-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Implement functionality of the VideoLibraryScreen
- Loading branch information
1 parent
42f57ac
commit 2af7897
Showing
10 changed files
with
174 additions
and
54 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
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 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
25 changes: 0 additions & 25 deletions
25
...o/src/main/java/com/wei/picquest/feature/photo/photosearch/manager/RecentSearchManager.kt
This file was deleted.
Oops, something went wrong.
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
44 changes: 44 additions & 0 deletions
44
.../video/src/main/java/com/wei/picquest/feature/video/videolibrary/VideoLibraryViewModel.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,44 @@ | ||
package com.wei.picquest.feature.video.videolibrary | ||
|
||
import androidx.lifecycle.viewModelScope | ||
import androidx.paging.PagingData | ||
import androidx.paging.cachedIn | ||
import com.wei.picquest.core.base.BaseViewModel | ||
import com.wei.picquest.core.data.model.VideoDetail | ||
import com.wei.picquest.core.data.repository.SearchVideosRepository | ||
import dagger.hilt.android.lifecycle.HiltViewModel | ||
import kotlinx.coroutines.flow.MutableStateFlow | ||
import kotlinx.coroutines.flow.distinctUntilChanged | ||
import kotlinx.coroutines.launch | ||
import javax.inject.Inject | ||
|
||
@HiltViewModel | ||
class VideoLibraryViewModel @Inject constructor( | ||
private val searchVideoRepository: SearchVideosRepository, | ||
) : BaseViewModel< | ||
VideoLibraryViewAction, | ||
VideoLibraryViewState, | ||
>(VideoLibraryViewState) { | ||
|
||
private val _videosState: MutableStateFlow<PagingData<VideoDetail>> = | ||
MutableStateFlow(value = PagingData.empty()) | ||
val videosState: MutableStateFlow<PagingData<VideoDetail>> get() = _videosState | ||
|
||
init { | ||
searchVideos("cat") | ||
} | ||
|
||
private fun searchVideos(query: String) { | ||
viewModelScope.launch { | ||
searchVideoRepository.getSearchVideo(query) | ||
.distinctUntilChanged() | ||
.cachedIn(viewModelScope) | ||
.collect { pagingData -> | ||
_videosState.value = pagingData | ||
} | ||
} | ||
} | ||
|
||
override fun dispatch(action: VideoLibraryViewAction) { | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
.../video/src/main/java/com/wei/picquest/feature/video/videolibrary/VideoLibraryViewState.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,8 @@ | ||
package com.wei.picquest.feature.video.videolibrary | ||
|
||
import com.wei.picquest.core.base.Action | ||
import com.wei.picquest.core.base.State | ||
|
||
sealed class VideoLibraryViewAction : Action | ||
|
||
object VideoLibraryViewState : State |