Код: Выделить всё
class VideoListAdapter(
options: FirestoreRecyclerOptions
) : FirestoreRecyclerAdapter(options) {
inner class VideoViewHolder(private val binding: VideoItemRowBinding) : RecyclerView.ViewHolder(binding.root) {
Код: Выделить всё
binding.likeVidButton.setOnClickListener {
change_liked_state()
}
Код: Выделить всё
fun change_liked_state() { // didn't add an "unlike" method yet.
var app_user_model_doc = Firebase.firestore.collection("users").document(Firebase.auth.currentUser!!.uid)
app_user_model_doc.update("liked_vids", FieldValue.arrayUnion(video_model_id)).addOnSuccessListener {
video_model_doc.update("likes", FieldValue.increment(1))
}
Что мне следует сделать, чтобы я мог обновить поля «liked_vids» без перезагрузки пользовательского интерфейса?
Я пытался привязать видео, только если идентификатор видео изменился:
Код: Выделить всё
override fun onBindViewHolder(holder: VideoViewHolder, position: Int, model: VideoModel) {
if (holder.binding.like_count.text != model.likes.toString()) {
holder.bindVideo(model)
}
}
Подробнее здесь: https://stackoverflow.com/questions/792 ... when-i-upd