@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode != Activity.RESULT_OK) return; if (requestCode == REQUEST_DATE) { Date date = (Date) data.getSerializableExtra(DatePickerFragment.EXTRA_DATE); crime.setDate(date); updateDate(); } }
public Crime getCrime() { String uuidString = getString(getColumnIndex(CrimeTable.Cols.UUID)); String title = getString(getColumnIndex(CrimeTable.Cols.TITLE)); long date = getLong(getColumnIndex(CrimeTable.Cols.DATE)); int isSolved = getInt(getColumnIndex(CrimeTable.Cols.SOLVED)); String suspect = getString(getColumnIndex(CrimeTable.Cols.SUSPECT)); Crime crime = new Crime(UUID.fromString(uuidString)); crime.setTitle(title); crime.setDate(new Date(date)); crime.setSolved(isSolved != 0); crime.setSuspect(suspect); return crime; }
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode != Activity.RESULT_OK) { return; } if (requestCode == REQUEST_DATE) { Date date = (Date) data.getSerializableExtra(DatePickerFragment.EXTRA_DATE); mCrime.setDate(date); updateDate(); } else if (requestCode == REQUEST_TIME) { Date date = (Date) data.getSerializableExtra(TimePickerFragment.EXTRA_TIME); mCrime.setTime(date); updateTime(); } else if (requestCode == REQUEST_CONTACT && data != null) { Uri contactUri = data.getData(); String[] queryFields = new String[] {ContactsContract.Contacts.DISPLAY_NAME}; Cursor c = getActivity().getContentResolver().query(contactUri, queryFields, null, null, null); try { if (c.getCount() == 0) { return; } c.moveToFirst(); String suspect = c.getString(0); mCrime.setSuspect(suspect); mSuspectButton.setText(suspect); } finally { c.close(); } } else if (requestCode == REQUEST_PHOTO) { updatePhotoView(); } }