关联用户增加判断限制
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
package com.example.defenseapplication.liveVideo
|
package com.example.defenseapplication.liveVideo
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.text.Editable
|
||||||
|
import android.text.TextWatcher
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
@@ -23,6 +25,7 @@ import androidx.recyclerview.widget.RecyclerView
|
|||||||
class AddLinkedUserActivity : AppCompatActivity() {
|
class AddLinkedUserActivity : AppCompatActivity() {
|
||||||
private lateinit var binding: AddLinkedUserActivityBinding
|
private lateinit var binding: AddLinkedUserActivityBinding
|
||||||
private val selectedPhoneSet = mutableSetOf<String>()
|
private val selectedPhoneSet = mutableSetOf<String>()
|
||||||
|
private val fullUserItemList = mutableListOf<UserItem>()
|
||||||
private val userItemList = mutableListOf<UserItem>()
|
private val userItemList = mutableListOf<UserItem>()
|
||||||
private val selectedUserIdMap = mutableMapOf<String, String>()
|
private val selectedUserIdMap = mutableMapOf<String, String>()
|
||||||
|
|
||||||
@@ -106,9 +109,9 @@ class AddLinkedUserActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun updateFamilyMemberList(familyMembersList: List<FamilyMembersBean>) {
|
private fun updateFamilyMemberList(familyMembersList: List<FamilyMembersBean>) {
|
||||||
userItemList.clear()
|
fullUserItemList.clear()
|
||||||
familyMembersList.forEach { member ->
|
familyMembersList.forEach { member ->
|
||||||
userItemList.add(
|
fullUserItemList.add(
|
||||||
UserItem(
|
UserItem(
|
||||||
name = member.nickName ?: member.parentName ?: "未知用户",
|
name = member.nickName ?: member.parentName ?: "未知用户",
|
||||||
phone = member.phonenumber ?: "",
|
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()
|
binding.rvAddLinkedUser.adapter?.notifyDataSetChanged()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -130,6 +147,14 @@ class AddLinkedUserActivity : AppCompatActivity() {
|
|||||||
binding.ivBack.setOnClickListener {
|
binding.ivBack.setOnClickListener {
|
||||||
finish()
|
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() {
|
private fun addDeviceUser() {
|
||||||
|
|||||||
@@ -279,16 +279,32 @@ class LinkedUserActivity : AppCompatActivity() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
binding.btnAddLinkedUser.setOnClickListener {
|
binding.btnAddLinkedUser.setOnClickListener {
|
||||||
val intent = Intent(this, AddLinkedUserActivity::class.java)
|
if (checkUserLimit()) {
|
||||||
startActivity(intent)
|
val intent = Intent(this, AddLinkedUserActivity::class.java)
|
||||||
|
startActivity(intent)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.fabAdd.setOnClickListener {
|
binding.fabAdd.setOnClickListener {
|
||||||
val intent = Intent(this, com.example.defenseapplication.personal.InvitationCodeActivity::class.java)
|
if (checkUserLimit()) {
|
||||||
startActivity(intent)
|
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() {
|
private fun setupModeUI() {
|
||||||
if (mode == MODE_SETTINGS) {
|
if (mode == MODE_SETTINGS) {
|
||||||
binding.btnAddLinkedUser.visibility = View.VISIBLE
|
binding.btnAddLinkedUser.visibility = View.VISIBLE
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ import java.io.InputStream
|
|||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
|
//个人资料页面
|
||||||
class PersonalProfileActivity : AppCompatActivity() {
|
class PersonalProfileActivity : AppCompatActivity() {
|
||||||
private lateinit var binding: PersonalProfileActivityBinding
|
private lateinit var binding: PersonalProfileActivityBinding
|
||||||
private var userInfo: UserInfoBean? = null
|
private var userInfo: UserInfoBean? = null
|
||||||
|
|||||||
@@ -58,12 +58,18 @@
|
|||||||
android:src="@drawable/search"
|
android:src="@drawable/search"
|
||||||
android:layout_marginRight="8dp"/>
|
android:layout_marginRight="8dp"/>
|
||||||
|
|
||||||
<TextView
|
<EditText
|
||||||
android:layout_width="wrap_content"
|
android:id="@+id/etSearch"
|
||||||
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/search_preset_text"
|
android:layout_weight="1"
|
||||||
android:textColor="@color/gray"
|
android:background="@null"
|
||||||
android:textSize="14sp"/>
|
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>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|||||||
@@ -93,7 +93,7 @@
|
|||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:id="@+id/add_family"
|
android:id="@+id/addFamily"
|
||||||
android:layout_width="38dp"
|
android:layout_width="38dp"
|
||||||
android:layout_height="38dp"
|
android:layout_height="38dp"
|
||||||
android:layout_marginEnd="10dp"
|
android:layout_marginEnd="10dp"
|
||||||
|
|||||||
@@ -469,4 +469,5 @@
|
|||||||
<string name="create_file_failed">创建文件失败</string>
|
<string name="create_file_failed">创建文件失败</string>
|
||||||
<string name="uploading">上传中...</string>
|
<string name="uploading">上传中...</string>
|
||||||
<string name="upload_failed">上传失败</string>
|
<string name="upload_failed">上传失败</string>
|
||||||
|
<string name="max_add_11_users">最多添加11个用户</string>
|
||||||
</resources>
|
</resources>
|
||||||
@@ -473,4 +473,5 @@
|
|||||||
<string name="select_from_album">Select from Album</string>
|
<string name="select_from_album">Select from Album</string>
|
||||||
<string name="select_date">Select Date</string>
|
<string name="select_date">Select Date</string>
|
||||||
<string name="select_time">Select Time</string>
|
<string name="select_time">Select Time</string>
|
||||||
|
<string name="max_add_11_users">A maximum of 11 users can be added</string>
|
||||||
</resources>
|
</resources>
|
||||||
Reference in New Issue
Block a user