|
|
@ -1,9 +1,12 @@ |
|
|
|
package com.project.survey.ui.controlnet |
|
|
|
package com.project.survey.ui.controlnet |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import android.widget.ArrayAdapter |
|
|
|
import androidx.activity.viewModels |
|
|
|
import androidx.activity.viewModels |
|
|
|
|
|
|
|
import androidx.appcompat.widget.ListPopupWindow |
|
|
|
import com.bingce.utils.ThreadPoolUtil |
|
|
|
import com.bingce.utils.ThreadPoolUtil |
|
|
|
import com.project.survey.R |
|
|
|
import com.project.survey.R |
|
|
|
import com.project.survey.databinding.ActivitySpecialControlNetworkBinding |
|
|
|
import com.project.survey.databinding.ActivitySpecialControlNetworkBinding |
|
|
|
|
|
|
|
import com.project.survey.extend.setOnClickNoRepeatListener |
|
|
|
import com.project.survey.extend.smartDismiss |
|
|
|
import com.project.survey.extend.smartDismiss |
|
|
|
import com.project.survey.logic.viewmodel.ControlNetViewModel |
|
|
|
import com.project.survey.logic.viewmodel.ControlNetViewModel |
|
|
|
import com.project.survey.model.ControlNetVersionBean |
|
|
|
import com.project.survey.model.ControlNetVersionBean |
|
|
@ -36,11 +39,22 @@ class SpecialControlNetworkActivity : |
|
|
|
private var currentPage = 1 |
|
|
|
private var currentPage = 1 |
|
|
|
private var currentVersion: String? = null |
|
|
|
private var currentVersion: String? = null |
|
|
|
private var currentName: String? = null // 控制网名称 |
|
|
|
private var currentName: String? = null // 控制网名称 |
|
|
|
private var versionList = ArrayList<SpecialControlNetworkVersionBean>() |
|
|
|
|
|
|
|
|
|
|
|
// private var versionList = ArrayList<SpecialControlNetworkVersionBean>() |
|
|
|
|
|
|
|
private var versionNameList = |
|
|
|
|
|
|
|
arrayListOf(SpecialControlNetworkVersionBean("版本号", "控制网名称")) |
|
|
|
|
|
|
|
private var versionList = ArrayList<String>() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private val nameListPopupWindow by lazy { ListPopupWindow(this) } |
|
|
|
|
|
|
|
private val versionListPopupWindow by lazy { ListPopupWindow(this) } |
|
|
|
|
|
|
|
private var versionAdapter: ArrayAdapter<String>? = null |
|
|
|
|
|
|
|
|
|
|
|
override fun initView() { |
|
|
|
override fun initView() { |
|
|
|
immersionToolbar(mBinding.toolbar, R.string.dedicated_control_network) |
|
|
|
immersionToolbar(mBinding.toolbar, R.string.dedicated_control_network) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
nameListPopupWindow.anchorView = mBinding.tvSpinnerName |
|
|
|
|
|
|
|
versionListPopupWindow.anchorView = mBinding.tvSpinnerVersion |
|
|
|
|
|
|
|
|
|
|
|
mBinding.smartRefreshLayout.setOnRefreshLoadMoreListener(this) |
|
|
|
mBinding.smartRefreshLayout.setOnRefreshLoadMoreListener(this) |
|
|
|
// mBinding.recyclerView.addItemDecoration(TransparentDividerDecoration(this)) |
|
|
|
// mBinding.recyclerView.addItemDecoration(TransparentDividerDecoration(this)) |
|
|
|
mBinding.recyclerView.adapter = adapter |
|
|
|
mBinding.recyclerView.adapter = adapter |
|
|
@ -53,12 +67,23 @@ class SpecialControlNetworkActivity : |
|
|
|
} |
|
|
|
} |
|
|
|
// 版本号列表 |
|
|
|
// 版本号列表 |
|
|
|
viewModel.specialControlNetworkVersionResponse.observe(this) { |
|
|
|
viewModel.specialControlNetworkVersionResponse.observe(this) { |
|
|
|
versionList.addAll(it) |
|
|
|
versionNameList.addAll(it) |
|
|
|
versionList.add(0, SpecialControlNetworkVersionBean("版本号", "控制网名称")) |
|
|
|
// versionList.add(0, SpecialControlNetworkVersionBean("版本号", "控制网名称")) |
|
|
|
mBinding.spinnerName.setItems(versionList.map { v -> v.KZW_NAME }) |
|
|
|
// mBinding.spinnerName.setItems(versionList.map { v -> v.KZW_NAME }) |
|
|
|
|
|
|
|
val nameAdapter = ArrayAdapter<String>( |
|
|
|
val versionList = versionList[0].version_array.split(",").toList() |
|
|
|
this, |
|
|
|
mBinding.spinnerVersion.setItems(versionList) |
|
|
|
android.R.layout.simple_list_item_1, |
|
|
|
|
|
|
|
versionNameList.map { it.KZW_NAME }) |
|
|
|
|
|
|
|
nameListPopupWindow.setAdapter(nameAdapter) |
|
|
|
|
|
|
|
mBinding.tvSpinnerName.text = versionNameList[0].KZW_NAME |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
versionList.clear() |
|
|
|
|
|
|
|
versionList.addAll(versionNameList[0].version_array.split(",").toList()) |
|
|
|
|
|
|
|
versionAdapter = |
|
|
|
|
|
|
|
ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, versionList) |
|
|
|
|
|
|
|
versionListPopupWindow.setAdapter(versionAdapter) |
|
|
|
|
|
|
|
mBinding.tvSpinnerVersion.text = versionList[0] |
|
|
|
|
|
|
|
// mBinding.spinnerVersion.setItems(versionList) |
|
|
|
} |
|
|
|
} |
|
|
|
viewModel.controlNetworkListResponse.observe(this) { |
|
|
|
viewModel.controlNetworkListResponse.observe(this) { |
|
|
|
mBinding.smartRefreshLayout.smartDismiss() |
|
|
|
mBinding.smartRefreshLayout.smartDismiss() |
|
|
@ -96,34 +121,65 @@ class SpecialControlNetworkActivity : |
|
|
|
|
|
|
|
|
|
|
|
override fun initListener() { |
|
|
|
override fun initListener() { |
|
|
|
// 控制网名称 |
|
|
|
// 控制网名称 |
|
|
|
mBinding.spinnerName.setOnItemSelectedListener { view, position, id, item -> |
|
|
|
mBinding.tvSpinnerName.setOnClickNoRepeatListener { |
|
|
|
val bean = item as String |
|
|
|
nameListPopupWindow.show() |
|
|
|
currentName = if ("控制网名称" == bean) null else bean |
|
|
|
} |
|
|
|
|
|
|
|
nameListPopupWindow.setOnItemClickListener { adapterView, view, i, l -> |
|
|
|
val versionList = versionList[position].version_array.split(",").toList() |
|
|
|
nameListPopupWindow.dismiss() |
|
|
|
mBinding.spinnerVersion.setItems(versionList) |
|
|
|
currentName = if (i == 0) null else versionNameList[i].KZW_NAME |
|
|
|
currentVersion = if ("控制网名称" == bean) |
|
|
|
mBinding.tvSpinnerName.text = currentName ?: "控制网名称" |
|
|
|
null |
|
|
|
|
|
|
|
else { |
|
|
|
versionList.clear() |
|
|
|
if (versionList.isEmpty()) null else versionList[0].toString() |
|
|
|
versionList.addAll(versionNameList[i].version_array.split(",").toList()) |
|
|
|
} |
|
|
|
// val versionList = versionList[position].version_array.split(",").toList() |
|
|
|
|
|
|
|
versionAdapter?.notifyDataSetChanged() |
|
|
|
|
|
|
|
currentVersion = |
|
|
|
|
|
|
|
if (currentName == null) null else if (versionList.isEmpty()) null else versionList[0] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mBinding.tvSpinnerVersion.text = currentVersion ?: "版本号" |
|
|
|
|
|
|
|
|
|
|
|
currentPage = 1 |
|
|
|
currentPage = 1 |
|
|
|
fetchData() |
|
|
|
fetchData() |
|
|
|
ThreadPoolUtil.executeInMainDelay300 { |
|
|
|
|
|
|
|
mBinding.spinnerName.collapse() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// mBinding.spinnerName.setOnItemSelectedListener { view, position, id, item -> |
|
|
|
|
|
|
|
// val bean = item as String |
|
|
|
|
|
|
|
// currentName = if ("控制网名称" == bean) null else bean |
|
|
|
|
|
|
|
// |
|
|
|
|
|
|
|
// val versionList = versionList[position].version_array.split(",").toList() |
|
|
|
|
|
|
|
// mBinding.spinnerVersion.setItems(versionList) |
|
|
|
|
|
|
|
// currentVersion = if ("控制网名称" == bean) |
|
|
|
|
|
|
|
// null |
|
|
|
|
|
|
|
// else { |
|
|
|
|
|
|
|
// if (versionList.isEmpty()) null else versionList[0].toString() |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
// currentPage = 1 |
|
|
|
|
|
|
|
// fetchData() |
|
|
|
|
|
|
|
// ThreadPoolUtil.executeInMainDelay300 { |
|
|
|
|
|
|
|
// mBinding.spinnerName.collapse() |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
// } |
|
|
|
// 版本号 |
|
|
|
// 版本号 |
|
|
|
mBinding.spinnerVersion.setOnItemSelectedListener { _, _, _, item -> |
|
|
|
mBinding.tvSpinnerVersion.setOnClickNoRepeatListener { |
|
|
|
val version = item as String |
|
|
|
versionListPopupWindow.show() |
|
|
|
currentVersion = |
|
|
|
} |
|
|
|
if ("版本号" == version) null else version |
|
|
|
versionListPopupWindow.setOnItemClickListener { adapterView, view, i, l -> |
|
|
|
|
|
|
|
versionListPopupWindow.dismiss() |
|
|
|
|
|
|
|
currentVersion = if (i == 0) null else versionList[i] |
|
|
|
|
|
|
|
mBinding.tvSpinnerVersion.text = versionList[i] |
|
|
|
|
|
|
|
|
|
|
|
currentPage = 1 |
|
|
|
currentPage = 1 |
|
|
|
fetchData() |
|
|
|
fetchData() |
|
|
|
ThreadPoolUtil.executeInMainDelay300 { |
|
|
|
|
|
|
|
mBinding.spinnerVersion.collapse() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// mBinding.spinnerVersion.setOnItemSelectedListener { _, _, _, item -> |
|
|
|
|
|
|
|
// val version = item as String |
|
|
|
|
|
|
|
// currentVersion = |
|
|
|
|
|
|
|
// if ("版本号" == version) null else version |
|
|
|
|
|
|
|
// currentPage = 1 |
|
|
|
|
|
|
|
// fetchData() |
|
|
|
|
|
|
|
// ThreadPoolUtil.executeInMainDelay300 { |
|
|
|
|
|
|
|
// mBinding.spinnerVersion.collapse() |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
// } |
|
|
|
adapter.setOnItemClickListener { adapter, _, position -> |
|
|
|
adapter.setOnItemClickListener { adapter, _, position -> |
|
|
|
adapter.getItem(position)?.let { bean -> |
|
|
|
adapter.getItem(position)?.let { bean -> |
|
|
|
ControlPointActivity.start(bean.KZW_NAME) |
|
|
|
ControlPointActivity.start(bean.KZW_NAME) |
|
|
|