Skip to content

Commit f74e694

Browse files
authored
Merge pull request react-native-camera#1479 from react-native-community/rn-camera-bug-fix
Fix an error when closing the application.
2 parents 4a5f887 + 71a5355 commit f74e694

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

android/src/main/java/org/reactnative/camera/RNCameraView.java

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -371,8 +371,8 @@ private void setupBarcodeDetector() {
371371
}
372372

373373
/**
374-
* Initial setup of the text recongizer
375-
*/
374+
* Initial setup of the text recongizer
375+
*/
376376
private void setupTextRecongnizer() {
377377
mTextRecognizer = new TextRecognizer.Builder(mThemedReactContext).build();
378378
}
@@ -408,9 +408,9 @@ public void onBarcodeDetectingTaskCompleted() {
408408
}
409409

410410
public void setShouldRecognizeText(boolean shouldRecognizeText) {
411-
if (shouldRecognizeText && mTextRecognizer == null) {
412-
setupTextRecongnizer();
413-
}
411+
if (shouldRecognizeText && mTextRecognizer == null) {
412+
setupTextRecongnizer();
413+
}
414414
this.mShouldRecognizeText = shouldRecognizeText;
415415
setScanning(mShouldDetectFaces || mShouldGoogleDetectBarcodes || mShouldScanBarCodes || mShouldRecognizeText);
416416
}
@@ -457,8 +457,15 @@ public void onHostPause() {
457457

458458
@Override
459459
public void onHostDestroy() {
460-
mFaceDetector.release();
461-
mGoogleBarcodeDetector.release();
460+
if (mFaceDetector != null) {
461+
mFaceDetector.release();
462+
}
463+
if (mGoogleBarcodeDetector != null) {
464+
mGoogleBarcodeDetector.release();
465+
}
466+
if (mTextRecognizer != null) {
467+
mTextRecognizer.release();
468+
}
462469
mMultiFormatReader = null;
463470
stop();
464471
mThemedReactContext.removeLifecycleEventListener(this);

0 commit comments

Comments
 (0)