关联用户关键字搜索
This commit is contained in:
@@ -2,6 +2,8 @@ package com.example.defenseapplication.liveVideo
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.text.Editable
|
||||
import android.text.TextWatcher
|
||||
import android.util.TypedValue
|
||||
import android.view.View
|
||||
import android.widget.Toast
|
||||
@@ -30,6 +32,7 @@ class LinkedUserActivity : AppCompatActivity() {
|
||||
|
||||
private lateinit var binding: LinkedUserActivityBinding
|
||||
private lateinit var adapter: LinkedUserAdapter
|
||||
private val fullUserList = mutableListOf<LinkedUser>()
|
||||
private val userList = mutableListOf<LinkedUser>()
|
||||
private var mode: Int = MODE_SETTINGS
|
||||
|
||||
@@ -317,9 +320,9 @@ class LinkedUserActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
private fun updateDeviceUserList(deviceUserList: List<DeviceUserBean>) {
|
||||
userList.clear()
|
||||
fullUserList.clear()
|
||||
deviceUserList.forEach { deviceUser ->
|
||||
userList.add(
|
||||
fullUserList.add(
|
||||
LinkedUser(
|
||||
userId = deviceUser.userId ?: "",
|
||||
name = deviceUser.nickName ?: "未知用户",
|
||||
@@ -329,13 +332,13 @@ class LinkedUserActivity : AppCompatActivity() {
|
||||
)
|
||||
)
|
||||
}
|
||||
adapter.submitList(userList)
|
||||
filterUsers(binding.etSearch.text?.toString() ?: "")
|
||||
}
|
||||
|
||||
private fun updateFamilyMembersList(familyMembersList: List<FamilyMembersBean>) {
|
||||
userList.clear()
|
||||
fullUserList.clear()
|
||||
familyMembersList.forEach { member ->
|
||||
userList.add(
|
||||
fullUserList.add(
|
||||
LinkedUser(
|
||||
userId = member.userId ?: "",
|
||||
name = member.nickName ?: member.parentName ?: "未知用户",
|
||||
@@ -345,6 +348,20 @@ class LinkedUserActivity : AppCompatActivity() {
|
||||
)
|
||||
)
|
||||
}
|
||||
filterUsers(binding.etSearch.text?.toString() ?: "")
|
||||
}
|
||||
|
||||
private fun filterUsers(keyword: String) {
|
||||
userList.clear()
|
||||
if (keyword.isEmpty()) {
|
||||
userList.addAll(fullUserList)
|
||||
} else {
|
||||
val lowerKeyword = keyword.lowercase()
|
||||
fullUserList.filter {
|
||||
it.name.lowercase().contains(lowerKeyword) ||
|
||||
it.phone.contains(keyword)
|
||||
}.forEach { userList.add(it) }
|
||||
}
|
||||
adapter.submitList(userList)
|
||||
}
|
||||
|
||||
@@ -353,9 +370,13 @@ class LinkedUserActivity : AppCompatActivity() {
|
||||
finish()
|
||||
}
|
||||
|
||||
binding.searchLayout.setOnClickListener {
|
||||
|
||||
}
|
||||
binding.etSearch.addTextChangedListener(object : TextWatcher {
|
||||
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {}
|
||||
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {}
|
||||
override fun afterTextChanged(s: Editable?) {
|
||||
filterUsers(s?.toString() ?: "")
|
||||
}
|
||||
})
|
||||
|
||||
binding.btnAddLinkedUser.setOnClickListener {
|
||||
val intent = Intent(this, AddLinkedUserActivity::class.java)
|
||||
|
||||
Reference in New Issue
Block a user