title: Yet another Adapter.notifyDataSetChanged() not working - Android
body: <p>I have been using a method to populate an adapter like the following:</p>
  
  <ol>
  <li>Set the UI components in a custom method inside <code>onCreate(...)</code></li>
  </ol>
  
  <p></p>
  
  <pre><code>//..
  mRecentSales = new ArrayList&lt;&gt;();
          recentSaleAdapter = new RecentSaleAdapter(getApplicationContext(), R.layout.row_recent_sale, mRecentSales);
          lvRecentSales.setAdapter(recentSaleAdapter);
  //.
  </code></pre>
  
  <ol start="2">
  <li>Load in a different thread the data for the adapter just after <code>onResume()</code></li>
  </ol>
  
  <p></p>
  
  <pre><code>@Override
  public void onLoadingPrepare() {
      super.onLoadingPrepare();
      if (qDaySales == null)
          qDaySales = new ArrayList&lt;&gt;();
      else
          qDaySales.clear();
      if (mRecentSales == null)
          mRecentSales = new ArrayList&lt;&gt;();
      else
          mRecentSales.clear();
  }
  
  @Override
  public void onLoading() {
      super.onLoading();
      todayIncome = Conversor.asCurrency(presenter.getDaySales());
      performance = presenter.getImprovement(getApplicationContext());
      for (int i = 1; i&lt;= DateTime.now().getDayOfMonth(); i++){
          qDaySales.add(new Entry(i, presenter.getSalesFromDay(i)));
      }
      mRecentSales.addAll(presenter.getRecentSales());
  }
  
  @Override
  public void onLoadingComplete() {
      super.onLoadingComplete();
      tvTodayIncome.setText(todayIncome);
      tvPerformance.setText(performance);
      setPerformanceChart(qDaySales);
      recentSaleAdapter.notifyDataSetChanged();
  }
  </code></pre>
  
  <p>This is the Adapter code:</p>
  
  <pre><code>public class RecentSaleAdapter extends ArrayAdapter&lt;MTicket&gt; {
  
  public RecentSaleAdapter(@NonNull Context context, int resource, @NonNull List objects) {
      super(context, resource, objects);
  }
  
  @NonNull
  @Override
  public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
      if (convertView == null){
          convertView = LayoutInflater.from(getContext()).inflate(R.layout.row_recent_sale, null);
      }
      MTicket ticket = getItem(position);
      TextView tvTicketId = (TextView)convertView.findViewById(R.id.tv_ticket_id);
      TextView tvTicketReference = (TextView)convertView.findViewById(R.id.tv_ticket_reference);
      TextView tvTicketTotal = (TextView)convertView.findViewById(R.id.tv_ticket_total);
      if (ticket != null){
          tvTicketId.setText(String.format("# %d", ticket.id));
          tvTicketReference.setText(ticket.ticketReference);
          tvTicketTotal.setText(ticket.maskSaleTotal);
      }
      return convertView;
  }
  
  @Override
  public long getItemId(int position) {
      MTicket ticket = getItem(position);
      if (ticket != null)
          return ticket.id;
      return -1;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>The result is not what I've expected since the List does not shows anything.</p>