关联用户增加判断限制
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,15 +279,31 @@ class LinkedUserActivity : AppCompatActivity() {
|
||||
})
|
||||
|
||||
binding.btnAddLinkedUser.setOnClickListener {
|
||||
if (checkUserLimit()) {
|
||||
val intent = Intent(this, AddLinkedUserActivity::class.java)
|
||||
startActivity(intent)
|
||||
}
|
||||
}
|
||||
|
||||
binding.fabAdd.setOnClickListener {
|
||||
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) {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -58,12 +58,18 @@
|
||||
android:src="@drawable/search"
|
||||
android:layout_marginRight="8dp"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
<EditText
|
||||
android:id="@+id/etSearch"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/search_preset_text"
|
||||
android:textColor="@color/gray"
|
||||
android:textSize="14sp"/>
|
||||
android:layout_weight="1"
|
||||
android:background="@null"
|
||||
android:hint="@string/search_preset_text"
|
||||
android:textColorHint="@color/gray"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="14sp"
|
||||
android:singleLine="true"
|
||||
android:imeOptions="actionSearch"/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@
|
||||
</FrameLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/add_family"
|
||||
android:id="@+id/addFamily"
|
||||
android:layout_width="38dp"
|
||||
android:layout_height="38dp"
|
||||
android:layout_marginEnd="10dp"
|
||||
|
||||
@@ -469,4 +469,5 @@
|
||||
<string name="create_file_failed">创建文件失败</string>
|
||||
<string name="uploading">上传中...</string>
|
||||
<string name="upload_failed">上传失败</string>
|
||||
<string name="max_add_11_users">最多添加11个用户</string>
|
||||
</resources>
|
||||
@@ -473,4 +473,5 @@
|
||||
<string name="select_from_album">Select from Album</string>
|
||||
<string name="select_date">Select Date</string>
|
||||
<string name="select_time">Select Time</string>
|
||||
<string name="max_add_11_users">A maximum of 11 users can be added</string>
|
||||
</resources>
|
||||
Reference in New Issue
Block a user