Code refactor
This commit is contained in:
parent
a3cee7d5f4
commit
607d1722da
2 changed files with 4 additions and 4 deletions
|
@ -48,7 +48,7 @@ import java.util.*
|
||||||
class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallbacks {
|
class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallbacks {
|
||||||
|
|
||||||
private lateinit var homeAdapter: HomeAdapter
|
private lateinit var homeAdapter: HomeAdapter
|
||||||
lateinit var homeModel: HomeViewModel
|
private lateinit var homeModel: HomeViewModel
|
||||||
|
|
||||||
override fun onCreateView(
|
override fun onCreateView(
|
||||||
inflater: LayoutInflater,
|
inflater: LayoutInflater,
|
||||||
|
|
|
@ -17,7 +17,7 @@ class HomeViewModel(application: Application) : AndroidViewModel(application) {
|
||||||
loadHome()
|
loadHome()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun loadHome() = viewModelScope.launch {
|
private fun loadHome() = viewModelScope.launch {
|
||||||
val list = mutableListOf<Home>()
|
val list = mutableListOf<Home>()
|
||||||
val result = listOf(
|
val result = listOf(
|
||||||
repository.topArtists(),
|
repository.topArtists(),
|
||||||
|
@ -27,8 +27,8 @@ class HomeViewModel(application: Application) : AndroidViewModel(application) {
|
||||||
repository.favoritePlaylist()
|
repository.favoritePlaylist()
|
||||||
)
|
)
|
||||||
for (r in result) {
|
for (r in result) {
|
||||||
when (r) {
|
if (r is Result.Success) {
|
||||||
is Result.Success -> list.add(r.data)
|
list.add(r.data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sections.value = list
|
sections.value = list
|
||||||
|
|
Loading…
Reference in a new issue