Browse Source

添加主板新增行列号设置

Frankensteinly 1 year ago
parent
commit
6391d50f49

+ 7 - 1
app/src/main/java/com/grkj/iscs/view/fragment/DockTestFragment.kt

@@ -114,5 +114,11 @@ class DockTestFragment : BaseFragment<FragmentDockTestBinding>() {
         }
         }
     }
     }
 
 
-    data class DockTestBean(val address: Byte, val type: Byte, var deviceList: MutableList<Int>? = null)
+    data class DockTestBean(
+        val address: Byte,
+        val row: String,
+        val column: String,
+        val type: Byte,
+        var deviceList: MutableList<Int>? = null
+    )
 }
 }

+ 9 - 1
app/src/main/java/com/grkj/iscs/view/fragment/SystemSettingFragment.kt

@@ -41,7 +41,13 @@ class SystemSettingFragment : BaseMvpFragment<ISystemSettingView, SystemSettingP
         }
         }
 
 
         mBinding?.tvAdd?.setOnClickListener {
         mBinding?.tvAdd?.setOnClickListener {
-            presenter?.addBoard(mBinding?.etAddress?.text.toString(), mSelectedBoardType, mDockList) {
+            presenter?.addBoard(
+                mBinding?.etAddress?.text.toString(),
+                mBinding?.etRow?.text.toString(),
+                mBinding?.etColumn?.text.toString(),
+                mSelectedBoardType,
+                mDockList
+            ) {
                 mBinding?.rvBoard?.adapter?.notifyDataSetChanged()
                 mBinding?.rvBoard?.adapter?.notifyDataSetChanged()
             }
             }
         }
         }
@@ -58,6 +64,8 @@ class SystemSettingFragment : BaseMvpFragment<ISystemSettingView, SystemSettingP
                     holder.setText(R.id.tv_board, "")
                     holder.setText(R.id.tv_board, "")
                 }
                 }
                 holder.setText(R.id.tv_address, byteToHexString(t.address))
                 holder.setText(R.id.tv_address, byteToHexString(t.address))
+                holder.setText(R.id.tv_row, t.row)
+                holder.setText(R.id.tv_column, t.column)
                 holder.setText(R.id.tv_action, getString(R.string.delete))
                 holder.setText(R.id.tv_action, getString(R.string.delete))
                 holder.setOnClickListener(R.id.tv_action) {
                 holder.setOnClickListener(R.id.tv_action) {
                     mDockList.removeAt(position)
                     mDockList.removeAt(position)

+ 15 - 1
app/src/main/java/com/grkj/iscs/view/presenter/SystemSettingPresenter.kt

@@ -48,6 +48,8 @@ class SystemSettingPresenter : BasePresenter<ISystemSettingView>() {
 
 
     fun addBoard(
     fun addBoard(
         address: String,
         address: String,
+        row: String,
+        column: String,
         type: Byte?,
         type: Byte?,
         dockList: MutableList<DockTestFragment.DockTestBean>,
         dockList: MutableList<DockTestFragment.DockTestBean>,
         callback: () -> Unit
         callback: () -> Unit
@@ -60,11 +62,23 @@ class SystemSettingPresenter : BasePresenter<ISystemSettingView>() {
             ToastUtils.tip(R.string.please_input_address)
             ToastUtils.tip(R.string.please_input_address)
             return
             return
         }
         }
+        if (row.isEmpty()) {
+            ToastUtils.tip(R.string.please_input_row)
+            return
+        }
+        if (column.isEmpty()) {
+            ToastUtils.tip(R.string.please_input_column)
+            return
+        }
+        if (dockList.any { it.row == row && it.column == column }) {
+            ToastUtils.tip(R.string.row_and_column_conflict)
+            return
+        }
         if (!CommonUtils.isValidHex(address)) {
         if (!CommonUtils.isValidHex(address)) {
             ToastUtils.tip(R.string.please_input_valid_address)
             ToastUtils.tip(R.string.please_input_valid_address)
             return
             return
         }
         }
-        dockList.add(DockTestFragment.DockTestBean(address.toInt(16).toByte(), type))
+        dockList.add(DockTestFragment.DockTestBean(address.toInt(16).toByte(), row, column, type))
         callback()
         callback()
     }
     }
 
 

+ 31 - 3
app/src/main/res/layout/fragment_system_setting.xml

@@ -13,7 +13,7 @@
     <LinearLayout
     <LinearLayout
         android:layout_width="0dp"
         android:layout_width="0dp"
         android:layout_height="match_parent"
         android:layout_height="match_parent"
-        android:layout_weight="1"
+        android:layout_weight="4"
         android:orientation="vertical">
         android:orientation="vertical">
 
 
         <TextView
         <TextView
@@ -62,10 +62,38 @@
                 android:id="@+id/et_address"
                 android:id="@+id/et_address"
                 style="@style/CommonEdit"
                 style="@style/CommonEdit"
                 android:layout_width="30dp"
                 android:layout_width="30dp"
-                android:layout_marginLeft="@dimen/common_spacing_small"
+                android:layout_marginHorizontal="@dimen/common_spacing_small"
                 android:gravity="center"
                 android:gravity="center"
                 android:maxLength="2" />
                 android:maxLength="2" />
 
 
+            <!-- 行 -->
+            <TextView
+                style="@style/CommonTextView"
+                android:text="@string/row" />
+
+            <EditText
+                android:id="@+id/et_row"
+                style="@style/CommonEdit"
+                android:layout_width="30dp"
+                android:layout_marginHorizontal="@dimen/common_spacing_small"
+                android:gravity="center"
+                android:inputType="number"
+                android:maxLength="1" />
+
+            <!-- 列 -->
+            <TextView
+                style="@style/CommonTextView"
+                android:text="@string/column" />
+
+            <EditText
+                android:id="@+id/et_column"
+                style="@style/CommonEdit"
+                android:layout_width="30dp"
+                android:layout_marginLeft="@dimen/common_spacing_small"
+                android:gravity="center"
+                android:inputType="number"
+                android:maxLength="1" />
+
             <TextView
             <TextView
                 android:id="@+id/tv_add"
                 android:id="@+id/tv_add"
                 android:layout_width="wrap_content"
                 android:layout_width="wrap_content"
@@ -93,7 +121,7 @@
     <RelativeLayout
     <RelativeLayout
         android:layout_width="0dp"
         android:layout_width="0dp"
         android:layout_height="match_parent"
         android:layout_height="match_parent"
-        android:layout_weight="1">
+        android:layout_weight="2">
 
 
         <TextView
         <TextView
             android:id="@+id/tv_port_title"
             android:id="@+id/tv_port_title"

+ 26 - 0
app/src/main/res/layout/item_rv_board.xml

@@ -38,6 +38,32 @@
             android:layout_marginVertical="@dimen/common_spacing_small"
             android:layout_marginVertical="@dimen/common_spacing_small"
             android:background="@color/common_bg_white_30" />
             android:background="@color/common_bg_white_30" />
 
 
+        <TextView
+            android:id="@+id/tv_row"
+            style="@style/CommonTextView"
+            android:layout_width="0dp"
+            android:layout_weight="1"
+            android:text="@string/row" />
+
+        <View
+            android:layout_width="@dimen/divider_line_width"
+            android:layout_height="match_parent"
+            android:layout_marginVertical="@dimen/common_spacing_small"
+            android:background="@color/common_bg_white_30" />
+
+        <TextView
+            android:id="@+id/tv_column"
+            style="@style/CommonTextView"
+            android:layout_width="0dp"
+            android:layout_weight="1"
+            android:text="@string/column" />
+
+        <View
+            android:layout_width="@dimen/divider_line_width"
+            android:layout_height="match_parent"
+            android:layout_marginVertical="@dimen/common_spacing_small"
+            android:background="@color/common_bg_white_30" />
+
         <TextView
         <TextView
             android:id="@+id/tv_action"
             android:id="@+id/tv_action"
             style="@style/CommonTextView"
             style="@style/CommonTextView"

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

@@ -282,4 +282,9 @@
     <string name="login_method_tip">● 您可以通过指纹或刷卡直接进行登录</string>
     <string name="login_method_tip">● 您可以通过指纹或刷卡直接进行登录</string>
     <string name="no_key_available_dialog_tip">暂无可用钥匙,确认继续执行作业票吗?</string>
     <string name="no_key_available_dialog_tip">暂无可用钥匙,确认继续执行作业票吗?</string>
     <string name="lock_take_report_fail">挂锁取出上报失败</string>
     <string name="lock_take_report_fail">挂锁取出上报失败</string>
+    <string name="row">行</string>
+    <string name="column">列</string>
+    <string name="please_input_row">请输入行号</string>
+    <string name="please_input_column">请输入列号</string>
+    <string name="row_and_column_conflict">存在相同的行列号,请重新输入</string>
 </resources>
 </resources>