Challenge Solution - having trouble


Its me again, :wave: I see that the underlying assumption behind clicking a item in the list fragment would necessarily mean that the user changes the details of the crime. However, I did not presume this. Instead, I detect for change in the fields that can be modified by the user (title and isSolved) using the existing infrastructure (text changed listener and checked changed listener). If there is actually a change in one of the fields then I pass on the information as a boolean via the setResult method from the Fragment and get that from the onActivityResult. Additionally, I always save a index of the clicked item. So, when I actually detect a change, I use the index position information force a item level list reload via the notifyItemChanged(changedItemPosition).

private void updateUI() {
    CrimeLab crimeLab = CrimeLab.get(getActivity());
    List<Crime> crimes = crimeLab.getCrimes();

    if (adapter == null) {
        adapter = new CrimeAdapter(crimes);
    } else {
        Log.d("UpdateUI", "Position reported by click listener: " + clickedItemPosition);
        if (crimeRecordAltered) adapter.notifyItemChanged(clickedItemPosition);

I see that that I did not accommodate for the data refresh when the activity goes to the background and comes back to the screen again after a brief while. Besides this, is my solution correct.