Parcourir la source

调整首页作业票显示样式

Frankensteinly il y a 6 mois
Parent
commit
d5aab870ab

+ 2 - 1
app/src/main/java/com/grkj/iscs/model/Constants.kt

@@ -93,8 +93,9 @@ object Constants {
     private val TICKET_CHANGE_SHIFTS = TicketType(2, "icon.permit.shift")
     private val TICKET_CLEAN = TicketType(3, "icon.permit.clean")
     private val TICKET_SWITCH_PRODUCT = TicketType(4, "icon.permit.changeover")
+    private val TICKET_MORE =  TicketType(5, "icon.permit.more")
 
-    private val mTicketTypeList = mutableListOf(TICKET_REPAIR, TICKET_PRE_MAINTENANCE, TICKET_CHANGE_SHIFTS, TICKET_CLEAN, TICKET_SWITCH_PRODUCT)
+    private val mTicketTypeList = mutableListOf(TICKET_REPAIR, TICKET_PRE_MAINTENANCE, TICKET_CHANGE_SHIFTS, TICKET_CLEAN, TICKET_SWITCH_PRODUCT, TICKET_MORE)
 
     fun getTicketKey(type: Int?): String? {
         return mTicketTypeList.find { it.type == type }?.key

+ 51 - 0
app/src/main/java/com/grkj/iscs/view/dialog/TicketListDialog.kt

@@ -0,0 +1,51 @@
+package com.grkj.iscs.view.dialog
+
+import android.content.Context
+import com.bumptech.glide.Glide
+import com.grkj.iscs.R
+import com.grkj.iscs.databinding.DialogTicketListBinding
+import com.grkj.iscs.model.Constants
+import com.grkj.iscs.model.vo.ticket.WorkstationTicketListRespVO
+import com.grkj.iscs.util.SPUtils
+import com.grkj.iscs.view.base.BaseDialog
+import com.zhy.adapter.recyclerview.CommonAdapter
+import com.zhy.adapter.recyclerview.base.ViewHolder
+
+/**
+ * 作业列表弹框
+ */
+class TicketListDialog(ctx: Context, var onSelect: (Int) -> Unit) : BaseDialog<DialogTicketListBinding>(ctx) {
+
+    private val mTicketList = mutableListOf<WorkstationTicketListRespVO>()
+
+    override val viewBinding: DialogTicketListBinding
+        get() = DialogTicketListBinding.inflate(layoutInflater)
+
+    override fun initView() {
+        mBinding?.rvList?.adapter = object : CommonAdapter<WorkstationTicketListRespVO>(
+            context,
+            R.layout.item_rv_ticket_list,
+            mTicketList
+        ) {
+            override fun convert(holder: ViewHolder, ticket: WorkstationTicketListRespVO, position: Int) {
+                holder.setText(R.id.tv_index, "${position + 1}")
+                ticket.ticketType?.let {
+                    Glide.with(context).load(SPUtils.getAttributeValue(context, Constants.getTicketKey(it.toInt()))).into(holder.getView(R.id.iv_icon))
+                }
+                holder.setText(R.id.tv_name, ticket.ticketName)
+                holder.setOnClickListener(R.id.tv_action) {
+                    onSelect(position)
+                    dismiss()
+                }
+            }
+        }
+    }
+
+    fun setDataAndShow(title: String, ticketList: MutableList<WorkstationTicketListRespVO>) {
+        mBinding?.tvTitle?.text = "$title ${context.getString(R.string.ticket_processing)}"
+        mTicketList.clear()
+        mTicketList.addAll(ticketList)
+        mBinding?.rvList?.adapter?.notifyDataSetChanged()
+        show()
+    }
+}

+ 41 - 13
app/src/main/java/com/grkj/iscs/view/fragment/WorkshopFragment.kt

@@ -14,6 +14,7 @@ import com.grkj.iscs.util.SPUtils
 import com.grkj.iscs.util.ToastUtils
 import com.grkj.iscs.util.log.LogUtil
 import com.grkj.iscs.view.base.BaseMvpFragment
+import com.grkj.iscs.view.dialog.TicketListDialog
 import com.grkj.iscs.view.iview.IWorkshopView
 import com.grkj.iscs.view.presenter.WorkshopPresenter
 import com.grkj.iscs.view.widget.CustomMarkLayer
@@ -82,18 +83,43 @@ class WorkshopFragment(val changePage: (PageChangeBO) -> Unit) :
                         }
                         mPointList.forEach { itPoint ->
                             itPoint.ticketList = it.filter { it.workstationId == itPoint.workstationId }.toMutableList()
-                            itPoint.ticketList.forEach { itTicket ->
-                                if (itTicket.ticketType == null) {
-                                    itTicket.bitmap = BitmapUtil.getResizedBitmapFromMipmap(requireContext(), R.mipmap.ticket_type_placeholder, 60, 60)
-                                } else {
+//                            itPoint.ticketList.forEach { itTicket ->
+//                                if (itTicket.ticketType == null) {
+//                                    itTicket.bitmap = BitmapUtil.getResizedBitmapFromMipmap(requireContext(), R.mipmap.ticket_type_placeholder, 60, 60)
+//                                } else {
+//                                    BitmapUtil.loadBitmapFromUrl(
+//                                        requireContext(),
+//                                        SPUtils.getAttributeValue(requireContext(), Constants.getTicketKey(itTicket.ticketType.toInt())),
+//                                        R.mipmap.ticket_type_placeholder,
+//                                        60, 60
+//                                    ) { itBitmap ->
+//                                        itTicket.bitmap = itBitmap ?: BitmapUtil.getResizedBitmapFromMipmap(requireContext(), R.mipmap.ticket_type_placeholder, 60, 60)
+//                                    }
+//                                }
+//                            }
+                            itPoint.ticketList.take(4).forEachIndexed { index, itTicket ->
+                                if (itPoint.ticketList.size > 3 && index == 3) {
                                     BitmapUtil.loadBitmapFromUrl(
                                         requireContext(),
-                                        SPUtils.getAttributeValue(requireContext(), Constants.getTicketKey(itTicket.ticketType.toInt())),
+                                        SPUtils.getAttributeValue(requireContext(), Constants.getTicketKey(5)),
                                         R.mipmap.ticket_type_placeholder,
                                         60, 60
                                     ) { itBitmap ->
                                         itTicket.bitmap = itBitmap ?: BitmapUtil.getResizedBitmapFromMipmap(requireContext(), R.mipmap.ticket_type_placeholder, 60, 60)
                                     }
+                                } else {
+                                    if (itTicket.ticketType == null) {
+                                        itTicket.bitmap = BitmapUtil.getResizedBitmapFromMipmap(requireContext(), R.mipmap.ticket_type_placeholder, 60, 60)
+                                    } else {
+                                        BitmapUtil.loadBitmapFromUrl(
+                                            requireContext(),
+                                            SPUtils.getAttributeValue(requireContext(), Constants.getTicketKey(itTicket.ticketType.toInt())),
+                                            R.mipmap.ticket_type_placeholder,
+                                            60, 60
+                                        ) { itBitmap ->
+                                            itTicket.bitmap = itBitmap ?: BitmapUtil.getResizedBitmapFromMipmap(requireContext(), R.mipmap.ticket_type_placeholder, 60, 60)
+                                        }
+                                    }
                                 }
                             }
                         }
@@ -134,15 +160,17 @@ class WorkshopFragment(val changePage: (PageChangeBO) -> Unit) :
                                 )
                             )
                         } else {
-                            changePage(
-                                PageChangeBO(
-                                    2,
-                                    mPointList[index].workstationId,
-                                    mPointList[index].ticketList[btnIndex].ticketId,
-                                    mPointList[index].ticketList[btnIndex].machineryId,
-                                    mPointList[index].name
+                            TicketListDialog(requireContext()) { selectIdx ->
+                                changePage(
+                                    PageChangeBO(
+                                        2,
+                                        mPointList[index].workstationId,
+                                        mPointList[index].ticketList[selectIdx].ticketId,
+                                        mPointList[index].ticketList[selectIdx].machineryId,
+                                        mPointList[index].name
+                                    )
                                 )
-                            )
+                            }.setDataAndShow(mPointList[index].name, mPointList[index].ticketList)
                         }
                     }
                 })

+ 57 - 26
app/src/main/java/com/grkj/iscs/view/widget/CustomMarkLayer.kt

@@ -152,36 +152,67 @@ class CustomMarkLayer @JvmOverloads constructor(
 
                     paint.color = Color.parseColor("#FFFFFF")
                     paint.textSize = radiusMark
-//                    if (mapView.currentZoom.toDouble() > 0.8) {
                     // 一直显示文字
-                        canvas.drawText(
-                            point.name,
-                            goal[0] - width / 2,
-                            goal[1] + radiusMark / 3.0f,
-                            paint
-                        )
-//                    }
-
-                    val list = point.ticketList
+                    canvas.drawText(
+                        point.name,
+                        goal[0] - width / 2,
+                        goal[1] + radiusMark / 3.0f,
+                        paint
+                    )
+
+                    val list = point.ticketList.take(3)
                     if (list.isNotEmpty()) {
                         for (j in list.indices) {
+                            val ticketX = if (list.size % 2 == 0) { // 偶数个
+                                if (j + 1 <= list.size / 2) {
+                                    goal[0] - list[j].bitmap!!.width * (list.size / 2 - j)
+                                } else {
+                                    goal[0] + list[j].bitmap!!.width * (j - list.size / 2)
+                                }
+                            } else {    // 奇数个
+                                if (j + 1 <= list.size / 2) {
+                                    goal[0] - list[j].bitmap!!.width * (list.size / 2 - j + 0.5f)
+                                } else {
+                                    goal[0] + list[j].bitmap!!.width * (j - list.size / 2 - 0.5f)
+                                }
+                            }
+                            val ticketY = goal[1] - list[j].bitmap!!.height / 2 * 3
+
+                            // 绘制图标
                             canvas.drawBitmap(
-                                list[j].bitmap!!,
-                                // 偶数个
-                                if (list.size % 2 == 0) {
-                                    if (j + 1 <= list.size / 2) {
-                                        goal[0] - list[j].bitmap!!.width * (list.size / 2 - j)
-                                    } else {
-                                        goal[0] + list[j].bitmap!!.width * (j - list.size / 2)
-                                    }
-                                } else {    // 奇数个
-                                    if (j + 1 <= list.size / 2) {
-                                        goal[0] - list[j].bitmap!!.width * (list.size / 2 - j + 0.5f)
-                                    } else {
-                                        goal[0] + list[j].bitmap!!.width * (j - list.size / 2 - 0.5f)
-                                    }
-                                },
-                                goal[1] - list[j].bitmap!!.height / 2 * 3,
+                                if (point.ticketList.size > 3 && j == 2) point.ticketList[j + 1].bitmap!! else list[j].bitmap!!,
+                                ticketX,
+                                ticketY,
+                                paint
+                            )
+
+                            // 计算序号背景的位置和大小
+                            val numberText = if (point.ticketList.size > 3 && j == list.size - 1) "${j + 1}+" else (j + 1).toString()
+                            val numberWidth = paint.measureText(numberText)
+                            val numberHeight = paint.fontMetrics.descent - paint.fontMetrics.ascent
+                            val numberRectLeft = ticketX + list[j].bitmap!!.width / 2 - radiusMark / 4.0f * 3
+                            val numberRectTop = ticketY - list[j].bitmap!!.height / 2 - radiusMark / 4.0f * 3
+                            val numberRectRight = ticketX + list[j].bitmap!!.width / 2 + radiusMark / 4.0f * 3
+                            val numberRectBottom = ticketY - list[j].bitmap!!.height / 2 + radiusMark / 4.0f * 3
+
+                            // 绘制序号背景
+                            paint.color = Color.parseColor("#00AAFF")
+                            canvas.drawRoundRect(
+                                numberRectLeft,
+                                numberRectTop,
+                                numberRectRight,
+                                numberRectBottom,
+                                5f,
+                                5f,
+                                paint
+                            )
+
+                            // 绘制序号
+                            paint.color = Color.WHITE
+                            canvas.drawText(
+                                numberText,
+                                ticketX + list[j].bitmap!!.width / 2 - numberWidth / 2,
+                                ticketY - list[j].bitmap!!.height / 2 + radiusMark / 3.0f,
                                 paint
                             )
                         }

+ 62 - 0
app/src/main/res/layout/dialog_ticket_list.xml

@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="utf-8"?>
+<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    android:layout_width="wrap_content"
+    android:layout_height="wrap_content"
+    app:cardCornerRadius="@dimen/common_radius">
+
+    <LinearLayout
+        android:layout_width="@dimen/dialog_tip_width"
+        android:layout_height="@dimen/dialog_ticket_list_height"
+        android:orientation="vertical">
+
+        <TextView
+            android:id="@+id/tv_title"
+            style="@style/CommonTextView"
+            android:layout_width="match_parent"
+            android:background="@color/main_color"
+            android:gravity="left"
+            android:paddingVertical="5dp"
+            android:paddingLeft="10dp" />
+
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:background="@color/common_bg_black_30"
+            android:orientation="horizontal"
+            android:paddingVertical="@dimen/common_spacing_smallest">
+
+            <TextView
+                style="@style/CommonTextView"
+                android:layout_weight="1"
+                android:width="0dp"
+                android:text="@string/index_number"
+                android:textColor="@color/black" />
+
+            <TextView
+                style="@style/CommonTextView"
+                android:layout_weight="1"
+                android:width="0dp"
+                android:text="@string/icon"
+                android:textColor="@color/black" />
+
+            <TextView
+                style="@style/CommonTextView"
+                android:layout_weight="2"
+                android:width="0dp"
+                android:text="@string/ticket_name"
+                android:textColor="@color/black" />
+
+            <TextView
+                style="@style/CommonTextView"
+                android:layout_weight="1"
+                android:width="0dp"
+                android:text="@string/action"
+                android:textColor="@color/black" />
+        </LinearLayout>
+
+        <androidx.recyclerview.widget.RecyclerView
+            android:id="@+id/rv_list"
+            style="@style/CommonRecyclerView" />
+    </LinearLayout>
+</androidx.cardview.widget.CardView>

+ 57 - 0
app/src/main/res/layout/item_rv_ticket_list.xml

@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/root"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:orientation="vertical">
+
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:gravity="center_vertical"
+        android:orientation="horizontal">
+
+        <TextView
+            android:id="@+id/tv_index"
+            style="@style/CommonTextView"
+            android:layout_width="0dp"
+            android:layout_weight="1"
+            android:textColor="@color/black"
+            android:textSize="@dimen/common_text_size_small" />
+
+        <RelativeLayout
+            android:layout_width="0dp"
+            android:layout_height="wrap_content"
+            android:layout_weight="1">
+
+            <ImageView
+                android:id="@+id/iv_icon"
+                android:layout_width="@dimen/common_icon_size"
+                android:layout_height="@dimen/common_icon_size"
+                android:layout_centerInParent="true" />
+        </RelativeLayout>
+
+        <TextView
+            android:id="@+id/tv_name"
+            style="@style/CommonTextView"
+            android:layout_width="0dp"
+            android:layout_weight="2"
+            android:textColor="@color/black"
+            android:textSize="@dimen/common_text_size_small" />
+
+        <TextView
+            android:id="@+id/tv_action"
+            style="@style/CommonTextView"
+            android:layout_width="0dp"
+            android:layout_weight="1"
+            android:text="@string/check"
+            android:textColor="@color/main_color"
+            android:textSize="@dimen/common_text_size_small" />
+    </LinearLayout>
+
+    <View
+        android:layout_width="match_parent"
+        android:layout_height="@dimen/divider_line_width"
+        android:layout_marginVertical="@dimen/common_spacing_smallest"
+        android:background="@color/common_bg_black_30" />
+</LinearLayout>

+ 2 - 1
app/src/main/res/values/dimens.xml

@@ -73,7 +73,8 @@
     <dimen name="item_rv_technology_type_padding">3dp</dimen>
     <dimen name="dialog_tip_width">256dp</dimen>
     <dimen name="dialog_tip_height">144dp</dimen>
-    
+    <dimen name="dialog_ticket_list_height">200dp</dimen>
+
     <dimen name="item_rv_step_width">80dp</dimen>
     <dimen name="item_rv_step_height">110dp</dimen>
     <dimen name="item_rv_menu_size">58dp</dimen>

+ 6 - 0
app/src/main/res/values/strings.xml

@@ -304,4 +304,10 @@
     <string name="repair_key">修复</string>
     <string name="no_key_to_repair">钥匙不存在,无法修复</string>
     <string name="key_take_error_tip">钥匙分配失败,请检查设备状态</string>
+    
+    <string name="index_number">编号</string>
+    <string name="icon">图标</string>
+    <string name="ticket_name">作业票名称</string>
+    <string name="check">查看</string>
+    <string name="ticket_processing">进行中的作业</string>
 </resources>