[6.10.0]数据落盘UI修改
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
package com.mogo.eagle.core.function.hmi.ui.diskcopy
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import com.mogo.eagle.core.data.deva.diskcopy.CopyCalendarInfo
|
||||
@@ -13,11 +15,18 @@ import kotlinx.android.synthetic.main.view_disk_copy.view.groupDateSelect
|
||||
import kotlinx.android.synthetic.main.view_disk_copy.view.groupDiskCopy
|
||||
import kotlinx.android.synthetic.main.view_disk_copy.view.pbDiskCopyProgress
|
||||
import kotlinx.android.synthetic.main.view_disk_copy.view.rvCalendar
|
||||
import kotlinx.android.synthetic.main.view_disk_copy.view.tvCurrentDate
|
||||
import kotlinx.android.synthetic.main.view_disk_copy.view.tvCurrentMonth
|
||||
import kotlinx.android.synthetic.main.view_disk_copy.view.tvCurrentWeek
|
||||
import kotlinx.android.synthetic.main.view_disk_copy.view.viewDiskCopyDate
|
||||
import java.time.DayOfWeek
|
||||
import java.time.LocalDate
|
||||
import java.time.Month
|
||||
|
||||
/**
|
||||
* 数据落盘辅助工具
|
||||
*/
|
||||
@RequiresApi(Build.VERSION_CODES.O)
|
||||
class DiskCopyView @JvmOverloads constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
@@ -40,6 +49,18 @@ class DiskCopyView @JvmOverloads constructor(
|
||||
private fun initView(){
|
||||
val gridLayoutManager = GridLayoutManager(context,7)
|
||||
diskCopyCalendarAdapter = DiskCopyCalendarAdapter()
|
||||
diskCopyCalendarAdapter?.setDateSelectListener(object: DiskCopyCalendarAdapter.DateSelectListener{
|
||||
override fun onDateSelect(date: String) {
|
||||
//
|
||||
//切换页面隐藏日历显示,切换为硬盘接入页面
|
||||
pbDiskCopyProgress.visibility = View.GONE
|
||||
groupDiskCopy.visibility = View.VISIBLE
|
||||
groupDateSelect.visibility = View.GONE
|
||||
//显示选择日期
|
||||
|
||||
|
||||
}
|
||||
})
|
||||
rvCalendar.adapter = diskCopyCalendarAdapter
|
||||
rvCalendar.layoutManager = gridLayoutManager
|
||||
|
||||
@@ -52,7 +73,13 @@ class DiskCopyView @JvmOverloads constructor(
|
||||
}
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.O)
|
||||
private fun initData(){
|
||||
|
||||
//TODO 当前选择日期显示
|
||||
tvCurrentDate.text = "2025.2.8"
|
||||
tvCurrentWeek.text = "周六"
|
||||
|
||||
//添加日历星期标题头
|
||||
calendarList.add(CopyCalendarInfo(true,"日"))
|
||||
calendarList.add(CopyCalendarInfo(true,"一"))
|
||||
@@ -62,6 +89,115 @@ class DiskCopyView @JvmOverloads constructor(
|
||||
calendarList.add(CopyCalendarInfo(true,"五"))
|
||||
calendarList.add(CopyCalendarInfo(true,"六"))
|
||||
|
||||
val dateNow = LocalDate.now()
|
||||
|
||||
tvCurrentMonth.text = when(dateNow.month){
|
||||
Month.JANUARY->{
|
||||
"一月"
|
||||
}
|
||||
Month.FEBRUARY->{
|
||||
"二月"
|
||||
}
|
||||
Month.MARCH->{
|
||||
"三月"
|
||||
}
|
||||
Month.APRIL->{
|
||||
"四月"
|
||||
}
|
||||
Month.MAY->{
|
||||
"五月"
|
||||
}
|
||||
Month.JUNE->{
|
||||
"六月"
|
||||
}
|
||||
Month.JULY->{
|
||||
"七月"
|
||||
}
|
||||
Month.AUGUST->{
|
||||
"八月"
|
||||
}
|
||||
Month.SEPTEMBER->{
|
||||
"九月"
|
||||
}
|
||||
Month.OCTOBER->{
|
||||
"十月"
|
||||
}
|
||||
Month.NOVEMBER->{
|
||||
"十一月"
|
||||
}
|
||||
Month.DECEMBER->{
|
||||
"十二月"
|
||||
}
|
||||
else -> {
|
||||
""
|
||||
}
|
||||
}
|
||||
val today = dateNow.dayOfMonth
|
||||
val yesterday = dateNow.minusDays(1).dayOfMonth
|
||||
val twoDaysAgo = dateNow.minusDays(2).dayOfMonth
|
||||
val threeDaysAgo = dateNow.minusDays(3).dayOfMonth
|
||||
val fourDaysAgo = dateNow.minusDays(4).dayOfMonth
|
||||
val fiveDaysAgo = dateNow.minusDays(5).dayOfMonth
|
||||
val sixDaysAgo = dateNow.minusDays(6).dayOfMonth
|
||||
|
||||
when(dateNow.minusDays(6).dayOfWeek){
|
||||
//星期日
|
||||
DayOfWeek.SUNDAY->{
|
||||
|
||||
}
|
||||
//星期一
|
||||
DayOfWeek.MONDAY->{
|
||||
calendarList.add(CopyCalendarInfo(false,""))
|
||||
}
|
||||
//星期二
|
||||
DayOfWeek.TUESDAY->{
|
||||
calendarList.add(CopyCalendarInfo(false,""))
|
||||
calendarList.add(CopyCalendarInfo(false,""))
|
||||
}
|
||||
//星期三
|
||||
DayOfWeek.WEDNESDAY->{
|
||||
calendarList.add(CopyCalendarInfo(false,""))
|
||||
calendarList.add(CopyCalendarInfo(false,""))
|
||||
calendarList.add(CopyCalendarInfo(false,""))
|
||||
}
|
||||
//星期四
|
||||
DayOfWeek.THURSDAY->{
|
||||
calendarList.add(CopyCalendarInfo(false,""))
|
||||
calendarList.add(CopyCalendarInfo(false,""))
|
||||
calendarList.add(CopyCalendarInfo(false,""))
|
||||
calendarList.add(CopyCalendarInfo(false,""))
|
||||
}
|
||||
//星期五
|
||||
DayOfWeek.FRIDAY->{
|
||||
calendarList.add(CopyCalendarInfo(false,""))
|
||||
calendarList.add(CopyCalendarInfo(false,""))
|
||||
calendarList.add(CopyCalendarInfo(false,""))
|
||||
calendarList.add(CopyCalendarInfo(false,""))
|
||||
calendarList.add(CopyCalendarInfo(false,""))
|
||||
}
|
||||
//星期六
|
||||
DayOfWeek.SATURDAY->{
|
||||
calendarList.add(CopyCalendarInfo(false,""))
|
||||
calendarList.add(CopyCalendarInfo(false,""))
|
||||
calendarList.add(CopyCalendarInfo(false,""))
|
||||
calendarList.add(CopyCalendarInfo(false,""))
|
||||
calendarList.add(CopyCalendarInfo(false,""))
|
||||
calendarList.add(CopyCalendarInfo(false,""))
|
||||
}
|
||||
else->{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
calendarList.add(CopyCalendarInfo(false,sixDaysAgo.toString()))
|
||||
calendarList.add(CopyCalendarInfo(false,fiveDaysAgo.toString()))
|
||||
calendarList.add(CopyCalendarInfo(false,fourDaysAgo.toString()))
|
||||
calendarList.add(CopyCalendarInfo(false,threeDaysAgo.toString()))
|
||||
calendarList.add(CopyCalendarInfo(false,twoDaysAgo.toString()))
|
||||
calendarList.add(CopyCalendarInfo(false,yesterday.toString()))
|
||||
calendarList.add(CopyCalendarInfo(false,today.toString()))
|
||||
|
||||
|
||||
diskCopyCalendarAdapter?.setData(calendarList)
|
||||
}
|
||||
|
||||
@@ -14,8 +14,8 @@ import com.mogo.eagle.core.function.hmi.R
|
||||
class DiskCopyCalendarAdapter(): RecyclerView.Adapter<RecyclerView.ViewHolder>() {
|
||||
|
||||
private var data: ArrayList<CopyCalendarInfo> ?= null
|
||||
|
||||
private val title: Int = 0
|
||||
private var dateSelectListener: DateSelectListener ?= null
|
||||
|
||||
fun setData(list: ArrayList<CopyCalendarInfo>){
|
||||
data = list
|
||||
@@ -44,7 +44,11 @@ class DiskCopyCalendarAdapter(): RecyclerView.Adapter<RecyclerView.ViewHolder>()
|
||||
}
|
||||
is CalendarContentHolder->{
|
||||
data?.let {
|
||||
holder.tvCalendarContent.text = it[position].content
|
||||
val dateInfo = it[position]
|
||||
holder.tvCalendarContent.text = dateInfo.content
|
||||
holder.tvCalendarContent.setOnClickListener {
|
||||
dateSelectListener?.onDateSelect(dateInfo.content)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -70,4 +74,18 @@ class DiskCopyCalendarAdapter(): RecyclerView.Adapter<RecyclerView.ViewHolder>()
|
||||
var tvCalendarContent: TextView = itemView.findViewById(R.id.tvCalendarContent)
|
||||
}
|
||||
|
||||
/**
|
||||
* 日期选择回调接口
|
||||
*/
|
||||
interface DateSelectListener{
|
||||
fun onDateSelect(date: String)
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置日期选择回调接口
|
||||
*/
|
||||
fun setDateSelectListener(listener: DateSelectListener){
|
||||
dateSelectListener = listener
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,9 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/tvCalendarContent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="@dimen/dp_88"
|
||||
android:layout_height="@dimen/dp_69"
|
||||
android:textSize="@dimen/sp_32"
|
||||
android:textColor="@color/white"
|
||||
android:gravity="center"
|
||||
>
|
||||
|
||||
</TextView>
|
||||
@@ -1,10 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/tvCalendarTitle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="@dimen/dp_88"
|
||||
android:layout_height="@dimen/dp_69"
|
||||
android:textSize="@dimen/sp_32"
|
||||
android:textColor="#999999"
|
||||
android:gravity="center"
|
||||
>
|
||||
|
||||
</TextView>
|
||||
Reference in New Issue
Block a user