package io.scanbot.barcodesdk.plugin.reactnative.extensions import android.content.res.Resources import io.scanbot.barcodesdk.plugin.reactnative.components.barcode_scanner_view.BarcodeErrorEvent import io.scanbot.barcodesdk.plugin.reactnative.components.barcode_scanner_view.ScanbotBarcodeScannerView fun Int.toPx(resources: Resources): Int { return (this * resources.displayMetrics.density).toInt() } fun io.scanbot.common.Result.getOrSendBarcodeErrorEvent(view: ScanbotBarcodeScannerView): T? { return try { this.getOrThrow() } catch (ex: Throwable) { view.sendEvent(BarcodeErrorEvent(ex)) null } }