关联用户增加判断限制
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package com.example.defenseapplication.liveVideo
|
||||
|
||||
import android.os.Bundle
|
||||
import android.text.Editable
|
||||
import android.text.TextWatcher
|
||||
import android.widget.Toast
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
@@ -23,6 +25,7 @@ import androidx.recyclerview.widget.RecyclerView
|
||||
class AddLinkedUserActivity : AppCompatActivity() {
|
||||
private lateinit var binding: AddLinkedUserActivityBinding
|
||||
private val selectedPhoneSet = mutableSetOf<String>()
|
||||
private val fullUserItemList = mutableListOf<UserItem>()
|
||||
private val userItemList = mutableListOf<UserItem>()
|
||||
private val selectedUserIdMap = mutableMapOf<String, String>()
|
||||
|
||||
@@ -106,9 +109,9 @@ class AddLinkedUserActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
private fun updateFamilyMemberList(familyMembersList: List<FamilyMembersBean>) {
|
||||
userItemList.clear()
|
||||
fullUserItemList.clear()
|
||||
familyMembersList.forEach { member ->
|
||||
userItemList.add(
|
||||
fullUserItemList.add(
|
||||
UserItem(
|
||||
name = member.nickName ?: member.parentName ?: "未知用户",
|
||||
phone = member.phonenumber ?: "",
|
||||
@@ -116,6 +119,20 @@ class AddLinkedUserActivity : AppCompatActivity() {
|
||||
)
|
||||
)
|
||||
}
|
||||
filterUsers(binding.etSearch.text?.toString() ?: "")
|
||||
}
|
||||
|
||||
private fun filterUsers(keyword: String) {
|
||||
userItemList.clear()
|
||||
if (keyword.isEmpty()) {
|
||||
userItemList.addAll(fullUserItemList)
|
||||
} else {
|
||||
val lowerKeyword = keyword.lowercase()
|
||||
fullUserItemList.filter {
|
||||
it.name.lowercase().contains(lowerKeyword) ||
|
||||
it.phone.contains(keyword)
|
||||
}.forEach { userItemList.add(it) }
|
||||
}
|
||||
binding.rvAddLinkedUser.adapter?.notifyDataSetChanged()
|
||||
}
|
||||
|
||||
@@ -130,6 +147,14 @@ class AddLinkedUserActivity : AppCompatActivity() {
|
||||
binding.ivBack.setOnClickListener {
|
||||
finish()
|
||||
}
|
||||
|
||||
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() ?: "")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun addDeviceUser() {
|
||||
|
||||
@@ -279,16 +279,32 @@ class LinkedUserActivity : AppCompatActivity() {
|
||||
})
|
||||
|
||||
binding.btnAddLinkedUser.setOnClickListener {
|
||||
val intent = Intent(this, AddLinkedUserActivity::class.java)
|
||||
startActivity(intent)
|
||||
if (checkUserLimit()) {
|
||||
val intent = Intent(this, AddLinkedUserActivity::class.java)
|
||||
startActivity(intent)
|
||||
}
|
||||
}
|
||||
|
||||
binding.fabAdd.setOnClickListener {
|
||||
val intent = Intent(this, com.example.defenseapplication.personal.InvitationCodeActivity::class.java)
|
||||
startActivity(intent)
|
||||
if (checkUserLimit()) {
|
||||
val intent = Intent(this, com.example.defenseapplication.personal.InvitationCodeActivity::class.java)
|
||||
startActivity(intent)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun checkUserLimit(): Boolean {
|
||||
if (fullUserList.size >= 11) {
|
||||
val dialog = CustomDialogFragmentText()
|
||||
dialog.setTitle(getString(R.string.notice))
|
||||
dialog.setMessage(getString(R.string.max_add_11_users))
|
||||
dialog.setShowInput(false)
|
||||
dialog.show(supportFragmentManager, "UserLimitDialog")
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
private fun setupModeUI() {
|
||||
if (mode == MODE_SETTINGS) {
|
||||
binding.btnAddLinkedUser.visibility = View.VISIBLE
|
||||
|
||||
@@ -44,7 +44,7 @@ import java.io.InputStream
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
import java.util.Locale
|
||||
|
||||
//个人资料页面
|
||||
class PersonalProfileActivity : AppCompatActivity() {
|
||||
private lateinit var binding: PersonalProfileActivityBinding
|
||||
private var userInfo: UserInfoBean? = null
|
||||
|
||||
Reference in New Issue
Block a user