feat(task): 实现任务数量动态显示功能
- 在TaskListActivity中添加ViewModel观察器,实时更新任务数量显示 - 在TaskListVM中新增taskCount MutableLiveData用于管理任务计数 - 修改布局文件中的默认任务数量文本为动态绑定值 - 统一调整应用中的颜色主题,将多个界面的文字颜色设置为#ff40FF5E - 更新空数据页面的加载提示文字,从"玩命加载中..."改为"加载中..."
这个提交包含在:
父节点
b785404f55
当前提交
96671914ab
@ -72,9 +72,14 @@ class TaskListActivity :
|
|||||||
binding.shang.setOnClickListener {
|
binding.shang.setOnClickListener {
|
||||||
toPre()
|
toPre()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
viewModel.taskCount.observe(this) { count ->
|
||||||
|
binding.tvTaskHeader.text = "查询到您当前有${count}条任务,信息如下:"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun initData() {
|
override fun initData() {
|
||||||
|
|
||||||
viewModel.searchParams = TaskListData(
|
viewModel.searchParams = TaskListData(
|
||||||
taskType = intent.getStringExtra("taskType") ?: "",
|
taskType = intent.getStringExtra("taskType") ?: "",
|
||||||
keyword = intent.getStringExtra("keyword") ?: "",
|
keyword = intent.getStringExtra("keyword") ?: "",
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
package com.nova.brain.glass.viewmodel
|
package com.nova.brain.glass.viewmodel
|
||||||
|
|
||||||
|
import androidx.lifecycle.MutableLiveData
|
||||||
import com.nova.brain.glass.MyApplication
|
import com.nova.brain.glass.MyApplication
|
||||||
import com.nova.brain.glass.model.TaskItem
|
import com.nova.brain.glass.model.TaskItem
|
||||||
import com.nova.brain.glass.model.data.TaskListData
|
import com.nova.brain.glass.model.data.TaskListData
|
||||||
@ -15,6 +16,8 @@ class TaskListVM : BaseListViewModel<TaskItem>() {
|
|||||||
var searchParams: TaskListData =
|
var searchParams: TaskListData =
|
||||||
TaskListData(taskType = "", keyword = "", dateRange = 0, dateType = 0)
|
TaskListData(taskType = "", keyword = "", dateRange = 0, dateType = 0)
|
||||||
|
|
||||||
|
val taskCount = MutableLiveData<Int>()
|
||||||
|
|
||||||
override fun loadData(page: Int, onResponse: Response<TaskItem>) {
|
override fun loadData(page: Int, onResponse: Response<TaskItem>) {
|
||||||
add(
|
add(
|
||||||
HttpManager.getApi(MyApplication.appComponent1, Service::class.java)
|
HttpManager.getApi(MyApplication.appComponent1, Service::class.java)
|
||||||
@ -31,6 +34,7 @@ class TaskListVM : BaseListViewModel<TaskItem>() {
|
|||||||
aiDescription = it.aiDescription
|
aiDescription = it.aiDescription
|
||||||
)
|
)
|
||||||
} ?: emptyList()
|
} ?: emptyList()
|
||||||
|
taskCount.value = response.data?.total ?: items.size
|
||||||
onResponse.onResponse(ArrayList(items))
|
onResponse.onResponse(ArrayList(items))
|
||||||
}, {
|
}, {
|
||||||
onResponse.onResponse(arrayListOf())
|
onResponse.onResponse(arrayListOf())
|
||||||
|
|||||||
@ -12,7 +12,7 @@
|
|||||||
android:id="@+id/tvTaskHeader"
|
android:id="@+id/tvTaskHeader"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="查询到您当前有5条任务,信息如下:"
|
android:text="查询到您当前有0条任务,信息如下:"
|
||||||
android:textColor="#ff40FF5E"
|
android:textColor="#ff40FF5E"
|
||||||
android:textSize="20sp"
|
android:textSize="20sp"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
|||||||
@ -4,6 +4,6 @@
|
|||||||
android:viewportWidth="1024"
|
android:viewportWidth="1024"
|
||||||
android:viewportHeight="1024">
|
android:viewportHeight="1024">
|
||||||
<path
|
<path
|
||||||
android:fillColor="#409CFA"
|
android:fillColor="#ff40FF5E"
|
||||||
android:pathData="M958.66,288.64l0.02,0L512,65.3 66.12,288.24l-0.83,0L65.29,735.35l446.71,223.34 446.71,-223.34L958.71,288.64 958.66,288.64 958.66,288.64 958.66,288.64zM512,119.41l335.91,168.38 -127.91,64.49L382.47,184.4 512,119.41 512,119.41 512,119.41zM323.94,216.09l341.85,164.71 -153.82,74.5L176.1,288.64 323.94,216.09 323.94,216.09 323.94,216.09zM121.13,345.14l17.75,0 -17.75,-0.65 0,-27.92L484.09,498.06l0,390.87L121.13,707.45 121.13,345.14 121.13,345.14 121.13,345.14zM902.87,372.41l0,335.03L539.91,888.93 539.91,498.06 902.87,316.57 902.87,372.41 902.87,372.41 902.87,372.41z"/>
|
android:pathData="M958.66,288.64l0.02,0L512,65.3 66.12,288.24l-0.83,0L65.29,735.35l446.71,223.34 446.71,-223.34L958.71,288.64 958.66,288.64 958.66,288.64 958.66,288.64zM512,119.41l335.91,168.38 -127.91,64.49L382.47,184.4 512,119.41 512,119.41 512,119.41zM323.94,216.09l341.85,164.71 -153.82,74.5L176.1,288.64 323.94,216.09 323.94,216.09 323.94,216.09zM121.13,345.14l17.75,0 -17.75,-0.65 0,-27.92L484.09,498.06l0,390.87L121.13,707.45 121.13,345.14 121.13,345.14 121.13,345.14zM902.87,372.41l0,335.03L539.91,888.93 539.91,498.06 902.87,316.57 902.87,372.41 902.87,372.41 902.87,372.41z"/>
|
||||||
</vector>
|
</vector>
|
||||||
|
|||||||
@ -21,8 +21,8 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="8dp"
|
android:layout_margin="8dp"
|
||||||
android:text="玩命加载中..."
|
android:text="加载中..."
|
||||||
android:textColor="@color/text_black"
|
android:textColor="#ff40FF5E"
|
||||||
android:textSize="12sp" />
|
android:textSize="12sp" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
@ -46,7 +46,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="8dp"
|
android:layout_margin="8dp"
|
||||||
android:text="暂无数据"
|
android:text="暂无数据"
|
||||||
android:textColor="@color/text_black"
|
android:textColor="#ff40FF5E"
|
||||||
android:textSize="12sp" />
|
android:textSize="12sp" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
@ -70,7 +70,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="8dp"
|
android:layout_margin="8dp"
|
||||||
android:text="加载失败"
|
android:text="加载失败"
|
||||||
android:textColor="@color/text_black"
|
android:textColor="#ff40FF5E"
|
||||||
android:textSize="12sp" />
|
android:textSize="12sp" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
@ -94,7 +94,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="8dp"
|
android:layout_margin="8dp"
|
||||||
android:text="网络异常"
|
android:text="网络异常"
|
||||||
android:textColor="@color/text_black"
|
android:textColor="#ff40FF5E"
|
||||||
android:textSize="12sp" />
|
android:textSize="12sp" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|||||||
正在加载...
在新工单中引用
屏蔽一个用户