Пример #1
0
  private void updateUI() {
    CrimeLab crimeLab = CrimeLab.get(getActivity());
    List<Crime> crimes = crimeLab.getCrimes();

    if (mAdapter == null) {
      mAdapter = new CrimeAdapter(crimes);
      mCrimeRecyclerView.setAdapter(mAdapter);
    } else {
      mAdapter.notifyItemChanged(mCrimePosition);
    }
  }
  /** Updates the Interface with all the crimes in recycler views */
  private void updateUI() {
    CrimeLab crimelab = CrimeLab.get(getActivity());
    List<Crime> crimes = crimelab.getCrimes();

    if (mAdapter == null) {
      mAdapter = new CrimeAdapter(crimes);
      mCrimeRecyclerView.setAdapter(mAdapter);
    } else {
      mAdapter.setCrimes(crimes);
      if (mPreviousAdapterSelected < 0) mAdapter.notifyDataSetChanged();
      else {
        mAdapter.notifyItemChanged(mPreviousAdapterSelected);
        mPreviousAdapterSelected = -1;
      }
    }

    // make sure number of crimes stays up to date
    updateSubtitle();
  }