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
100
101
102
103
104
105
106
107
108
package com.flightfeather.ducha.module.inspection
 
import android.arch.lifecycle.Observer
import android.os.Bundle
import android.view.View
import cn.flightfeather.thirdappmodule.CommonApplication
import cn.flightfeather.thirdappmodule.adapter.IconsPageAdapter
import cn.flightfeather.thirdappmodule.module.inspection.InspectionDetailActivity
import cn.flightfeather.thirdappmodule.util.Domain
import com.flightfeather.ducha.R
 
/**
 * @author riku
 * Date: 2021/8/2
 */
class DCInspectionDetailActivity : InspectionDetailActivity() {
 
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
 
        viewModel.subTask.removeObservers(this)
        viewModel.subTask.observe(this, Observer {
            it?.let {
                updateUIBySubTask(it)
                taskStatus = it.status
                onDataLoaded(1)
                if (it.stAssessorguid != null
                    && it.stAssessorguid.contains(CommonApplication.getInstance().currentUser.guid)) {
                    if (menuList.size >= 4) {
                        menuList[3].alpha = 1F
                        menuList[3].setOnClickListener(this)
                    }
                } else {
                    if (menuList.size >= 4) {
                        menuList[3].alpha = 0.2F
                        menuList[3].setOnClickListener(null)
                    }
                }
            }
        })
    }
 
//    override fun initIconViewPager() {
//        super.initIconViewPager()
//        val iconPage1 = View.inflate(this, R.layout.dc_page_patrol_icons_first, null)
//
//        menuList.apply{
//            clear()
//
//            add(iconPage1.findViewById(R.id.ln_patrol_take_evidence))
//            add(iconPage1.findViewById(R.id.ln_patrol_problem_list))
//            add(iconPage1.findViewById(R.id.ln_patrol_camera))
//            add(iconPage1.findViewById(R.id.ln_patrol_check))
//            add(iconPage1.findViewById(R.id.ln_patrol_navi))
//            add(iconPage1.findViewById(R.id.ln_patrol_chose_latlng))
//            add(iconPage1.findViewById(R.id.ln_patrol_edit))
//        }
//
//        vp_patrol_icons.adapter = IconsPageAdapter(ArrayList<View>().apply {
//            add(iconPage1)
//        })
//    }
 
    override fun refreshMenuStatus(status: String) {
        menuList.let {m ->
            when (status) {
                Domain.TASK_STATUS_WAITING -> {
                    for (i in m.indices) {
                        if (i <= 3) {
                            m[i].alpha = 0.2F
                            m[i].setOnClickListener(showNeedStartTaskListener())
                        } else {
                            m[i].alpha = 1F
                            m[i].setOnClickListener(this)
                        }
                    }
                }
                Domain.TASK_STATUS_RUNNING -> {
                    m.forEach {
                        it.alpha = 1F
                        it.setOnClickListener(this)
                    }
                }
                Domain.TASK_STATUS_FINISHED -> {
                    for (i in m.indices) {
//                        if (i == 1) {
//                            m[i].alpha = 0.2F
//                            m[i].isClickable = false
//                        } else {
                        m[i].alpha = 1F
                        m[i].setOnClickListener(this)
//                        }
                    }
                }
            }
            if (viewModel.userTypeId == Domain.USER_COMPTENT.toByte()) {
                for (i in m.indices) {
                    when (i) {
                        1, in 3..4, in 7..11 -> {
                            m[i].alpha = 0.2F
                            m[i].isClickable = false
                        }
                    }
                }
            }
        }
    }
}