2.3.6 release
parent
c4398c51f2
commit
dd45c4610a
@ -0,0 +1,58 @@
|
||||
package com.rehome.zhdcoa.ui.activity
|
||||
|
||||
import android.content.Intent
|
||||
import android.util.Log
|
||||
import androidx.activity.result.ActivityResultLauncher
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager
|
||||
import com.rehome.zhdcoa.Contans
|
||||
import com.rehome.zhdcoa.base.BaseActivityOaToolbarViewBinding
|
||||
import com.rehome.zhdcoa.databinding.ActivityQrCodeInfoBinding
|
||||
|
||||
class QrCodeInfoActivity : BaseActivityOaToolbarViewBinding<ActivityQrCodeInfoBinding>() {
|
||||
|
||||
private lateinit var launcherResult: ActivityResultLauncher<Intent>
|
||||
|
||||
|
||||
override fun getViewBinding() = ActivityQrCodeInfoBinding.inflate(layoutInflater)
|
||||
|
||||
override fun getToolbar() = binding.toolbarView.toolbar
|
||||
|
||||
override fun initView() {
|
||||
initToolbar("读取二维码")
|
||||
setLeftOnClickListener {
|
||||
finish()
|
||||
}
|
||||
|
||||
launcherResult = createActivityResultLauncher()
|
||||
|
||||
|
||||
binding.tvScan.setOnClickListener {
|
||||
val intent = Intent(context, QrCodeActivity::class.java)
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP)
|
||||
launcherResult.launch(intent)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun initData() {
|
||||
|
||||
}
|
||||
|
||||
//创建一个ActivityResultLauncher
|
||||
private fun createActivityResultLauncher(): ActivityResultLauncher<Intent> {
|
||||
//kotlin写法
|
||||
return registerForActivityResult(ActivityResultContracts.StartActivityForResult()) {
|
||||
val resultIntent = it.data
|
||||
val resultCode = it.resultCode
|
||||
if (resultCode == RESULT_OK) {
|
||||
if(resultIntent!=null){
|
||||
val code = resultIntent.getStringExtra("code")
|
||||
binding.tvNfc.text = code
|
||||
showLog("---------二维码----------")
|
||||
showLog(code)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
tools:context=".ui.activity.QrCodeInfoActivity">
|
||||
|
||||
<include
|
||||
android:id="@+id/toolbarView"
|
||||
layout="@layout/layout_base" />
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginStart="10px"
|
||||
android:layout_marginEnd="10px"
|
||||
android:layout_marginBottom="10px"
|
||||
android:layout_weight="1">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_nfc"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:textColor="@color/viewfinder_mask"
|
||||
android:textSize="24sp"
|
||||
android:gravity="center"
|
||||
android:text="读取二维码" />
|
||||
|
||||
</FrameLayout>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp"
|
||||
android:background="@color/colorPrimary"
|
||||
android:orientation="vertical">
|
||||
<TextView
|
||||
android:id="@+id/tv_scan"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:textColor="@color/white"
|
||||
android:gravity="center"
|
||||
android:textSize="18sp"
|
||||
android:text="开始扫描二维码"/>
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
Loading…
Reference in New Issue