|
@@ -1,88 +1,56 @@
|
|
|
package com.sybotan.android.demo.activities.poc
|
|
|
|
|
|
import android.os.Bundle
|
|
|
-import android.support.v7.app.AppCompatActivity
|
|
|
import android.widget.ImageView
|
|
|
import android.widget.ListView
|
|
|
import com.sybotan.android.demo.R
|
|
|
-import com.sybotan.android.demo.adapter.TreeAdapter
|
|
|
-import com.sybotan.android.demo.data.datas
|
|
|
+import com.sybotan.android.demo.activities.BaseActivity
|
|
|
+import com.sybotan.android.demo.entitiies.Device
|
|
|
+import com.sybotan.android.demo.retrofit.BaseViewModelInterface
|
|
|
+import com.sybotan.android.demo.viewmodel.DeviceVM
|
|
|
|
|
|
-class DeviceTypeActivity : AppCompatActivity() {
|
|
|
+class DeviceTypeActivity : BaseActivity() {
|
|
|
+ private lateinit var typeLv: ListView
|
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
|
super.onCreate(savedInstanceState)
|
|
|
setContentView(R.layout.activity_device_type)
|
|
|
- val typeLv = findViewById<ListView>(R.id.typeLv)
|
|
|
- val adapter = TreeAdapter(datas(), this, typeLv)
|
|
|
- typeLv.adapter = adapter
|
|
|
-
|
|
|
+ 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()
|
|
|
}
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-data class DeviceType(
|
|
|
- val rtn: Rtn
|
|
|
-)
|
|
|
|
|
|
-data class Rtn(
|
|
|
- val content: List<Content>,
|
|
|
- val message: String,
|
|
|
- val result: String,
|
|
|
- val total: Int
|
|
|
-)
|
|
|
|
|
|
-data class Content(
|
|
|
- val aliasCode: String,
|
|
|
- val aliasName: String,
|
|
|
- val children: List<Children>,
|
|
|
- val code: String,
|
|
|
- val groupCode: String,
|
|
|
- val name: String,
|
|
|
- val projectId: String
|
|
|
-)
|
|
|
-
|
|
|
-data class Children(
|
|
|
- val aliasCode: String,
|
|
|
- val aliasName: String,
|
|
|
- val children: List<ChildrenX>,
|
|
|
- val code: String,
|
|
|
- val createTime: String,
|
|
|
- val groupCode: String,
|
|
|
- val id: String,
|
|
|
- val lastUpdate: String,
|
|
|
- val majorCode: String,
|
|
|
- val name: String,
|
|
|
- val objType: String,
|
|
|
- val parentCode: String,
|
|
|
- val projectId: String,
|
|
|
- val statistics: StatisticsX,
|
|
|
- val type: String
|
|
|
-)
|
|
|
+ /*val saveBtn = findViewById<Button>(R.id.saveBtn)
|
|
|
+ saveBtn.setOnClickListener {
|
|
|
+ val intent = Intent()
|
|
|
+ intent.putExtra("device", "13213213213")
|
|
|
+ setResult(1, intent)
|
|
|
+ }*/
|
|
|
+ initViewModel()
|
|
|
+ }
|
|
|
|
|
|
-data class ChildrenX(
|
|
|
- val aliasCode: String,
|
|
|
- val aliasName: String,
|
|
|
- val code: String,
|
|
|
- val createTime: String,
|
|
|
- val groupCode: String,
|
|
|
- val id: String,
|
|
|
- val lastUpdate: String,
|
|
|
- val majorCode: String,
|
|
|
- val name: String,
|
|
|
- val objType: String,
|
|
|
- val parentCode: String,
|
|
|
- val projectId: String,
|
|
|
- val statistics: Statistics,
|
|
|
- val systemCode: String,
|
|
|
- val type: String
|
|
|
-)
|
|
|
+ private fun initViewModel() {
|
|
|
+ val deviceVM = DeviceVM(BaseViewModelInterface { name, params ->
|
|
|
+ val types = params as List<Device>
|
|
|
|
|
|
-class StatisticsX(
|
|
|
-)
|
|
|
+ //val adapter = TreeAdapter(types, this, typeLv)
|
|
|
+ // typeLv.adapter = adapter
|
|
|
+ }, this)
|
|
|
|
|
|
-class Statistics(
|
|
|
-)
|
|
|
+ deviceVM.getDeviceType()
|
|
|
+ }
|
|
|
+}
|