I have 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()
        }

    }
}

And fragment in which this adapter created:

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

After the adapter.submitList (t) method has been called. Nothing happens, and the onCreateViewHolder and onBindViewHolder methods are not called, please tell me there could be a reason, I just can't understand (

0 Answers