Code refactor

This commit is contained in:
Hemanth S 2020-05-21 03:10:29 +05:30
parent a3cee7d5f4
commit 607d1722da
2 changed files with 4 additions and 4 deletions

View file

@ -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,

View file

@ -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