Michaelvilleneuve / react-native-document-scanner

Document scanner, features live border detection, perspective correction, image filters and more ! 📲📸
MIT License
843 stars 289 forks source link

[BUG] please fix crash for android when onActivityResult called from other module but documentScanner = null #103

Open fukemy opened 1 year ago

fukemy commented 1 year ago

Hi, I am using other lib(photo editor), it's using onActivityResult to get the image, but the module onActivityResult triggered + documentScanner = null => app crashed

Please fix like this to avoid crash

private ActivityEventListener activityEventListener = new BaseActivityEventListener() {
        @Override
        public void onActivityResult(
                final Activity activity,
                final int requestCode,
                final int resultCode,
                final Intent intent) {
            // trigger callbacks (success, cancel, error)
            if (requestCode == DOCUMENT_SCAN_REQUEST) {
                if(documentScanner != null){
                    documentScanner.handleDocumentScanIntentResult(
                            new ActivityResult(resultCode, intent)
                    );
                }
            }
        }
    };