Skip to content

Commit 115b6ab

Browse files
authored
Android upstream fixes (#27)
Android upstream fixes
2 parents 83a3ab2 + eb3b833 commit 115b6ab

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

android/src/main/java/com/documentscanner/ImageProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ private void processPreviewFrame(PreviewFrame previewFrame) {
102102
if (detectPreviewDocument(frame) && focused) {
103103
numOfSquares++;
104104
double now = (double)(new Date()).getTime() / 1000.0;
105-
if (numOfSquares == numOfRectangles && now < lastCaptureTime + durationBetweenCaptures) {
105+
if (numOfSquares == numOfRectangles && now > lastCaptureTime + durationBetweenCaptures) {
106106
lastCaptureTime = now;
107107
numOfSquares = 0;
108108
mMainActivity.requestPicture();

src/index.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,23 @@ class PdfScanner extends React.Component<PdfScannerProps> {
8484
}
8585
}
8686

87+
componentDidUpdate(prevProps: PdfScannerProps) {
88+
if (Platform.OS === 'android') {
89+
if (this.props.onPictureTaken !== prevProps.onPictureTaken) {
90+
if (prevProps.onPictureTaken)
91+
DeviceEventEmitter.removeListener('onPictureTaken', prevProps.onPictureTaken)
92+
if (this.props.onPictureTaken)
93+
DeviceEventEmitter.addListener('onPictureTaken', this.props.onPictureTaken)
94+
}
95+
if (this.props.onProcessing !== prevProps.onProcessing) {
96+
if (prevProps.onProcessing)
97+
DeviceEventEmitter.removeListener('onProcessingChange', prevProps.onProcessing)
98+
if (this.props.onProcessing)
99+
DeviceEventEmitter.addListener('onProcessingChange', this.props.onProcessing)
100+
}
101+
}
102+
}
103+
87104
componentWillUnmount () {
88105
if (Platform.OS === 'android') {
89106
const { onPictureTaken, onProcessing } = this.props

0 commit comments

Comments
 (0)