18034727885
2026-04-27 3a4c1bbb2cf4fb1cdda8a5061b0674f30e7456b4
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
package com.example.smart.ui.project.correct
 
import android.R
import android.view.LayoutInflater
import android.view.View
import android.widget.AdapterView
import android.widget.ArrayAdapter
import androidx.core.view.isVisible
import androidx.fragment.app.viewModels
import androidx.recyclerview.widget.LinearLayoutManager
import com.example.smart.databinding.ProjectIssuePageLayoutBinding
import com.example.smart.ui.project.correct.adapter.CorrectAdapter
import com.example.smart.ui.project.correct.bean.CorrectStyleBean
import com.example.smart.ui.project.frag.ProjectBasePage
import com.example.smart.ui.project.provider.ProjectPageFactory.PAGE_CORRECT
import razerdp.basepopup.BasePopupWindow.OnDismissListener
 
 
class CorrectPageFragment : ProjectBasePage() {
 
    private val mDataList =  ArrayList<CorrectStyleBean>()
 
    private lateinit var adapter : CorrectAdapter
 
    private val viewModel: CorrectViewModel by viewModels()
 
    private var mineIssues = false
 
    override fun callList() {
        viewModel.callList(param.taskId, mineIssues) {
            binding.loadingLayout.isVisible = true
            binding.loadingLayout.loadError()
        }
    }
 
    override fun onBindObserver() {
        super.onBindObserver()
        super.onBindObserver()
        viewModel.correctBean.observe(this) {
            if(it.isEmpty()) {
                binding.loadingLayout.isVisible = true
                binding.loadingLayout.loadEmpty()
            } else{
                binding.loadingLayout.isVisible = false
                adapter.notifyData(it)
            }
        }
    }
 
 
    override fun initView() {
        binding.recyclerView.layoutManager =
            LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false)
        adapter = CorrectAdapter(mContext!!, mDataList, param)
        adapter.setDismissListener(object : OnDismissListener() {
            override fun onDismiss() {
                callList()
            }
        })
        binding.recyclerView.adapter = adapter
 
        initSpinner()
    }
 
    private fun initSpinner() {
        val creatorOptions = listOf("全部人员", "我创建的")
        val adapter = ArrayAdapter(requireContext(), R.layout.simple_spinner_item, creatorOptions)
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
        binding.creatorSpinner.adapter = adapter
        // 调整字体大小
        binding.creatorSpinner.setPopupBackgroundResource(com.example.smart.R.color.white)
        binding.deviceSpinner.visibility = View.GONE
 
        binding.creatorSpinner.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
            override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) {
                mineIssues = position == 1
 
                callList()
            }
 
            override fun onNothingSelected(parent: AdapterView<*>?) {
            }
        }
    }
 
    override fun initData() {}
 
    override fun getPageId() = PAGE_CORRECT
 
    private val binding by lazy {
        ProjectIssuePageLayoutBinding.inflate(LayoutInflater.from(context))
    }
 
    companion object {
        fun newInstance() = CorrectPageFragment()
    }
 
    override fun getRootView() = binding.root
 
 
}