Source:
<code>protected void onActivityResult(final int requestCode, final int resultCode, final Intent data) { if (resultCode == RESULT_CANCELED) { showToast(getString(R.string.info_select_logimage_cancelled)); return; } if (resultCode != RESULT_OK) { showFailure(); return; } if (data != null) { final Uri selectedImage = data.getData(); if (selectedImage != null) { final String mimeType = getContentResolver().getType(selectedImage); if (!(("image/jpeg".equals(mimeType) || "image/png".equals(mimeType) || "image/gif".equals(mimeType)))) { showFailureUnsupportedImageFormat(); return; <START> } else { <END> if (Build.VERSION.SDK_INT < VERSION_CODES.KITKAT) { final String[] filePathColumn = { MediaColumns.DATA }; Cursor cursor = null; try { cursor = getContentResolver().query(selectedImage, filePathColumn, null, null, null); if (cursor == null) { showFailure(); return; } cursor.moveToFirst(); final int columnIndex = cursor.getColumnIndex(filePathColumn[0]); final String filePath = cursor.getString(columnIndex); if (StringUtils.isBlank(filePath)) { showFailure(); return; } image = new Image.Builder().setUrl(filePath).build(); } catch (final Exception e) { Log.e("ImageSelectActivity.onActivityResult", e); showFailure(); } finally { if (cursor != null) { cursor.close(); } } Log.d("SELECT IMAGE data = " + data.toString()); } else { InputStream input = null; OutputStream output = null; try { input = getContentResolver().openInputStream(selectedImage); final File outputFile = ImageUtils.getOutputImageFile(); if (outputFile != null) { output = new FileOutputStream(outputFile); IOUtils.copy(input, output); image = new Image.Builder().setUrl(outputFile).build(); } } catch (final IOException e) { Log.e("ImageSelectActivity.onActivityResult", e); } finally { IOUtils.closeQuietly(input); IOUtils.closeQuietly(output); } } } } else { showFailure(); return; } } if (requestCode == SELECT_NEW_IMAGE) { showToast(getString(R.string.info_stored_image) + '\n' + image.getUrl()); } loadImagePreview(); }</code><technical_language>Due return in if block, else is necessary. Omitting else reduces indentation for code</technical_language>

Target:
protected void onActivityResult(final int requestCode, final int resultCode, final Intent data) { if (resultCode == RESULT_CANCELED) { showToast(getString(R.string.info_select_logimage_cancelled)); return; } if (resultCode != RESULT_OK) { showFailure(); return; } if (data != null) { final Uri selectedImage = data.getData(); if (selectedImage != null) { final String mimeType = getContentResolver().getType(selectedImage); if (!("image/jpeg".equals(mimeType) || "image/png".equals(mimeType) || "image/gif".equals(mimeType))) { showToast(getString(R.string.err_unsupported_image_format)); return; } if (Build.VERSION.SDK_INT < VERSION_CODES.KITKAT) { final String[] filePathColumn = { MediaColumns.DATA }; Cursor cursor = null; try { cursor = getContentResolver().query(selectedImage, filePathColumn, null, null, null); if (cursor == null) { showFailure(); return; } cursor.moveToFirst(); final int columnIndex = cursor.getColumnIndex(filePathColumn[0]); final String filePath = cursor.getString(columnIndex); if (StringUtils.isBlank(filePath)) { showFailure(); return; } image = new Image.Builder().setUrl(filePath).build(); } catch (final Exception e) { Log.e("ImageSelectActivity.onActivityResult", e); showFailure(); } finally { if (cursor != null) { cursor.close(); } } Log.d("SELECT IMAGE data = " + data.toString()); } else { InputStream input = null; OutputStream output = null; try { input = getContentResolver().openInputStream(selectedImage); final File outputFile = ImageUtils.getOutputImageFile(); if (outputFile != null) { output = new FileOutputStream(outputFile); IOUtils.copy(input, output); image = new Image.Builder().setUrl(outputFile).build(); } } catch (final IOException e) { Log.e("ImageSelectActivity.onActivityResult", e); } finally { IOUtils.closeQuietly(input); IOUtils.closeQuietly(output); } } } else { showFailure(); return; } } if (requestCode == SELECT_NEW_IMAGE) { showToast(getString(R.string.info_stored_image) + '\n' + image.getUrl()); } loadImagePreview(); }