Fix crashing for the first time
This commit is contained in:
parent
58dc709a7e
commit
ad6eec2240
4 changed files with 8 additions and 8 deletions
|
@ -10,7 +10,7 @@ import code.name.monkey.retromusic.providers.RepositoryImpl
|
|||
import kotlinx.coroutines.launch
|
||||
|
||||
class AlbumViewModel(application: Application) : AndroidViewModel(application) {
|
||||
lateinit var albums: MutableLiveData<List<Album>>
|
||||
var albums = MutableLiveData<List<Album>>()
|
||||
|
||||
init {
|
||||
getAlbums()
|
||||
|
@ -19,7 +19,7 @@ class AlbumViewModel(application: Application) : AndroidViewModel(application) {
|
|||
fun getAlbums() = viewModelScope.launch {
|
||||
val result = RepositoryImpl(getApplication()).allAlbums()
|
||||
if (result is Result.Success) {
|
||||
albums = MutableLiveData(result.data)
|
||||
albums.value = result.data
|
||||
}
|
||||
}
|
||||
}
|
|
@ -10,7 +10,7 @@ import code.name.monkey.retromusic.providers.RepositoryImpl
|
|||
import kotlinx.coroutines.launch
|
||||
|
||||
class ArtistViewModel(application: Application) : AndroidViewModel(application) {
|
||||
lateinit var artists: MutableLiveData<List<Artist>>
|
||||
var artists = MutableLiveData<List<Artist>>()
|
||||
|
||||
init {
|
||||
loadArtists()
|
||||
|
@ -19,7 +19,7 @@ class ArtistViewModel(application: Application) : AndroidViewModel(application)
|
|||
fun loadArtists() = viewModelScope.launch {
|
||||
val result = RepositoryImpl(getApplication()).allArtists()
|
||||
if (result is Result.Success) {
|
||||
artists = MutableLiveData(result.data)
|
||||
artists.value = result.data
|
||||
}
|
||||
}
|
||||
}
|
|
@ -10,7 +10,7 @@ import code.name.monkey.retromusic.providers.RepositoryImpl
|
|||
import kotlinx.coroutines.launch
|
||||
|
||||
class GenreViewModel(application: Application) : AndroidViewModel(application) {
|
||||
lateinit var genres: MutableLiveData<List<Genre>>
|
||||
var genres = MutableLiveData<List<Genre>>()
|
||||
|
||||
init {
|
||||
loadGenre()
|
||||
|
@ -19,7 +19,7 @@ class GenreViewModel(application: Application) : AndroidViewModel(application) {
|
|||
fun loadGenre() = viewModelScope.launch {
|
||||
val result = RepositoryImpl(getApplication()).allGenres()
|
||||
if (result is Success) {
|
||||
genres = MutableLiveData(result.data)
|
||||
genres.value = result.data
|
||||
}
|
||||
}
|
||||
}
|
|
@ -10,7 +10,7 @@ import code.name.monkey.retromusic.providers.RepositoryImpl
|
|||
import kotlinx.coroutines.launch
|
||||
|
||||
class HomeViewModel(application: Application) : AndroidViewModel(application) {
|
||||
lateinit var sections: MutableLiveData<List<Home>>
|
||||
var sections = MutableLiveData<List<Home>>()
|
||||
var repository: RepositoryImpl = RepositoryImpl(getApplication())
|
||||
|
||||
init {
|
||||
|
@ -31,6 +31,6 @@ class HomeViewModel(application: Application) : AndroidViewModel(application) {
|
|||
is Result.Success -> list.add(r.data)
|
||||
}
|
||||
}
|
||||
sections = MutableLiveData(list)
|
||||
sections.value = list
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue