I am using Android Paging library to load data from server in my RecyclerView. I am able to see the data properly but when i print the size of the list, it returns me zero.
Following is my code:
val itemViewModel =
ViewModelProviders.of(this, MyViewModelFacotry(disciplineId, schoolId, yearId)).get(StudentInfoViewModel::class.java)
activity?.let {
itemViewModel.itemPagedList.observe(it, Observer<PagedList<StudentData>> { studentDataPagedList ->
if(BuildConfig.DEBUG){
Log.i("MainActivity",studentDataPagedList?.size.toString())
}
studentInfoNameAdapter?.submitList(studentDataPagedList)
})
recyclerView.adapter = studentInfoNameAdapter
}
The Log statement prints always zero. I want to show a TextView if list is empty but the list always returns size as zero.