package com.abbidot.tracker.adapter

import android.content.Context
import com.abbidot.baselibrary.list.BaseRecyclerAdapter
import com.abbidot.baselibrary.list.RecyclerViewHolder
import com.abbidot.baselibrary.util.Utils
import com.abbidot.tracker.R
import com.abbidot.tracker.bean.WiFiBean
import com.abbidot.tracker.constant.ConstantInt
import com.abbidot.tracker.widget.MyWiFiSignalView

/**
 *Created  by .yzq on 2024/3/26/026.
 * @link
 * @description:
 */
class WiFiListAdapter(
    ctx: Context, list: MutableList<WiFiBean>?
) : BaseRecyclerAdapter<WiFiBean>(ctx, list) {
    override fun getEmptyLayoutId(viewType: Int) = 0

    override fun getItemLayoutId(viewType: Int) = R.layout.item_wifi_info_layout

    override fun bindData(holder: RecyclerViewHolder?, position: Int, item: WiFiBean) {
//        val wifiName = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
//            item.wifiSsid.toString()
//        } else {
//            item.SSID
//        }
        holder!!.setText(R.id.tv_wifi_item_name, item.name)
        val signalView = holder.getView(R.id.tv_wifi_item_signal) as MyWiFiSignalView
        val signal = Utils.calculateSignalLevel(item.signal, 3)
        if (item.auth_type == ConstantInt.Type0) {
            signalView.setValue(signal)
        } else {
            signalView.setValue(signal, true)
        }
    }
}