File tree Expand file tree Collapse file tree
app/src/main/java/org/fairscan/app/ui/screens/camera Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ import org.fairscan.app.domain.CapturedPage
3636import org.fairscan.app.platform.extractDocumentFromBitmap
3737import org.fairscan.imageprocessing.ImageSize
3838import org.fairscan.imageprocessing.detectDocumentQuad
39+ import java.util.concurrent.CancellationException
3940
4041sealed interface CameraEvent {
4142 data class ImageCaptured (val page : CapturedPage ) : CameraEvent
@@ -203,12 +204,18 @@ class CameraViewModel(appContainer: AppContainer): ViewModel() {
203204 _importState .value = ImportState .Importing (0 , uris.size)
204205 uris.forEachIndexed { index, uri ->
205206 ensureActive()
206- val photoToImport = imageLoader.load(uri)
207- ensureActive()
208- val page = processCapturedImage(photoToImport, 0 )
209- ensureActive()
210- page?.let {
211- _events .emit(CameraEvent .ImageCaptured (it))
207+ try {
208+ val photoToImport = imageLoader.load(uri)
209+ ensureActive()
210+ val page = processCapturedImage(photoToImport, 0 )
211+ ensureActive()
212+ page?.let {
213+ _events .emit(CameraEvent .ImageCaptured (it))
214+ }
215+ } catch (e: CancellationException ) {
216+ throw e
217+ } catch (e: Exception ) {
218+ logger.e(" Import" , " Failed to import image: $uri " , e)
212219 }
213220 _importState .value = ImportState .Importing (index + 1 , uris.size)
214221 }
You can’t perform that action at this time.
0 commit comments