Skip to content

Commit 8594712

Browse files
committed
Refactor: Extract edit image intent method for media picker activity
1 parent f5cbb2e commit 8594712

File tree

1 file changed

+19
-21
lines changed

1 file changed

+19
-21
lines changed

WordPress/src/main/java/org/wordpress/android/ui/mediapicker/MediaPickerActivity.kt

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ class MediaPickerActivity : LocaleAwareActivity(), MediaPickerListener {
173173
return super.onOptionsItemSelected(item)
174174
}
175175

176-
@Suppress("DEPRECATION", "OVERRIDE_DEPRECATION", "LongMethod", "NestedBlockDepth")
176+
@Suppress("DEPRECATION", "OVERRIDE_DEPRECATION")
177177
override fun onActivityResult(
178178
requestCode: Int,
179179
resultCode: Int,
@@ -192,33 +192,31 @@ class MediaPickerActivity : LocaleAwareActivity(), MediaPickerListener {
192192
}
193193
}
194194
TAKE_PHOTO -> takeAPhoto()
195-
196-
IMAGE_EDITOR_EDIT_IMAGE -> {
197-
data?.let {
198-
val intent = Intent()
199-
val uris = WPMediaUtils.retrieveImageEditorResult(data)
200-
if (mediaPickerSetup.queueResults) {
201-
intent.putQueuedUris(uris)
202-
} else {
203-
intent.putUris(uris)
204-
}
205-
intent.putExtra(
206-
EXTRA_MEDIA_SOURCE,
207-
APP_PICKER.name
208-
)
209-
intent
210-
}
211-
}
212-
else -> {
213-
data
214-
}
195+
IMAGE_EDITOR_EDIT_IMAGE -> data?.let { editImageIntent(it) }
196+
else -> data
215197
}
198+
216199
intent?.let {
217200
setResult(Activity.RESULT_OK, intent)
218201
finish()
219202
}
220203
}
221204

205+
private fun editImageIntent(data: Intent?): Intent {
206+
val intent = Intent()
207+
val uris = WPMediaUtils.retrieveImageEditorResult(data)
208+
if (mediaPickerSetup.queueResults) {
209+
intent.putQueuedUris(uris)
210+
} else {
211+
intent.putUris(uris)
212+
}
213+
intent.putExtra(
214+
EXTRA_MEDIA_SOURCE,
215+
APP_PICKER.name
216+
)
217+
return intent
218+
}
219+
222220
private fun takeAPhoto() = try {
223221
val intent = Intent()
224222
mediaCapturePath!!.let {

0 commit comments

Comments
 (0)