Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import com.getcode.libs.code.detection.CodeScanResult
import com.getcode.libs.qr.QrCodeAnalyzer
import com.kik.kikx.kikcodes.implementation.KikCodeAnalyzer
import com.kik.kikx.kikcodes.implementation.KikCodeScannerImpl
import kotlinx.coroutines.CoroutineExceptionHandler
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.SupervisorJob
Expand Down Expand Up @@ -76,7 +77,10 @@ class MultiCodeAnalyzer(
private var onError: (Throwable) -> Unit = { }

private val job = SupervisorJob()
private val scope = CoroutineScope(Dispatchers.IO + job)
private val exceptionHandler = CoroutineExceptionHandler { _, throwable ->
onError(throwable)
}
private val scope = CoroutineScope(Dispatchers.IO + job + exceptionHandler)

fun listen(listener: CodeScanListener) {
onCodeScanned = listener::onCodeScanned
Expand Down Expand Up @@ -111,7 +115,7 @@ class MultiCodeAnalyzer(
} catch (e: Exception) {
onError(e)
} finally {
image.close()
runCatching { image.close() }
}
}
}
Expand Down
Loading