Skip to content
This repository has been archived by the owner on Sep 27, 2020. It is now read-only.

Time to open (UI/Main thread) #54

Open
leonardosalles opened this issue Sep 15, 2017 · 1 comment
Open

Time to open (UI/Main thread) #54

leonardosalles opened this issue Sep 15, 2017 · 1 comment

Comments

@leonardosalles
Copy link

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.

@DaDanny
Copy link

DaDanny commented Oct 24, 2017

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 👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants