소스 검색

演示页添加共锁人选择

Frankensteinly 1 년 전
부모
커밋
c19db154ea

+ 23 - 1
app/src/main/java/com/grkj/iscs/presentation/PresentationActivity.kt

@@ -2,12 +2,17 @@ package com.grkj.iscs.presentation
 
 import android.os.Environment
 import android.view.Gravity
+import android.widget.CheckBox
+import androidx.recyclerview.widget.LinearLayoutManager
+import com.grkj.iscs.R
 import com.grkj.iscs.base.BaseMvpActivity
 import com.grkj.iscs.databinding.ActivityPresentationBinding
 import com.grkj.iscs.modbus.ModBusController
 import com.grkj.iscs.util.FileUtil
 import com.grkj.iscs.widget.SelectableInput
 import com.manu.mdatepicker.MDatePicker
+import com.zhy.adapter.recyclerview.CommonAdapter
+import com.zhy.adapter.recyclerview.base.ViewHolder
 import java.text.SimpleDateFormat
 import java.util.Date
 import java.util.stream.Collectors
@@ -44,7 +49,11 @@ class PresentationActivity :
         private val mLockerList = mutableListOf("上锁人1", "上锁人2", "上锁人3")
         // 安全员
         private val mSafetyList = mutableListOf("安全员1", "安全员2", "安全员3")
-
+        // 共锁人
+        private val mLockerTogetherList = mutableListOf(
+            LockerTogetherBean("共锁人1", false),
+            LockerTogetherBean("共锁人2", false),
+            LockerTogetherBean("共锁人3", false))
     }
 
     override fun initView() {
@@ -99,6 +108,17 @@ class PresentationActivity :
                 }
                .build().show()
         }
+
+        (mBinding?.rvLockerTogether?.layoutManager as LinearLayoutManager).orientation =  LinearLayoutManager.HORIZONTAL
+        mBinding?.rvLockerTogether?.adapter = object : CommonAdapter<LockerTogetherBean>(this, R.layout.item_rv_locker_together, mLockerTogetherList) {
+            override fun convert(holder: ViewHolder, data: LockerTogetherBean, position: Int) {
+                holder.setText(R.id.tv_name, data.name)
+                holder.setChecked(R.id.cb, data.isChecked)
+                holder.getView<CheckBox>(R.id.cb).setOnCheckedChangeListener { _, b ->
+                    data.isChecked = b
+                }
+            }
+        }
     }
 
     private fun confirm() {
@@ -113,4 +133,6 @@ class PresentationActivity :
         super.onDestroy()
         ModBusController.stop()
     }
+
+    data class LockerTogetherBean(var name: String? = null, var isChecked: Boolean = false)
 }

+ 15 - 7
app/src/main/res/layout/activity_presentation.xml

@@ -95,16 +95,24 @@
             app:name="@string/presentation_person_lock"
             app:required="true" />
 
-        <com.grkj.iscs.widget.SelectableInput
-            android:id="@+id/si_person_lock_together"
+        <LinearLayout
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:layout_marginTop="20px"
-            app:edittext_hint="@string/presentation_hint_together"
-            app:enabled="true"
-            app:mode="input"
-            app:name="@string/presentation_person_lock_together"
-            app:required="true" />
+            android:orientation="horizontal">
+
+            <TextView
+                android:id="@+id/tv_name"
+                android:layout_width="@dimen/selectable_input_width"
+                android:layout_height="wrap_content"
+                android:text="@string/presentation_person_lock_together"
+                android:textColor="@color/main_color"
+                android:textSize="@dimen/common_text_size" />
+
+            <androidx.recyclerview.widget.RecyclerView
+                android:id="@+id/rv_locker_together"
+                style="@style/CommonRecyclerView" />
+        </LinearLayout>
 
         <com.grkj.iscs.widget.SelectableInput
             android:id="@+id/si_person_safety"

+ 19 - 0
app/src/main/res/layout/item_rv_locker_together.xml

@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="wrap_content"
+    android:layout_height="wrap_content"
+    android:layout_margin="@dimen/rv_item_margin"
+    android:gravity="center_vertical"
+    android:orientation="horizontal">
+
+    <CheckBox
+        android:id="@+id/cb"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content" />
+
+    <TextView
+        android:id="@+id/tv_name"
+        style="@style/CommonTextView"
+        android:textColor="@color/main_color" />
+
+</LinearLayout>