Android-Image-Cropper
Android-Image-Cropper copied to clipboard
ActivityResultContract for custom activity
It would be nice if CropImageContract
allows to provide custom activity class. Currently I need to implement custom contract with delegation to library implementation:
class CustomCropImageContract :
ActivityResultContract<CropImageContractOptions, CropImageView.CropResult>() {
private val delegate = CropImageContract()
override fun createIntent(context: Context, input: CropImageContractOptions): Intent {
return delegate.createIntent(context, input).apply {
setClass(context, CropImage::class.java)
}
}
override fun parseResult(resultCode: Int, intent: Intent?): CropImageView.CropResult {
return delegate.parseResult(resultCode, intent)
}
override fun getSynchronousResult(
context: Context,
input: CropImageContractOptions
): SynchronousResult<CropImageView.CropResult>? {
return delegate.getSynchronousResult(context, input)
}
}
CropImageContractOptions
may be a good place to provide custom class
.