I am trying to display scan results, from EstimoteUWBScanResult but I have not been able to access the properties to get the device Id. I am using scanResult as my EstimoteUWBScanResult and the autofill suggestions are not showing any available properties, so something like scanResult.deviceId does not resolve. What am I doing wrong?
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.estimote.uwb.api.scanning.EstimoteDevice
import com.estimote.uwb.api.scanning.EstimoteUWBScanResult
class DeviceListAdapter : RecyclerView.Adapter<DeviceListAdapter.DeviceViewHolder>() {
private var scanResults: List<EstimoteUWBScanResult> = emptyList()
private lateinit var uwbManager: EstimoteUWBManager
private var deviceList: List<EstimoteDevice> = emptyList()
fun setUwbManager(uwbManager: EstimoteUWBManager) {
this.uwbManager = uwbManager
}
fun setDeviceList(deviceList: List<EstimoteDevice>) {
this.deviceList = deviceList
notifyDataSetChanged()
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): DeviceViewHolder {
val view = LayoutInflater.from(parent.context).inflate(R.layout.item_device, parent, false)
return DeviceViewHolder(view)
}
override fun onBindViewHolder(holder: DeviceViewHolder, position: Int) {
val scanResult = scanResults[position]
val device = findDeviceByScanResult(scanResult)
holder.bind(device)
}
override fun getItemCount(): Int {
return scanResults.size
}
fun setScanResults(scanResults: List<EstimoteUWBScanResult>) {
this.scanResults = scanResults
notifyDataSetChanged()
}
private fun findDeviceByScanResult(scanResult: EstimoteUWBScanResult): EstimoteDevice? {
return deviceList.find { it.deviceId==scanResult.deviceID}
}