优化列表
This commit is contained in:
@@ -392,6 +392,8 @@ class HomeMenuFragment : Fragment() {
|
|||||||
Log.d("DeviceList", "deviceBeanList size = ${deviceBeanList.size}")
|
Log.d("DeviceList", "deviceBeanList size = ${deviceBeanList.size}")
|
||||||
updateDeviceList()
|
updateDeviceList()
|
||||||
} else {
|
} else {
|
||||||
|
binding.rvDeviceList.visibility = View.GONE
|
||||||
|
binding.layoutNoPermission.visibility = View.VISIBLE
|
||||||
Toast.makeText(requireContext(), response.msg, Toast.LENGTH_SHORT).show()
|
Toast.makeText(requireContext(), response.msg, Toast.LENGTH_SHORT).show()
|
||||||
if (isLoadMore) {
|
if (isLoadMore) {
|
||||||
hasMore = false
|
hasMore = false
|
||||||
@@ -401,6 +403,8 @@ class HomeMenuFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
withContext(Dispatchers.Main) {
|
withContext(Dispatchers.Main) {
|
||||||
|
binding.rvDeviceList.visibility = View.GONE
|
||||||
|
binding.layoutNoPermission.visibility = View.VISIBLE
|
||||||
Toast.makeText(requireContext(), R.string.network_error, Toast.LENGTH_SHORT).show()
|
Toast.makeText(requireContext(), R.string.network_error, Toast.LENGTH_SHORT).show()
|
||||||
isLoading = false
|
isLoading = false
|
||||||
if (isLoadMore) {
|
if (isLoadMore) {
|
||||||
|
|||||||
@@ -257,6 +257,7 @@ class LinkedUserActivity : AppCompatActivity() {
|
|||||||
updateFamilyMembersList(response.data as List<FamilyMembersBean>)
|
updateFamilyMembersList(response.data as List<FamilyMembersBean>)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
hide()
|
||||||
Toast.makeText(this@LinkedUserActivity, response.msg, Toast.LENGTH_SHORT).show()
|
Toast.makeText(this@LinkedUserActivity, response.msg, Toast.LENGTH_SHORT).show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -264,11 +265,18 @@ class LinkedUserActivity : AppCompatActivity() {
|
|||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
withContext(Dispatchers.Main) {
|
withContext(Dispatchers.Main) {
|
||||||
binding.swipeRefresh.isRefreshing = false
|
binding.swipeRefresh.isRefreshing = false
|
||||||
|
hide()
|
||||||
Toast.makeText(this@LinkedUserActivity, "网络请求失败", Toast.LENGTH_SHORT).show()
|
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>) {
|
private fun updateDeviceUserList(deviceUserList: List<DeviceUserBean>) {
|
||||||
fullUserList.clear()
|
fullUserList.clear()
|
||||||
|
|||||||
@@ -79,8 +79,7 @@ class VoiceSettingsActivity : AppCompatActivity() {
|
|||||||
private fun updateDeviceAlertAudio() {
|
private fun updateDeviceAlertAudio() {
|
||||||
deviceId?.let { id ->
|
deviceId?.let { id ->
|
||||||
val newAlertAudio = if (binding.swWarningVoice.isChecked) "1" else "0"
|
val newAlertAudio = if (binding.swWarningVoice.isChecked) "1" else "0"
|
||||||
// 只有状态发生变化时才请求
|
// 点击返回时总是触发网络请求
|
||||||
if (newAlertAudio != originalAlertAudio) {
|
|
||||||
CoroutineScope(Dispatchers.IO).launch {
|
CoroutineScope(Dispatchers.IO).launch {
|
||||||
try {
|
try {
|
||||||
val deviceBean = DeviceBean(id = id, alertAudio = newAlertAudio)
|
val deviceBean = DeviceBean(id = id, alertAudio = newAlertAudio)
|
||||||
@@ -89,20 +88,23 @@ class VoiceSettingsActivity : AppCompatActivity() {
|
|||||||
if (response.code == 200 && response.data != null) {
|
if (response.code == 200 && response.data != null) {
|
||||||
Toast.makeText(this@VoiceSettingsActivity, "修改成功", Toast.LENGTH_SHORT).show()
|
Toast.makeText(this@VoiceSettingsActivity, "修改成功", Toast.LENGTH_SHORT).show()
|
||||||
} else {
|
} else {
|
||||||
|
// 仅在状态实际发生变化时才显示错误提示
|
||||||
|
if (newAlertAudio != originalAlertAudio) {
|
||||||
Toast.makeText(this@VoiceSettingsActivity, response.msg, Toast.LENGTH_SHORT).show()
|
Toast.makeText(this@VoiceSettingsActivity, response.msg, Toast.LENGTH_SHORT).show()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
withContext(Dispatchers.Main) {
|
withContext(Dispatchers.Main) {
|
||||||
|
// 仅在状态实际发生变化时才显示失败提示
|
||||||
|
if (newAlertAudio != originalAlertAudio) {
|
||||||
Toast.makeText(this@VoiceSettingsActivity, "修改失败", Toast.LENGTH_SHORT).show()
|
Toast.makeText(this@VoiceSettingsActivity, "修改失败", Toast.LENGTH_SHORT).show()
|
||||||
|
}
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
finish()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5,6 +5,7 @@ import android.graphics.Color
|
|||||||
import android.graphics.drawable.GradientDrawable
|
import android.graphics.drawable.GradientDrawable
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.os.CountDownTimer
|
import android.os.CountDownTimer
|
||||||
|
import android.util.Log
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
@@ -194,6 +195,7 @@ class LoginActivity : AppCompatActivity() {
|
|||||||
try {
|
try {
|
||||||
val response = RetrofitNetwork.getNetworkService().getCode(phone)
|
val response = RetrofitNetwork.getNetworkService().getCode(phone)
|
||||||
withContext(Dispatchers.Main) {
|
withContext(Dispatchers.Main) {
|
||||||
|
Log.d("VerificationCode", "code = ${response.code}, msg = ${response.msg}")
|
||||||
if (response.code == 200) {
|
if (response.code == 200) {
|
||||||
Toast.makeText(this@LoginActivity, getString(R.string.code_sent_to, phone), Toast.LENGTH_SHORT).show()
|
Toast.makeText(this@LoginActivity, getString(R.string.code_sent_to, phone), Toast.LENGTH_SHORT).show()
|
||||||
startCountDown()
|
startCountDown()
|
||||||
|
|||||||
@@ -35,6 +35,12 @@
|
|||||||
android:textStyle="bold" />
|
android:textStyle="bold" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
<!-- 搜索区域 -->
|
<!-- 搜索区域 -->
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/searchLayout"
|
android:id="@+id/searchLayout"
|
||||||
@@ -72,23 +78,48 @@
|
|||||||
android:singleLine="true"/>
|
android:singleLine="true"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
<!-- 列表区域 -->
|
|
||||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
<!-- 内容区域 -->
|
||||||
android:id="@+id/swipeRefresh"
|
<FrameLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:layout_weight="1">
|
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
|
<com.yanzhenjie.recyclerview.SwipeRecyclerView
|
||||||
android:id="@+id/rvLinkedUser"
|
android:id="@+id/rvLinkedUser"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"/>
|
||||||
android:paddingHorizontal="16dp"
|
|
||||||
android:paddingTop="8dp"
|
|
||||||
android:paddingBottom="16dp"/>
|
|
||||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
</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
|
<LinearLayout
|
||||||
|
android:id="@+id/butting"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
|||||||
Reference in New Issue
Block a user