cordova-plugin-crop
cordova-plugin-crop copied to clipboard
Time to open (UI/Main thread)
I am facing some problems to open the crop, it is very slowly, by searching about native threads I find something that is use to run the plugin in the main thread, my question right now is about to add that feature to the plugin, I made my own version with:
iOS (added when presentViewController):
dispatch_async(dispatch_get_main_queue(), ^{
PECropViewController *cropController = [[PECropViewController alloc] init];
cropController.delegate = self;
cropController.image = image;
CGFloat width = image.size.width;
CGFloat height = image.size.height;
CGFloat length = MIN(width, height);
cropController.toolbarHidden = YES;
cropController.rotationEnabled = NO;
cropController.keepingCropAspectRatio = NO;
cropController.imageCropRect = CGRectMake((width - length) / 2,
(height - length) / 2,
length,
length);
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:cropController];
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
navigationController.modalPresentationStyle = UIModalPresentationFormSheet;
}
[self.viewController presentViewController:navigationController animated:YES completion:NULL];
});
Android:
cordova.getActivity().runOnUiThread(new Runnable() {
public void run() {
Crop.of(cropPlugin.inputUri, cropPlugin.outputUri)
.start(cordova.getActivity());
}
});
Can you explain why it is not added to the plugin. In my case it solved all the problems when open the cropper and maybe I can create a PR to add this feature to the plugin.
Thanks.
It looks like your edits are in the CTCrop.m file for iOS and then the CropPlugin.java file for Android?
I will try out your changes and let you know how it runs for me, thanks for taking the time to improve this, this plugin came in handy 👍