优化列表

This commit is contained in:
2026-06-15 10:19:42 +08:00
parent d30c025874
commit 7e362038b3
5 changed files with 109 additions and 62 deletions

View File

@@ -392,6 +392,8 @@ class HomeMenuFragment : Fragment() {
Log.d("DeviceList", "deviceBeanList size = ${deviceBeanList.size}")
updateDeviceList()
} else {
binding.rvDeviceList.visibility = View.GONE
binding.layoutNoPermission.visibility = View.VISIBLE
Toast.makeText(requireContext(), response.msg, Toast.LENGTH_SHORT).show()
if (isLoadMore) {
hasMore = false
@@ -401,6 +403,8 @@ class HomeMenuFragment : Fragment() {
}
} catch (e: Exception) {
withContext(Dispatchers.Main) {
binding.rvDeviceList.visibility = View.GONE
binding.layoutNoPermission.visibility = View.VISIBLE
Toast.makeText(requireContext(), R.string.network_error, Toast.LENGTH_SHORT).show()
isLoading = false
if (isLoadMore) {

View File

@@ -257,6 +257,7 @@ class LinkedUserActivity : AppCompatActivity() {
updateFamilyMembersList(response.data as List<FamilyMembersBean>)
}
} else {
hide()
Toast.makeText(this@LinkedUserActivity, response.msg, Toast.LENGTH_SHORT).show()
}
}
@@ -264,11 +265,18 @@ class LinkedUserActivity : AppCompatActivity() {
e.printStackTrace()
withContext(Dispatchers.Main) {
binding.swipeRefresh.isRefreshing = false
hide()
Toast.makeText(this@LinkedUserActivity, "网络请求失败", Toast.LENGTH_SHORT).show()
}
}
}
}
private fun hide() {
binding.searchLayout.visibility = View.GONE
binding.rvLinkedUser.visibility = View.GONE
binding.butting?.visibility = View.GONE
binding.layoutNoPermission?.visibility = View.VISIBLE
}
private fun updateDeviceUserList(deviceUserList: List<DeviceUserBean>) {
fullUserList.clear()

View File

@@ -79,8 +79,7 @@ class VoiceSettingsActivity : AppCompatActivity() {
private fun updateDeviceAlertAudio() {
deviceId?.let { id ->
val newAlertAudio = if (binding.swWarningVoice.isChecked) "1" else "0"
// 只有状态发生变化时才请求
if (newAlertAudio != originalAlertAudio) {
// 点击返回时总是触发网络请求
CoroutineScope(Dispatchers.IO).launch {
try {
val deviceBean = DeviceBean(id = id, alertAudio = newAlertAudio)
@@ -89,20 +88,23 @@ class VoiceSettingsActivity : AppCompatActivity() {
if (response.code == 200 && response.data != null) {
Toast.makeText(this@VoiceSettingsActivity, "修改成功", Toast.LENGTH_SHORT).show()
} else {
// 仅在状态实际发生变化时才显示错误提示
if (newAlertAudio != originalAlertAudio) {
Toast.makeText(this@VoiceSettingsActivity, response.msg, Toast.LENGTH_SHORT).show()
}
}
finish()
}
} catch (e: Exception) {
withContext(Dispatchers.Main) {
// 仅在状态实际发生变化时才显示失败提示
if (newAlertAudio != originalAlertAudio) {
Toast.makeText(this@VoiceSettingsActivity, "修改失败", Toast.LENGTH_SHORT).show()
finish()
}
}
}
} else {
finish()
}
}
}
}
}
}

View File

@@ -5,6 +5,7 @@ import android.graphics.Color
import android.graphics.drawable.GradientDrawable
import android.os.Bundle
import android.os.CountDownTimer
import android.util.Log
import android.view.View
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
@@ -194,6 +195,7 @@ class LoginActivity : AppCompatActivity() {
try {
val response = RetrofitNetwork.getNetworkService().getCode(phone)
withContext(Dispatchers.Main) {
Log.d("VerificationCode", "code = ${response.code}, msg = ${response.msg}")
if (response.code == 200) {
Toast.makeText(this@LoginActivity, getString(R.string.code_sent_to, phone), Toast.LENGTH_SHORT).show()
startCountDown()

View File

@@ -35,6 +35,12 @@
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical">
<!-- 搜索区域 -->
<LinearLayout
android:id="@+id/searchLayout"
@@ -72,23 +78,48 @@
android:singleLine="true"/>
</LinearLayout>
</LinearLayout>
<!-- 列表区域 -->
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/swipeRefresh"
<!-- 内容区域 -->
<FrameLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<!-- 列表 -->
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/swipeRefresh"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.yanzhenjie.recyclerview.SwipeRecyclerView
android:id="@+id/rvLinkedUser"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingHorizontal="16dp"
android:paddingTop="8dp"
android:paddingBottom="16dp"/>
android:layout_height="match_parent"/>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
<!-- 空页面 -->
<LinearLayout
android:id="@+id/layoutNoPermission"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
android:visibility="gone">
<ImageView
android:layout_width="244dp"
android:layout_height="131dp"
android:src="@mipmap/default_page"/>
</LinearLayout>
</FrameLayout>
</LinearLayout>
<!-- 底部按钮 -->
<LinearLayout
android:id="@+id/butting"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"