/** * Response to add crime action button. * * <p>Toggling the action item subtitle. * * @param item * @return */ @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.menu_item_new_crime: Crime crime = new Crime(); CrimeLab.getInstance(getActivity()).addCrime(crime); Intent intent = CrimePagerActivity.newIntent(getActivity(), crime.getId()); startActivity(intent); return true; case R.id.menu_item_show_subtitle: mSubtitleVisible = !mSubtitleVisible; getActivity().invalidateOptionsMenu(); updateSubtitle(); return true; default: return super.onOptionsItemSelected(item); } }
@Override public void onClick(View v) { Intent intent = CrimePagerActivity.newIntent(getActivity(), mCrime.getId()); startActivity(intent); }
/** * Helper method to update View with the Model * * @param crime */ public void bindCrime(Crime crime) { mCrime = crime; mTextViewTitle.setText(mCrime.getTitle()); mTextViewDate.setText(mCrime.getFormattedDate()); mCheckBoxSolved.setChecked(mCrime.isSolved()); }