Last active
April 15, 2020 19:22
-
-
Save EudyContreras/fe931164d0da5fd0d7156f1f4a3b611e to your computer and use it in GitHub Desktop.
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
private val dummyData = arrayOfNulls<DemoData>(DUMMY_ENTRY_COUNT) | |
val items: LiveData<Resource<List<DemoData?>?>> = repository.getDemoData().map { | |
if (it.loading) { | |
Resource.Loading(dummyData.toList()) | |
} else it | |
} | |
val itemBinding: ItemBinding<DemoData> = { data, position -> | |
when (data) { | |
is DemoData.A -> R.layout.list_item_a | |
is DemoData.B -> R.layout.list_item_b | |
else -> if (position % 2 == 0) { R.layout.list_item_a } else R.layout.list_item_b | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment