@@ -58,8 +58,8 @@ public static CrimeFragment newInstance(UUID crimeId) {
5858 @ Override
5959 public void onCreate (Bundle savedInstanceState ) {
6060 super .onCreate (savedInstanceState );
61-
62- UUID crimeId = (UUID )getArguments ().getSerializable (EXTRA_CRIME_ID );
61+
62+ UUID crimeId = (UUID ) getArguments ().getSerializable (EXTRA_CRIME_ID );
6363 mCrime = CrimeLab .get (getActivity ()).getCrime (crimeId );
6464
6565 setHasOptionsMenu (true );
@@ -73,10 +73,10 @@ public void updateDate() {
7373 @ TargetApi (11 )
7474 public View onCreateView (LayoutInflater inflater , ViewGroup parent , Bundle savedInstanceState ) {
7575 View v = inflater .inflate (R .layout .fragment_crime , parent , false );
76-
76+
7777 getActionBar ().setDisplayHomeAsUpEnabled (true );
7878
79- mTitleField = (EditText )v .findViewById (R .id .crime_title );
79+ mTitleField = (EditText ) v .findViewById (R .id .crime_title );
8080 mTitleField .setText (mCrime .getTitle ());
8181 mTitleField .addTextChangedListener (new TextWatcher () {
8282 public void onTextChanged (CharSequence c , int start , int before , int count ) {
@@ -91,62 +91,61 @@ public void afterTextChanged(Editable c) {
9191 // this one too
9292 }
9393 });
94-
95- mSolvedCheckBox = (CheckBox )v .findViewById (R .id .crime_solved );
94+
95+ mSolvedCheckBox = (CheckBox ) v .findViewById (R .id .crime_solved );
9696 mSolvedCheckBox .setChecked (mCrime .isSolved ());
9797 mSolvedCheckBox .setOnCheckedChangeListener (new OnCheckedChangeListener () {
9898 public void onCheckedChanged (CompoundButton buttonView , boolean isChecked ) {
9999 // set the crime's solved property
100100 mCrime .setSolved (isChecked );
101101 }
102102 });
103-
104- mDateButton = (Button )v .findViewById (R .id .crime_date );
103+ mDateButton = (Button ) v .findViewById (R .id .crime_date );
105104 updateDate ();
106105 mDateButton .setOnClickListener (new View .OnClickListener () {
107106 public void onClick (View v ) {
108107 FragmentManager fm = getActivity ()
109108 .getFragmentManager ();
110109 DatePickerFragment dialog = DatePickerFragment
111- .newInstance (mCrime .getDate ());
110+ .newInstance (mCrime .getDate ());
112111 dialog .setTargetFragment (CrimeFragment .this , REQUEST_DATE );
113112 dialog .show (fm , DIALOG_DATE );
114113 }
115114 });
116-
117- mPhotoButton = (ImageButton )v .findViewById (R .id .crime_imageButton );
115+
116+ mPhotoButton = (ImageButton ) v .findViewById (R .id .crime_imageButton );
118117 mPhotoButton .setOnClickListener (new View .OnClickListener () {
119118 public void onClick (View v ) {
120119 // launch the camera activity
121120 Intent i = new Intent (getActivity (), CrimeCameraActivity .class );
122121 startActivityForResult (i , REQUEST_PHOTO );
123122 }
124123 });
125-
124+
126125 // if camera is not available, disable camera functionality
127126 PackageManager pm = getActivity ().getPackageManager ();
128127 if (!pm .hasSystemFeature (PackageManager .FEATURE_CAMERA ) &&
129128 !pm .hasSystemFeature (PackageManager .FEATURE_CAMERA_FRONT )) {
130129 mPhotoButton .setEnabled (false );
131130 }
132131
133- mPhotoView = (ImageView )v .findViewById (R .id .crime_imageView );
132+ mPhotoView = (ImageView ) v .findViewById (R .id .crime_imageView );
134133 mPhotoView .setOnClickListener (new View .OnClickListener () {
135134 public void onClick (View v ) {
136135 Photo p = mCrime .getPhoto ();
137- if (p == null )
136+ if (p == null )
138137 return ;
139138
140139 FragmentManager fm = getActivity ()
141- .getFragmentManager ();
140+ .getFragmentManager ();
142141 String path = getActivity ()
143- .getFileStreamPath (p .getFilename ()).getAbsolutePath ();
142+ .getFileStreamPath (p .getFilename ()).getAbsolutePath ();
144143 ImageFragment .createInstance (path )
145- .show (fm , DIALOG_IMAGE );
144+ .show (fm , DIALOG_IMAGE );
146145 }
147146 });
148-
149- mSuspectButton = (Button )v .findViewById (R .id .crime_suspectButton );
147+
148+ mSuspectButton = (Button ) v .findViewById (R .id .crime_suspectButton );
150149 mSuspectButton .setOnClickListener (new View .OnClickListener () {
151150 public void onClick (View v ) {
152151 Intent i = new Intent (Intent .ACTION_PICK , ContactsContract .Contacts .CONTENT_URI );
@@ -157,7 +156,7 @@ public void onClick(View v) {
157156 mSuspectButton .setText (mCrime .getSuspect ());
158157 }
159158
160- Button reportButton = (Button )v .findViewById (R .id .crime_reportButton );
159+ Button reportButton = (Button ) v .findViewById (R .id .crime_reportButton );
161160 reportButton .setOnClickListener (new View .OnClickListener () {
162161 public void onClick (View v ) {
163162 Intent i = new Intent (Intent .ACTION_SEND );
@@ -166,19 +165,19 @@ public void onClick(View v) {
166165 i .putExtra (Intent .EXTRA_SUBJECT , getString (R .string .crime_report_subject ));
167166 i = Intent .createChooser (i , getString (R .string .send_report ));
168167 startActivity (i );
169- }
168+ }
170169 });
171-
172- return v ;
170+
171+ return v ;
173172 }
174-
173+
175174 private void showPhoto () {
176175 // (re)set the image button's image based on our photo
177176 Photo p = mCrime .getPhoto ();
178177 BitmapDrawable b = null ;
179178 if (p != null ) {
180179 String path = getActivity ()
181- .getFileStreamPath (p .getFilename ()).getAbsolutePath ();
180+ .getFileStreamPath (p .getFilename ()).getAbsolutePath ();
182181 b = PictureUtils .getScaledDrawable (getActivity (), path );
183182 }
184183 mPhotoView .setImageDrawable (b );
@@ -195,32 +194,32 @@ public void onStart() {
195194 super .onStart ();
196195 showPhoto ();
197196 }
198-
197+
199198 @ Override
200199 public void onActivityResult (int requestCode , int resultCode , Intent data ) {
201200 if (resultCode != Activity .RESULT_OK ) return ;
202201 if (requestCode == REQUEST_DATE ) {
203- Date date = (Date )data .getSerializableExtra (DatePickerFragment .EXTRA_DATE );
202+ Date date = (Date ) data .getSerializableExtra (DatePickerFragment .EXTRA_DATE );
204203 mCrime .setDate (date );
205204 updateDate ();
206205 } else if (requestCode == REQUEST_PHOTO ) {
207206 // create a new Photo object and attach it to the crime
208207 String filename = data
209- .getStringExtra (CrimeCameraFragment .EXTRA_PHOTO_FILENAME );
208+ .getStringExtra (CrimeCameraFragment .EXTRA_PHOTO_FILENAME );
210209 if (filename != null ) {
211210 Photo p = new Photo (filename );
212211 mCrime .setPhoto (p );
213212 showPhoto ();
214213 }
215214 } else if (requestCode == REQUEST_CONTACT ) {
216215 Uri contactUri = data .getData ();
217- String [] queryFields = new String [] { ContactsContract .Contacts .DISPLAY_NAME_PRIMARY };
216+ String [] queryFields = new String []{ ContactsContract .Contacts .DISPLAY_NAME_PRIMARY };
218217 Cursor c = getActivity ().getContentResolver ()
219- .query (contactUri , queryFields , null , null , null );
218+ .query (contactUri , queryFields , null , null , null );
220219
221220 if (c .getCount () == 0 ) {
222221 c .close ();
223- return ;
222+ return ;
224223 }
225224
226225 c .moveToFirst ();
@@ -230,7 +229,7 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) {
230229 c .close ();
231230 }
232231 }
233-
232+
234233 private String getCrimeReport () {
235234 String solvedString = null ;
236235 if (mCrime .isSolved ()) {
@@ -268,6 +267,6 @@ public boolean onOptionsItemSelected(MenuItem item) {
268267 return true ;
269268 default :
270269 return super .onOptionsItemSelected (item );
271- }
270+ }
272271 }
273272}
0 commit comments