title: How to update item in a recycler view using diff item callback?
body: <p>I'm implementing a recycler view using room database library. I would like to list my items and that they could be edited by clicking. After re-submit the item, go back again to the list and show up the items + changes.</p>
  
  <p>I'm currently using DiffUtil callback to compare the old and the new lists. I think the problem is here. My Dto item has 4 fields.</p>
  
  <ul>
  <li>id title image arraylist</li>
  </ul>
  
  <p>So when the user edits an item, the list should update the UI row (title, image or/and arraylist)</p>
  
  <p>This is my Adapter.</p>
  
  <pre><code>private OnItemClickListener listener;
  
  public ExercicioAdapter() {
      super(DIFF_CALLBACK);
  }
  
  private static final DiffUtil.ItemCallback&lt;Exercicio&gt; DIFF_CALLBACK = new DiffUtil.ItemCallback&lt;Exercicio&gt;() {
      @Override
      public boolean areItemsTheSame(@NonNull Exercicio oldExercicio, @NonNull Exercicio newExercicio) {
          return oldExercicio.getId() == newExercicio.getId();
      }
  
      @Override
      public boolean areContentsTheSame(@NonNull Exercicio oldExercicio, @NonNull Exercicio newExercicio) {
          return oldExercicio.getTitulo().equals(newExercicio.getTitulo()) &amp;&amp;
                  Float.compare(oldExercicio.getMaxPeso(), newExercicio.getMaxPeso()) == 0;
      }
  };
  
  @NonNull
  @Override
  public MyHolderView onCreateViewHolder(@NonNull ViewGroup parent, int i) {
      View           view;
      LayoutInflater mInflater = LayoutInflater.from(parent.getContext());
      view = mInflater.inflate(R.layout.exercicios_item, parent, false);
      return new MyHolderView(view);
  }
  
  @Override
  public void onBindViewHolder(@NonNull MyHolderView exercicioHolder, final int i) {
      Exercicio exercicio = getItem(i);
  
      // Mostrar a informacion do obxeto.
      ArrayList&lt;Repeticion&gt; repeticions = exercicio.getRepeticions();
      float                 peso_max    = 0f;
      if (repeticions != null &amp;&amp; repeticions.size() &gt; 0) {
          for (Repeticion rep : repeticions) {
              if (rep.getPeso() &gt; peso_max) {
                  peso_max = rep.getPeso();
              }
          }
      }
      exercicioHolder.nome.setText(exercicio.getTitulo());
      String peso_str = exercicioHolder.itemView.getContext().getString(R.string.peso_max);
      exercicioHolder.peso.setText(peso_str + " " + Float.toString(peso_max));
  
      if (exercicio.getImaxe() != null &amp;&amp; exercicio.getImaxe().length != 0) {
          exercicioHolder.imx_exercicio.setImageBitmap(convertByteArrayToBitmap(exercicio.getImaxe()));
      }
  }
  
  public Exercicio getExercicioAt(int position) {
      return getItem(position);
  }
  
  public class MyHolderView extends RecyclerView.ViewHolder {
      TextView  nome;
      TextView  peso;
      ImageView imx_exercicio;
      CardView  exercicio_cardview;
  
      MyHolderView(@NonNull View itemView) {
          super(itemView);
          exercicio_cardview = itemView.findViewById(R.id.exercicio_cardview);
          nome = itemView.findViewById(R.id.nome);
          peso = itemView.findViewById(R.id.peso);
          imx_exercicio = itemView.findViewById(R.id.imx_exercicio);
  
          itemView.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                  int position = getAdapterPosition();
                  if (listener != null &amp;&amp; position != RecyclerView.NO_POSITION) {
                      listener.onItemClick(getItem(position));
                  }
              }
          });
      }
  }
  
  public interface OnItemClickListener {
      void onItemClick(Exercicio exercicio);
  }
  
  public void setOnItemClickListener(OnItemClickListener listener) {
      this.listener = listener;
  }
  </code></pre>
  
  <p><strong>The problem:</strong> when an item is updated, changing the title for example, the list gets updated, but the eddited item disappears. If i end the activity and start it again, the item updated is there. So the problem must be the diff callback, but I'm not really able to make it work. Sorry for my English, this is not my main language, thanks all!</p>