У меня есть PagedListAdapater :
class TrackedActivityAdapter constructor(diffUtilCallback: DiffUtil.ItemCallback<TrackedActivity>) :
PagedListAdapter<TrackedActivity, TrackedActivityAdapter.TrackedActivityHolder>(diffUtilCallback) {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): TrackedActivityHolder {
val inflater = LayoutInflater.from(parent.context)
val view = DataBindingUtil.inflate<ActivityItemBinding>(inflater, R.layout.activity_item, parent, false)
return TrackedActivityHolder(view)
}
override fun onBindViewHolder(holder: TrackedActivityHolder, position: Int) {
getItem(position)?.let { holder.bind(it) }
}
class TrackedActivityHolder(var binding: ActivityItemBinding) : RecyclerView.ViewHolder(binding.root) {
fun bind(trackedActivity: TrackedActivity) {
binding.activity = trackedActivity
binding.executePendingBindings()
}
}
}
И фрагмент, в котором создан этот адаптер:
class HistoryFragment : DaggerFragment() {
@Inject
lateinit var viewModelFactory: ViewModelProvider.Factory
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
val binding = DataBindingUtil.inflate<HistoryFragmentViewBinding>(
inflater,
R.layout.history_fragment_view,
container,
false
)
val historyViewModel = ViewModelProviders.of(this, viewModelFactory).get(HistoryViewModel::class.java)
val adapter = TrackedActivityAdapter(TrackedActivity.DIFF_CALLBACK)
binding.trackedActivityRv.adapter = adapter
binding.trackedActivityRv.layoutManager = LinearLayoutManager(binding.root.context)
historyViewModel.getTrackedActivities().observe(this,
Observer<PagedList<TrackedActivity>> { t ->
adapter.submitList(t)
})
binding.executePendingBindings()
return binding.root
}
}
После вызова метода adapter.submitList (t). Ничего не происходит, и методы onCreateViewHolder и onBindViewHolder не вызываются, пожалуйста, скажите, что может быть причина, я просто не могу понять (