private String getCrimeReport() {
   String solvedString = null;
   if (mCrime.isSolved()) {
     solvedString = getString(R.string.crime_report_solved);
   } else {
     solvedString = getString(R.string.crime_report_unsolved);
   }
   String dateFormat = "EEE, MMM dd";
   String dateString = DateFormat.format(dateFormat, mCrime.getDate()).toString();
   String suspect = mCrime.getSuspect();
   if (suspect == null) {
     suspect = getString(R.string.crime_report_no_suspect);
   } else {
     suspect = getString(R.string.crime_report_suspect, suspect);
   }
   String report =
       getString(R.string.crime_report, mCrime.getTitle(), dateString, solvedString, suspect);
   return report;
 }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.fragment_crime, container, false);
    mTitleField = (EditText) v.findViewById(R.id.crime_title);
    mTitleField.setText(mCrime.getTitle());
    mTitleField.addTextChangedListener(
        new TextWatcher() {
          @Override
          public void beforeTextChanged(
              CharSequence charSequence, int i, int i1, int i2) { // Intentionally blank
          }

          @Override
          public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
            mCrime.setTitle(charSequence.toString());
          }

          @Override
          public void afterTextChanged(Editable editable) { // Intentionally blank
          }
        });

    mDateButton = (Button) v.findViewById(R.id.crime_date);
    mDateButton.setText(new DateFormat().format("EEE, MMM dd, yyyy", mCrime.getDate()));
    mDateButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            FragmentManager manager = getFragmentManager();
            DatePickerFragment dialog = DatePickerFragment.newInstance(mCrime.getDate());
            dialog.setTargetFragment(CrimeFragment.this, REQUEST_DATE);
            dialog.show(manager, DIALOG_DATE);
          }
        });

    mTimeButton = (Button) v.findViewById(R.id.crime_time);
    updateTime();
    mTimeButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            FragmentManager manager = getFragmentManager();
            TimePickerFragment dialog = TimePickerFragment.newInstance(mCrime.getDate());
            dialog.setTargetFragment(CrimeFragment.this, REQUEST_TIME);
            dialog.show(manager, DIALOG_TIME);
          }
        });

    mSolvedCheckBox = (CheckBox) v.findViewById(R.id.crime_solved);
    mSolvedCheckBox.setChecked(mCrime.isSolved());
    mSolvedCheckBox.setOnCheckedChangeListener(
        new CompoundButton.OnCheckedChangeListener() {
          @Override
          public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            mCrime.setSolved(isChecked);
          }
        });

    mReportButton = (Button) v.findViewById(R.id.crime_report);
    mReportButton.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            Intent i = new Intent(Intent.ACTION_SEND);
            i.setType("text/plain");
            i.putExtra(Intent.EXTRA_TEXT, getCrimeReport());
            i.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.crime_report_subject));
            startActivity(i);
          }
        });

    final Intent pickContact =
        new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI);
    mSuspectButton = (Button) v.findViewById(R.id.crime_suspect);
    mSuspectButton.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            startActivityForResult(pickContact, REQUEST_CONTACT);
          }
        });
    if (mCrime.getSuspect() != null) {
      mSuspectButton.setText(mCrime.getSuspect());
    }

    PackageManager packageManager = getActivity().getPackageManager();
    if (packageManager.resolveActivity(pickContact, PackageManager.MATCH_DEFAULT_ONLY) == null) {
      mSuspectButton.setEnabled(false);
    }

    return v;
  }