18034727885
2026-06-26 253f680fb9666751e0f9a8e5e8f2f9e3eb1894e3
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
package com.example.smart.ui.query.view
 
import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import android.widget.LinearLayout
import com.example.basecore.util.dp2px
import com.example.smart.R
import com.example.smart.databinding.QueryTagLayoutBinding
import com.example.smart.ui.query.bean.QueryInfoBean
import com.example.smart.ui.query.event.ITagEvent
 
 
class QueryTagLayout @JvmOverloads constructor(
    context: Context,
    private val infoBean: QueryInfoBean,
    private val mITagEvent: ITagEvent,
    attrs: AttributeSet? = null,
    defStyleAttr: Int = 0,
) : LinearLayout(context, attrs, defStyleAttr) {
 
    companion object {
        fun create(context: Context, infoBean: QueryInfoBean, mITagEvent: ITagEvent) =
            QueryTagLayout(context, infoBean, mITagEvent)
    }
 
    private val binding by lazy(LazyThreadSafetyMode.NONE) {
        QueryTagLayoutBinding.bind(this)
    }
 
 
    init {
        LayoutInflater.from(context).inflate(R.layout.query_tag_layout, this)
        orientation = VERTICAL
 
        setBackgroundResource(R.drawable.shape_layout)
 
        binding.run {
            tabNameTv.text = infoBean.tabName
        }
 
        if (infoBean.list.isNotEmpty()) {
            buildTagView()
        }
 
        post {
            if (layoutParams != null) {
                val params = layoutParams as LayoutParams
                params.topMargin = dp2px(18)
                layoutParams = params
            }
        }
    }
 
 
    private fun buildTagView() {
        for (tagInfo in infoBean.list) {
            val tagView = QueryTagView.create(context, tagInfo)
            tagView.setTagEvent(mITagEvent)
            binding.flexBox.addView(tagView)
        }
    }
 
    fun getFlexView() = binding.flexBox
 
 
}