控制台

This commit is contained in:
2026-05-29 17:46:13 +08:00
parent 08449d8abb
commit ed9d05cb42
12 changed files with 112 additions and 26 deletions

View File

@@ -198,32 +198,69 @@ class LiveVideoActivity : BaseActivity() {
intent.putExtra("from_live_video", true) intent.putExtra("from_live_video", true)
startActivity(intent) startActivity(intent)
} }
// 控制台方向按钮点击事件
binding.ivUp.setOnClickListener {
handleDirectionClick("up")
}
binding.ivDown.setOnClickListener {
handleDirectionClick("down")
}
binding.ivLeft.setOnClickListener {
handleDirectionClick("left")
}
binding.ivRight.setOnClickListener {
handleDirectionClick("right")
}
// 触摸反馈
setTouchFeedback(binding.ivUp)
setTouchFeedback(binding.ivDown)
setTouchFeedback(binding.ivLeft)
setTouchFeedback(binding.ivRight)
}
private fun setTouchFeedback(view: View) {
view.setOnTouchListener { v, event ->
when (event.action) {
android.view.MotionEvent.ACTION_DOWN -> {
v.scaleX = 0.9f
v.scaleY = 0.9f
}
android.view.MotionEvent.ACTION_UP, android.view.MotionEvent.ACTION_CANCEL -> {
v.scaleX = 1.0f
v.scaleY = 1.0f
}
}
false
}
}
private fun handleDirectionClick(direction: String) {
val directionText = when (direction) {
"up" -> getString(R.string.direction_up)
"down" -> getString(R.string.direction_down)
"left" -> getString(R.string.direction_left)
"right" -> getString(R.string.direction_right)
else -> ""
}
} }
private fun fetchAlarmList(page: Int = 1) { private fun fetchAlarmList(page: Int = 1) {
val currentDeviceId = deviceId ?: return val currentDeviceId = deviceId ?: return
Log.d("LiveVideoActivity", "=== 开始请求设备告警日志 ===")
Log.d("LiveVideoActivity", "请求参数 - deviceId: $currentDeviceId, page: $page, pageSize: $pageSize")
isLoading = true isLoading = true
lifecycleScope.launch { lifecycleScope.launch {
try { try {
Log.d("LiveVideoActivity", "正在发送网络请求...")
val response = RetrofitNetwork.getNetworkService().getDeviceAlarmList( val response = RetrofitNetwork.getNetworkService().getDeviceAlarmList(
deviceId = currentDeviceId, deviceId = currentDeviceId,
pageNum = page.toString(), pageNum = page.toString(),
pageSize = pageSize.toString() pageSize = pageSize.toString()
) )
Log.d("LiveVideoActivity", "请求完成")
Log.d("LiveVideoActivity", "完整响应对象: $response")
Log.d("LiveVideoActivity", "总条数: ${response.total}, 当前页数据条数: ${response.rows.size}") Log.d("LiveVideoActivity", "总条数: ${response.total}, 当前页数据条数: ${response.rows.size}")
val newData = response.rows val newData = response.rows
if (newData.isEmpty()) { if (newData.isEmpty()) {
Log.d("LiveVideoActivity", "当前页数据为空列表")
} else { } else {
Log.d("LiveVideoActivity", "数据示例:")
newData.take(3).forEachIndexed { index, item -> newData.take(3).forEachIndexed { index, item ->
Log.d("LiveVideoActivity", "${index + 1}条 - id: ${item.id}, categoryName: ${item.categoryName}, createTime: ${item.createTime}") Log.d("LiveVideoActivity", "${index + 1}条 - id: ${item.id}, categoryName: ${item.categoryName}, createTime: ${item.createTime}")
} }
@@ -234,28 +271,18 @@ class LiveVideoActivity : BaseActivity() {
} else { } else {
response.total / pageSize + 1 response.total / pageSize + 1
} }
Log.d("LiveVideoActivity", "总页数: $totalPage")
isFirstLoad = false isFirstLoad = false
if (page == 1) { if (page == 1) {
alarmList.clear() alarmList.clear()
hasMore = totalPage > 1 hasMore = totalPage > 1
Log.d("LiveVideoActivity", "第一页,已清空列表")
} }
alarmList.addAll(newData) alarmList.addAll(newData)
Log.d("LiveVideoActivity", "已添加 ${newData.size} 条数据,列表总条数: ${alarmList.size}")
alarmAdapter?.notifyDataSetChanged() alarmAdapter?.notifyDataSetChanged()
Log.d("LiveVideoActivity", "已通知适配器刷新")
} catch (e: Exception) { } catch (e: Exception) {
Log.e("LiveVideoActivity", "请求异常: ${e.message}", e)
hasMore = false hasMore = false
} finally { } finally {
isLoading = false isLoading = false
Log.d("LiveVideoActivity", "请求结束isLoading: $isLoading")
Log.d("LiveVideoActivity", "=== 请求结束 ===")
} }
} }
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

@@ -144,12 +144,65 @@
android:orientation="vertical" android:orientation="vertical"
android:visibility="gone"> android:visibility="gone">
<!-- 控制台图片 --> <!-- 圆形控制台 -->
<ImageView <RelativeLayout
android:id="@+id/ivConsole" android:layout_width="200dp"
android:layout_width="160dp" android:layout_height="200dp">
android:layout_height="160dp"
android:src="@drawable/console" /> <!-- 圆形背景 -->
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent" />
<!-- 上按钮 -->
<ImageView
android:id="@+id/ivUp"
android:layout_width="108dp"
android:layout_height="108dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="8dp"
android:src="@drawable/selector_up"
android:clickable="true"
android:focusable="true" />
<!-- 下按钮 -->
<ImageView
android:id="@+id/ivDown"
android:layout_width="108dp"
android:layout_height="108dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="8dp"
android:src="@drawable/selector_down"
android:clickable="true"
android:focusable="true" />
<!-- 左按钮 -->
<ImageView
android:id="@+id/ivLeft"
android:layout_width="108dp"
android:layout_height="108dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="8dp"
android:src="@drawable/selector_left"
android:clickable="true"
android:focusable="true" />
<!-- 右按钮 -->
<ImageView
android:id="@+id/ivRight"
android:layout_width="108dp"
android:layout_height="108dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="8dp"
android:src="@drawable/selector_right"
android:clickable="true"
android:focusable="true" />
</RelativeLayout>
</LinearLayout> </LinearLayout>

View File

@@ -477,4 +477,10 @@
<string name="max_add_11_users">A maximum of 11 users can be added</string> <string name="max_add_11_users">A maximum of 11 users can be added</string>
<string name="linked_user_phone_label">Phone: %s</string> <string name="linked_user_phone_label">Phone: %s</string>
<string name="linked_user_idcard_label">ID: %s</string> <string name="linked_user_idcard_label">ID: %s</string>
<!-- Direction Control -->
<string name="direction_up">Move Up</string>
<string name="direction_down">Move Down</string>
<string name="direction_left">Move Left</string>
<string name="direction_right">Move Right</string>
</resources> </resources>