riku
2025-10-27 0f58aa8ea118c3bd0b28396febc58fdbd94eef75
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
package cn.flightfeather.thirdappmodule.module.nightwork
 
import android.arch.lifecycle.Observer
import android.arch.lifecycle.ViewModelProviders
import android.content.Intent
import android.os.Bundle
import android.view.View
import cn.flightfeather.thirdappmodule.R
import cn.flightfeather.thirdappmodule.model.bean.NightWorkFileVo
import cn.flightfeather.thirdappmodule.module.base.BaseActivity
import cn.flightfeather.thirdappmodule.module.common.OfficeFileManageActivity
import cn.flightfeather.thirdappmodule.util.CommonUtils
import cn.flightfeather.thirdappmodule.view.recyclerview.BaseCustomViewHolder
import cn.flightfeather.thirdappmodule.view.recyclerview.MySection
import cn.flightfeather.thirdappmodule.view.recyclerview.RecyclerViewPanel
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import kotlinx.android.synthetic.main.activity_night_work_manage.*
import kotlinx.android.synthetic.main.layout_toolbar_2.*
 
/**
 * @author riku
 * Date: 2021/1/4
 */
class NightWorkManageActivity : BaseActivity() {
    override fun getLayoutId(): Int = R.layout.activity_night_work_manage
 
    lateinit var viewModel: NightWorkViewModel
 
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        viewModel = ViewModelProviders.of(this).get(NightWorkViewModel::class.java)
 
        initToolbar()
        initView()
        initRecyclerView()
        initObserver()
 
        viewModel.getSummary()
    }
 
    private fun initToolbar() {
        img_back.setOnClickListener { finish() }
        tv_main_title.text = "夜间施工许可"
    }
 
    private fun initView() {
 
    }
 
    private fun initRecyclerView() {
        object : RecyclerViewPanel<NightWorkFileVo>(viewModel.dataLoadModel3, recycler_view, this) {
            override fun getItemLayoutId(): Int? = R.layout.item_night_work_3
 
            override fun onBindView(holder: BaseCustomViewHolder, item: MySection<NightWorkFileVo>?) {
                item?.t?.let {vo ->
                    val time = CommonUtils.getStartEndDate(vo.startDate, vo.endDate)
 
                    holder.setText(R.id.txt_content, vo.itemName)
                            .setText(R.id.txt_night_work_num, vo.num)
                            .setText(R.id.txt_time, time)
                            if (vo.isRead == true) {
                                holder.setSelected(R.id.txt_signed, true)
                                        .setText(R.id.txt_signed, getString(R.string.signed))
 
                            } else{
                                holder.setSelected(R.id.txt_signed, false)
                                        .setText(R.id.txt_signed, getString(R.string.unsigned))
                            }
                }
            }
 
            override fun onItemClick(adapter: BaseQuickAdapter<Any?, BaseViewHolder>, view: View, position: Int, dataList: List<NightWorkFileVo>) {
                super.onItemClick(adapter, view, position, dataList)
                openDetail(dataList[position])
            }
        }.run {
            init()
            startRefresh()
        }
    }
 
    private fun initObserver() {
        viewModel.summary.observe(this, Observer {
            it?.let { n ->
                txt_total_count.text = n.totalCount.toString()
                txt_signed_count.text = n.signedCount.toString()
            }
        })
    }
 
    private fun openDetail(nightWorkFileVo: NightWorkFileVo) {
        val intent = Intent(this, OfficeFileManageActivity::class.java)
        intent.putExtra("filePath", nightWorkFileVo.url)
        intent.putExtra("fileName", nightWorkFileVo.fileName)
        intent.putExtra("isRemoteFile", nightWorkFileVo.url?.contains("http") == true)
        startActivity(intent)
    }
}