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
package com.example.smart.ui.exclude.fragment
 
import android.view.LayoutInflater
import android.view.View
import androidx.fragment.app.viewModels
import com.example.basecore.util.LogUtils
import com.example.basecore.util.showCenterToast
import com.example.basecore.util.showOnlyToast
import com.example.smart.databinding.FragmentContentBinding
import com.example.smart.ui.exclude.ExcludeViewModel
import com.example.smart.ui.exclude.adapter.ContentAdapter
import com.example.smart.ui.exclude.bean.ByPassInfoBean
import com.example.smart.ui.exclude.bean.SelectArrayList
import com.example.smart.ui.home.BasePageFragment
import com.example.smart.ui.projectevent.bean.SystemTreeBean
import com.example.smart.widget.dialog.LoadingDialog
import com.google.android.material.tabs.TabLayoutMediator
 
 
/**
 * @description:
 * extend SystemByPassFragment
 */
class DeviceByPassFragment(viewModel: ExcludeViewModel, isClose: Boolean) : SystemByPassFragment(viewModel, isClose) {
 
    override fun applyData() {
        byPassInfoBean?.deviceHierarchyPaths = mSelectedItemList
    }
 
    override fun onBindObserver() {
        super.onBindObserver()
 
        viewModel.deviceTreeBean.observe(this) {
            LogUtils.e("s t = ${System.currentTimeMillis()}")
            treeBean = it
            onCreatePage()
        }
 
        viewModel.byPassInfoBean.observe(this) {
            byPassInfoBean = it
            if(it.deviceHierarchyPaths!=null && it.deviceHierarchyPaths.isNotEmpty()) {
                mSelectedItemList.addAll(it.deviceHierarchyPaths)
                onCreatePage()
            }
        }
 
        viewModel.submitResult.observe(this) {
            mContext?.showCenterToast("提交成功")
            loadingDialog.dismiss()
        }
    }
 
    override fun onCreatePage() {
//        if(treeBean.isEmpty()) {
//            // 空白页
//            binding.loadingLayout.loadEmpty()
//            binding.submitTv.visibility = View.GONE
//            return
//        }
 
        super.onCreatePage()
    }
 
    override fun initData() {
        viewModel.callDeviceTree() {}
    }
 
    companion object {
        fun newInstance(viewModel: ExcludeViewModel, isClose: Boolean): SystemByPassFragment {
            return DeviceByPassFragment(viewModel, isClose)
        }
    }
 
}