-
Notifications
You must be signed in to change notification settings - Fork 4
hosseini_createMusicListViewModel #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
hosseiniSeyRo
wants to merge
5
commits into
dev
Choose a base branch
from
hosseini_createMusicListViewModel
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
24c82c2
design playerFragment view
hosseiniSeyRo 8f93b84
remove actionBar
hosseiniSeyRo bf2d481
create ProjectRepository and MusicListViewModel
hosseiniSeyRo 2407c23
some change in package structure
hosseiniSeyRo 9abd2f9
add coroutines and use in MusicListViewModel and repository
hosseiniSeyRo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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.
11 changes: 11 additions & 0 deletions
11
app/src/main/java/com/worldsnas/starplayer/service/model/Music.kt
This file contains hidden or 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,11 @@ | ||
| package com.worldsnas.starplayer.service.model | ||
|
|
||
| data class Music( | ||
| val id: Int, | ||
| val image: String, | ||
| val title: String, | ||
| val artist: String, | ||
| val album: String, | ||
| val genre: String, | ||
| val duration: Int | ||
| ) | ||
63 changes: 63 additions & 0 deletions
63
app/src/main/java/com/worldsnas/starplayer/service/repository/ProjectRepository.kt
This file contains hidden or 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,63 @@ | ||
| package com.worldsnas.starplayer.service.repository | ||
|
|
||
| import com.worldsnas.starplayer.service.model.Music | ||
|
|
||
| object ProjectRepository { | ||
|
|
||
| suspend fun fetchMusicList(): List<Music>? { | ||
| var data: List<Music> = ArrayList<Music>() | ||
| //TODO fetch music list from device or server | ||
| data = getDummyData() | ||
| return data | ||
| } | ||
|
|
||
| private suspend fun getDummyData(): List<Music> { | ||
| return listOf( | ||
| Music( | ||
| 1, | ||
| "https://www.google.com/imgres?imgurl=https%3A%2F%2Fd2uqwoe9jzxxtn.cloudfront.net%2Fimages%2Fmusic%2Fcover%2FReza-Bahram_Divaneh_1542873566.jpg&imgrefurl=https%3A%2F%2Fwww.bia2.com%2Fmusic%2F58424&tbnid=delorUWCaJIxVM&vet=12ahUKEwjGjMmMn_7nAhXMGd8KHQ8sBfYQMygAegUIARDWAQ..i&docid=QbgkPvan3RNPMM&w=640&h=640&q=reza%20bahram&ved=2ahUKEwjGjMmMn_7nAhXMGd8KHQ8sBfYQMygAegUIARDWAQ", | ||
| "Divaneh", | ||
| "reza bahram", | ||
| "album1", | ||
| "genre1", | ||
| 152365 | ||
| ), | ||
| Music( | ||
| 2, | ||
| "https://www.google.com/imgres?imgurl=https%3A%2F%2Fd2uqwoe9jzxxtn.cloudfront.net%2Fimages%2Fmusic%2Fcover%2FReza-Bahram_Divaneh_1542873566.jpg&imgrefurl=https%3A%2F%2Fwww.bia2.com%2Fmusic%2F58424&tbnid=delorUWCaJIxVM&vet=12ahUKEwjGjMmMn_7nAhXMGd8KHQ8sBfYQMygAegUIARDWAQ..i&docid=QbgkPvan3RNPMM&w=640&h=640&q=reza%20bahram&ved=2ahUKEwjGjMmMn_7nAhXMGd8KHQ8sBfYQMygAegUIARDWAQ", | ||
| "Divaneh", | ||
| "reza bahram", | ||
| "album2", | ||
| "genre2", | ||
| 152365 | ||
| ), | ||
| Music( | ||
| 3, | ||
| "https://www.google.com/imgres?imgurl=https%3A%2F%2Fd2uqwoe9jzxxtn.cloudfront.net%2Fimages%2Fmusic%2Fcover%2FReza-Bahram_Divaneh_1542873566.jpg&imgrefurl=https%3A%2F%2Fwww.bia2.com%2Fmusic%2F58424&tbnid=delorUWCaJIxVM&vet=12ahUKEwjGjMmMn_7nAhXMGd8KHQ8sBfYQMygAegUIARDWAQ..i&docid=QbgkPvan3RNPMM&w=640&h=640&q=reza%20bahram&ved=2ahUKEwjGjMmMn_7nAhXMGd8KHQ8sBfYQMygAegUIARDWAQ", | ||
| "Divaneh", | ||
| "reza bahram", | ||
| "album3", | ||
| "genre3", | ||
| 152365 | ||
| ), | ||
| Music( | ||
| 4, | ||
| "https://www.google.com/imgres?imgurl=https%3A%2F%2Fd2uqwoe9jzxxtn.cloudfront.net%2Fimages%2Fmusic%2Fcover%2FReza-Bahram_Divaneh_1542873566.jpg&imgrefurl=https%3A%2F%2Fwww.bia2.com%2Fmusic%2F58424&tbnid=delorUWCaJIxVM&vet=12ahUKEwjGjMmMn_7nAhXMGd8KHQ8sBfYQMygAegUIARDWAQ..i&docid=QbgkPvan3RNPMM&w=640&h=640&q=reza%20bahram&ved=2ahUKEwjGjMmMn_7nAhXMGd8KHQ8sBfYQMygAegUIARDWAQ", | ||
| "Divaneh", | ||
| "reza bahram", | ||
| "album4", | ||
| "genre4", | ||
| 152365 | ||
| ), | ||
| Music( | ||
| 5, | ||
| "https://www.google.com/imgres?imgurl=https%3A%2F%2Fd2uqwoe9jzxxtn.cloudfront.net%2Fimages%2Fmusic%2Fcover%2FReza-Bahram_Divaneh_1542873566.jpg&imgrefurl=https%3A%2F%2Fwww.bia2.com%2Fmusic%2F58424&tbnid=delorUWCaJIxVM&vet=12ahUKEwjGjMmMn_7nAhXMGd8KHQ8sBfYQMygAegUIARDWAQ..i&docid=QbgkPvan3RNPMM&w=640&h=640&q=reza%20bahram&ved=2ahUKEwjGjMmMn_7nAhXMGd8KHQ8sBfYQMygAegUIARDWAQ", | ||
| "Divaneh", | ||
| "reza bahram", | ||
| "album5", | ||
| "genre5", | ||
| 152365 | ||
| ) | ||
| ) | ||
| } | ||
| } |
2 changes: 1 addition & 1 deletion
2
...rldsnas/starplayer/view/PlayerFragment.kt → ...snas/starplayer/view/ui/PlayerFragment.kt
This file contains hidden or 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
18 changes: 18 additions & 0 deletions
18
app/src/main/java/com/worldsnas/starplayer/viewModel/MusicListViewModel.kt
This file contains hidden or 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,18 @@ | ||
| package com.worldsnas.starplayer.viewModel | ||
|
|
||
| import androidx.lifecycle.* | ||
| import com.worldsnas.starplayer.service.model.Music | ||
| import com.worldsnas.starplayer.service.repository.ProjectRepository | ||
| import kotlinx.coroutines.launch | ||
|
|
||
| class MusicListViewModel(private val repository: ProjectRepository) : ViewModel() { | ||
|
|
||
| private val _musicList = MutableLiveData<List<Music>>() | ||
| val musicList: LiveData<List<Music>> = _musicList | ||
|
|
||
| fun fetchMusicList() { | ||
| viewModelScope.launch { | ||
| _musicList.value = repository.fetchMusicList() | ||
| } | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.