|
@@ -1,11 +1,14 @@
|
|
|
package com.sybotan.android.demo.activities.poc
|
|
|
|
|
|
+import android.content.Intent
|
|
|
import android.os.Bundle
|
|
|
+import android.widget.Button
|
|
|
import android.widget.ImageView
|
|
|
import android.widget.ListView
|
|
|
import com.sybotan.android.demo.R
|
|
|
import com.sybotan.android.demo.activities.BaseActivity
|
|
|
-import com.sybotan.android.demo.entitiies.Device
|
|
|
+import com.sybotan.android.demo.adapter.DeviceTypeAdapter
|
|
|
+import com.sybotan.android.demo.entitiies.DeviceType
|
|
|
import com.sybotan.android.demo.retrofit.BaseViewModelInterface
|
|
|
import com.sybotan.android.demo.viewmodel.DeviceVM
|
|
|
|
|
@@ -15,40 +18,32 @@ class DeviceTypeActivity : BaseActivity() {
|
|
|
super.onCreate(savedInstanceState)
|
|
|
setContentView(R.layout.activity_device_type)
|
|
|
typeLv = findViewById(R.id.typeLv)
|
|
|
- /* val adapter = TreeAdapter(datas(), this, typeLv)
|
|
|
- typeLv.adapter = adapter*/
|
|
|
-
|
|
|
- /* adapter.setOnTreeNodeClickListener(object : OnTreeNodeClickListener<Data> {
|
|
|
- override fun onClick(node: Node<Data>, position: Int) {
|
|
|
- if (!node.isLeaf) return
|
|
|
- val intent = Intent()
|
|
|
- intent.putExtra("device", "${node.data.label} -> 13213213213")
|
|
|
- setResult(1, intent)
|
|
|
- finish()
|
|
|
- }
|
|
|
-
|
|
|
- })*/
|
|
|
+
|
|
|
val backIv = findViewById<ImageView>(R.id.backIv)
|
|
|
backIv.setOnClickListener {
|
|
|
finish()
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- /*val saveBtn = findViewById<Button>(R.id.saveBtn)
|
|
|
+ val saveBtn = findViewById<Button>(R.id.saveBtn)
|
|
|
saveBtn.setOnClickListener {
|
|
|
val intent = Intent()
|
|
|
- intent.putExtra("device", "13213213213")
|
|
|
- setResult(1, intent)
|
|
|
- }*/
|
|
|
+ intent.putExtra("type", mType)
|
|
|
+ setResult(DeviceActivity.RES_CODE_DEVICE, intent)
|
|
|
+ finish()
|
|
|
+ }
|
|
|
initViewModel()
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ var mType: DeviceType? = null
|
|
|
+
|
|
|
private fun initViewModel() {
|
|
|
val deviceVM = DeviceVM(BaseViewModelInterface { name, params ->
|
|
|
- val types = params as List<Device>
|
|
|
-
|
|
|
- //val adapter = TreeAdapter(types, this, typeLv)
|
|
|
- // typeLv.adapter = adapter
|
|
|
+ val types = params as List<DeviceType>
|
|
|
+ val adapter = DeviceTypeAdapter(types, this@DeviceTypeActivity) {
|
|
|
+ mType = it
|
|
|
+ }
|
|
|
+ typeLv.adapter = adapter
|
|
|
}, this)
|
|
|
|
|
|
deviceVM.getDeviceType()
|