|
@@ -3,27 +3,61 @@ package com.sybotan.android.demo.activities.poc
|
|
|
import android.content.Intent
|
|
|
import android.os.Bundle
|
|
|
import android.support.constraint.ConstraintLayout
|
|
|
+import android.view.View
|
|
|
import android.widget.Button
|
|
|
+import android.widget.ImageView
|
|
|
+import android.widget.TextView
|
|
|
import android.widget.Toast
|
|
|
import com.sybotan.android.demo.R
|
|
|
import com.sybotan.android.demo.activities.BaseActivity
|
|
|
-import org.jetbrains.anko.startActivity
|
|
|
+import com.zbar.lib.CaptureActivity
|
|
|
|
|
|
class DeviceActivity : BaseActivity() {
|
|
|
+ companion object {
|
|
|
+ const val REQ_CODE_DEVICE = 1
|
|
|
+ const val REQ_CODE_QR = 2
|
|
|
+ const val REQ_CODE_INFO = 3
|
|
|
+ const val REQ_CODE_POS = 4
|
|
|
+
|
|
|
+ const val RES_CODE_DEVICE = 1
|
|
|
+ const val RES_CODE_QR = 2
|
|
|
+ const val RES_CODE_INFO = 3
|
|
|
+ const val RES_CODE_POS = 4
|
|
|
+ }
|
|
|
+
|
|
|
private var device: String = ""
|
|
|
+ private lateinit var infoMsgTv: TextView
|
|
|
+ private lateinit var infoOkIv: ImageView
|
|
|
+
|
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
|
super.onCreate(savedInstanceState)
|
|
|
setContentView(R.layout.activity_device)
|
|
|
val deviceCl = findViewById<ConstraintLayout>(R.id.deviceCl)
|
|
|
deviceCl.setOnClickListener {
|
|
|
val intent = Intent(this, DeviceTypeActivity::class.java)
|
|
|
- startActivityForResult(intent, 1)
|
|
|
+ startActivityForResult(intent, REQ_CODE_DEVICE)
|
|
|
}
|
|
|
+
|
|
|
val infoCl = findViewById<ConstraintLayout>(R.id.infoCl)
|
|
|
infoCl.setOnClickListener {
|
|
|
- startActivity<RecordInfoActivity>()
|
|
|
+ val intent = Intent(this, RecordInfoActivity::class.java)
|
|
|
+ startActivityForResult(intent, REQ_CODE_INFO)
|
|
|
+ }
|
|
|
+ infoMsgTv = findViewById(R.id.infoMsgTv)
|
|
|
+ infoOkIv = findViewById(R.id.infoOkIv)
|
|
|
+
|
|
|
+ val qrCl = findViewById<ConstraintLayout>(R.id.qrCl)
|
|
|
+ qrCl.setOnClickListener {
|
|
|
+ val intent = Intent(this, CaptureActivity::class.java)
|
|
|
+ startActivityForResult(intent, REQ_CODE_QR)
|
|
|
}
|
|
|
|
|
|
+ /*val posCl = findViewById<ConstraintLayout>(R.id.positionCl)
|
|
|
+ posCl.setOnClickListener {
|
|
|
+ val intent = Intent(this, ::class.java)
|
|
|
+ startActivityForResult(intent, INFO_REQ_CODE)
|
|
|
+ }*/
|
|
|
+
|
|
|
val saveBtn = findViewById<Button>(R.id.saveBtn)
|
|
|
saveBtn.setOnClickListener {
|
|
|
Toast.makeText(this@DeviceActivity, "hello", Toast.LENGTH_LONG).show()
|
|
@@ -31,14 +65,29 @@ class DeviceActivity : BaseActivity() {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
|
|
super.onActivityResult(requestCode, resultCode, data)
|
|
|
- if (requestCode == 1 && resultCode == 1) {
|
|
|
-
|
|
|
+ // 设备信息
|
|
|
+ if (requestCode == REQ_CODE_DEVICE && resultCode == RES_CODE_DEVICE) {
|
|
|
val bundle = data?.extras
|
|
|
val device = bundle?.getString("device") ?: ""
|
|
|
Toast.makeText(this, "device:$device", Toast.LENGTH_LONG).show()
|
|
|
}
|
|
|
+
|
|
|
+ // 二维码信息
|
|
|
+ if (requestCode == REQ_CODE_QR && resultCode == RESULT_OK) {
|
|
|
+ val bundle = data?.extras
|
|
|
+ val result = bundle?.getString(CaptureActivity.EXTRA_STRING) ?: ""
|
|
|
+ Toast.makeText(this, "qr:$result", Toast.LENGTH_LONG).show()
|
|
|
+ }
|
|
|
+
|
|
|
+ // 记录文本信息
|
|
|
+ if (requestCode == REQ_CODE_INFO && resultCode == RES_CODE_INFO) {
|
|
|
+ val bundle = data?.extras
|
|
|
+ val info = bundle?.getString("info") ?: ""
|
|
|
+ infoMsgTv.text = info
|
|
|
+ infoOkIv.visibility = if (info.isNotEmpty()) View.VISIBLE else View.INVISIBLE
|
|
|
+ Toast.makeText(this, "info:$info", Toast.LENGTH_LONG).show()
|
|
|
+ }
|
|
|
}
|
|
|
}
|