There are many examples of how to transfer a new list to the adapter when LiveData changes.
I am trying to update a single line (for example, the number of comments for a post) in a huge list. It would be foolish to reset the list of everything to change only one field.
I can add an observer onBindViewHolder, but I can not figure out when to remove the observer
@Override public void onBindViewHolder(ViewHolder vh, int position) { Post post = getPost(position); vh.itemView.setTag(post); post.getLiveName().observeForever(vh.nameObserver); ... }
android recycler-adapter android-livedata
Andrew Matuk
source share