如何解决RxAndroidBle从列表中删除禁用的设备
需要有关RxAndroidBle库的帮助。 我想从找到的设备列表中删除已关闭的特定设备。
在GitHub https://github.com/Polidea/RxAndroidBle上研究官方图书馆存储库时,我使用这段代码来搜索设备
private val data = mutableListOf<ScanResult>()
fun addScanResult(bleScanResult: ScanResult) {
// Not the best way to ensure distinct devices,just for the sake of the demo.
data.withIndex()
.firstOrNull { it.value.bleDevice == bleScanResult.bleDevice }
?.let {
// device already in data list => update
data[it.index] = bleScanResult
notifyItemChanged(it.index)
}
?: run {
// new device => add to data list
with(data) {
add(bleScanResult)
sortBy { it.bleDevice.macAddress }
}
notifyDataSetChanged()
}
}
找到的所有设备都添加到列表中,但是我不知道如何最好地将其从列表中删除。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。