| | |
| | | package cn.flightfeather.thirdappmodule.module.inspection |
| | | |
| | | import android.annotation.SuppressLint |
| | | import android.arch.lifecycle.Observer |
| | | import android.arch.lifecycle.ViewModelProviders |
| | | import android.os.Bundle |
| | | import android.support.v7.app.AppCompatActivity |
| | | import android.support.v7.widget.LinearLayoutManager |
| | | import android.view.View |
| | | import cn.flightfeather.thirdappmodule.R |
| | | import cn.flightfeather.thirdappmodule.adapter.AllRecyclerViewAdapter |
| | | import cn.flightfeather.thirdappmodule.bean.entity.Scense |
| | | import cn.flightfeather.thirdappmodule.bean.vo.SceneConstructionSite |
| | | import cn.flightfeather.thirdappmodule.module.base.BaseActivity |
| | | import cn.flightfeather.thirdappmodule.module.task.SceneDetailViewModel |
| | | import cn.flightfeather.thirdappmodule.util.Constant |
| | | import kotlinx.android.synthetic.main.dialog_scene_subinfo.* |
| | | |
| | | class MenuSceneInfoActivity : AppCompatActivity() { |
| | | /** |
| | | * 场景施工阶段管理界面 |
| | | * Date: 2025/10/27 |
| | | */ |
| | | class MenuSceneInfoActivity : BaseActivity() { |
| | | |
| | | private var scene: Scense? = null |
| | | private var statusAdapter: AllRecyclerViewAdapter<String>? = null |
| | | |
| | | override fun getLayoutId(): Int = R.layout.dialog_scene_subinfo |
| | | |
| | | lateinit var viewModel: SceneDetailViewModel |
| | | |
| | | override fun onCreate(savedInstanceState: Bundle?) { |
| | | super.onCreate(savedInstanceState) |
| | | |
| | | viewModel = ViewModelProviders.of(this).get(SceneDetailViewModel::class.java) |
| | | |
| | | scene = intent.getSerializableExtra("scene") as Scense? |
| | | |
| | | initUI() |
| | | initObserver() |
| | | initListener() |
| | | |
| | | viewModel.getSceneStatus { |
| | | statusAdapter?.notifyDataSetChanged() |
| | | scene?.let { viewModel.getSceneDetail(it) } |
| | | } |
| | | } |
| | | |
| | | private fun initUI() { |
| | | view_waiting.visibility = View.VISIBLE |
| | | scene?.let { |
| | | tv_title.text = StringBuilder(it.type + getString(R.string.scene_sub_info)) |
| | | tv_status.text = StringBuilder(it.type + getString(R.string.scene_status)) |
| | | } |
| | | } |
| | | |
| | | private fun initObserver() { |
| | | viewModel.subScene.observe(this, Observer { |
| | | view_waiting.visibility = View.GONE |
| | | val status = when (scene?.typeid.toString()) { |
| | | Constant.SCENE_TYPE_SITE -> { |
| | | (it as SceneConstructionSite?)?.siExtension1 |
| | | } |
| | | else -> "" |
| | | } |
| | | var index = viewModel.sceneStatus.indexOf(status) |
| | | if (index == -1) index = 0 |
| | | statusAdapter?.run { |
| | | setSelected(true, index) |
| | | notifyItemChanged(index) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | private fun initListener() { |
| | | statusAdapter = object : AllRecyclerViewAdapter<String>(viewModel.sceneStatus, R.layout.item_simple_radio, this) { |
| | | @SuppressLint("NotifyDataSetChanged") |
| | | override fun bindView(holder: MyViewHolder?, obj: String?, isSelected: Boolean, position: Int) { |
| | | holder?.setText(R.id.check_text, obj) |
| | | ?.setChecked(R.id.check_text, isSelected) |
| | | ?.setOnClickListener(R.id.check_text) { |
| | | setAllFalse() |
| | | setSelected(true, position) |
| | | notifyDataSetChanged() |
| | | (viewModel.subScene.value as SceneConstructionSite?)?.siExtension1 = obj |
| | | } |
| | | } |
| | | } |
| | | val lm = LinearLayoutManager(this) |
| | | lm.orientation = LinearLayoutManager.VERTICAL |
| | | rv_status!!.layoutManager = lm |
| | | rv_status!!.adapter = statusAdapter |
| | | |
| | | |
| | | fab_close.setOnClickListener { |
| | | this.finish() |
| | | } |
| | | fab_submit.setOnClickListener { |
| | | viewModel.updateSceneDetail(scene) { |
| | | this.finish() |
| | | } |
| | | } |
| | | } |
| | | } |