pull/480/head
gedoor 4 years ago
parent c71a525de8
commit cf919ee682
  1. 12
      app/src/main/java/io/legado/app/ui/qrcode/QrCodeActivity.kt
  2. 6
      app/src/main/java/io/legado/app/ui/replace/edit/ReplaceEditActivity.kt

@ -64,17 +64,20 @@ class QrCodeActivity : BaseActivity(R.layout.activity_qrcode_capture), QRCodeVie
.rationale(R.string.qr_per) .rationale(R.string.qr_per)
.onGranted { .onGranted {
zxingview.visibility = View.VISIBLE zxingview.visibility = View.VISIBLE
zxingview.startSpotAndShowRect() // 显示扫描框,并开始识别 //TODO 显示扫描框,并开始识别
zxingview.startSpotAndShowRect()
}.request() }.request()
} }
override fun onStop() { override fun onStop() {
zxingview.stopCamera() // 关闭摄像头预览,并且隐藏扫描框 //TODO 关闭摄像头预览,并且隐藏扫描框
zxingview.stopCamera()
super.onStop() super.onStop()
} }
override fun onDestroy() { override fun onDestroy() {
zxingview.onDestroy() // 销毁二维码扫描控件 //TODO 销毁二维码扫描控件
zxingview.onDestroy()
super.onDestroy() super.onDestroy()
} }
@ -96,7 +99,8 @@ class QrCodeActivity : BaseActivity(R.layout.activity_qrcode_capture), QRCodeVie
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data) super.onActivityResult(requestCode, resultCode, data)
data?.data?.let { data?.data?.let {
zxingview.startSpotAndShowRect() // 显示扫描框,并开始识别 //TODO 显示扫描框,并开始识别
zxingview.startSpotAndShowRect()
if (resultCode == Activity.RESULT_OK && requestCode == requestQrImage) { if (resultCode == Activity.RESULT_OK && requestCode == requestQrImage) {
// 本来就用到 QRCodeView 时可直接调 QRCodeView 的方法,走通用的回调 // 本来就用到 QRCodeView 时可直接调 QRCodeView 的方法,走通用的回调

@ -117,11 +117,13 @@ class ReplaceEditActivity :
if (view is EditText) { if (view is EditText) {
val start = view.selectionStart val start = view.selectionStart
val end = view.selectionEnd val end = view.selectionEnd
val edit = view.editableText//获取EditText的文字 //TODO 获取EditText的文字
val edit = view.editableText
if (start < 0 || start >= edit.length) { if (start < 0 || start >= edit.length) {
edit.append(text) edit.append(text)
} else { } else {
edit.replace(start, end, text)//光标所在位置插入文字 //TODO 光标所在位置插入文字
edit.replace(start, end, text)
} }
} }
} }

Loading…
Cancel
Save