PagingDataEpoxyController is easy to set up and works great however I am facing some issues in displaying a model when the PagingData is empty. I have tried to override the addModels() method but seems it never gets triggered when data is empty. Not sure if I am missing something here.
PS: I am new to Kotlin and Android
Paging model
class PagingModel : ViewModel() {
var repository = PagingRepository()
fun query(query: Query): Flow<PagingData<DocumentSnapshot>> =
repository.query(query).cachedIn(viewModelScope)
}
lifecycleScope.launchWhenCreated {
pagingModel.query(query).collectLatest {
Timber.d("before submit data")
recyclerView.setController(controller)
controller.submitData(it)
Timber.d("after submit data") // ==============> THIS IS NEVER PRINTED
}
}
My Controller class
inner class Controller : PagingDataEpoxyController<DocumentSnapshot>() {
override fun addModels(models: List<EpoxyModel<*>>) {
add(photo()) // =============> THIS NEVER GETS CALLED WHEN DATA IS EMPTY
super.addModels(models)
}
override fun buildItemModel(
currentPosition: Int,
item: DocumentSnapshot?
): EpoxyModel<*> {
// my model here
}
}
PagingDataEpoxyController is easy to set up and works great however I am facing some issues in displaying a model when the PagingData is empty. I have tried to override the addModels() method but seems it never gets triggered when data is empty. Not sure if I am missing something here.
PS: I am new to Kotlin and Android
Paging model
Paging Repository
I am loading data from onCreateView() of fragment
My Controller class