From d18e2dffae00bd278bdefe41a3acdb0da64c65a8 Mon Sep 17 00:00:00 2001 From: Leon Date: Tue, 2 Apr 2019 11:18:26 +0800 Subject: [PATCH] fix black screen when manual focus --- .../kotlin/net/touchcapture/qr/flutterqr/QRView.kt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/android/src/main/kotlin/net/touchcapture/qr/flutterqr/QRView.kt b/android/src/main/kotlin/net/touchcapture/qr/flutterqr/QRView.kt index 1dce749..72fa5c6 100644 --- a/android/src/main/kotlin/net/touchcapture/qr/flutterqr/QRView.kt +++ b/android/src/main/kotlin/net/touchcapture/qr/flutterqr/QRView.kt @@ -42,6 +42,15 @@ class QRView(context: Context, private val registrar: PluginRegistry.Registrar, override fun possibleResultPoints(resultPoints: List) {} } ) + barcodeView.addOnAttachStateChangeListener(object : View.OnAttachStateChangeListener { + override fun onViewDetachedFromWindow(p0: View?) { + barcodeView.pause() + } + + override fun onViewAttachedToWindow(p0: View?) { + barcodeView.resume() + } + }) } @@ -54,7 +63,6 @@ class QRView(context: Context, private val registrar: PluginRegistry.Registrar, } override fun getView(): View { - barcodeView.pause() return barcodeView.apply { init() }