Bläddra i källkod

完善演示页

Frankensteinly 1 år sedan
förälder
incheckning
1f62fed5ce

+ 1 - 1
app/src/main/AndroidManifest.xml

@@ -22,7 +22,7 @@
         android:theme="@style/Theme.ISCS"
         tools:targetApi="31">
         <activity
-            android:name=".activity.PresentationActivity"
+            android:name=".presentation.PresentationActivity"
             android:exported="false" />
         <activity
             android:name=".activity.SopActivity"

+ 1 - 0
app/src/main/java/com/grkj/iscs/activity/MainActivity.kt

@@ -3,6 +3,7 @@ package com.grkj.iscs.activity
 import android.content.Intent
 import com.grkj.iscs.base.BaseActivity
 import com.grkj.iscs.databinding.ActivityMainBinding
+import com.grkj.iscs.presentation.PresentationActivity
 
 class MainActivity : BaseActivity<ActivityMainBinding>() {
 

+ 0 - 26
app/src/main/java/com/grkj/iscs/activity/PresentationActivity.kt

@@ -1,26 +0,0 @@
-package com.grkj.iscs.activity
-
-import android.os.Environment
-import com.grkj.iscs.base.BaseMvpActivity
-import com.grkj.iscs.databinding.ActivityPresentationBinding
-import com.grkj.iscs.iview.IPresentationView
-import com.grkj.iscs.presenter.PresentationPresenter
-import com.grkj.iscs.util.FileUtil
-
-class PresentationActivity :
-    BaseMvpActivity<IPresentationView, PresentationPresenter, ActivityPresentationBinding>() {
-
-    override val viewBinding: ActivityPresentationBinding
-        get() = ActivityPresentationBinding.inflate(layoutInflater)
-
-    override fun initView() {
-        val path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).absolutePath + "/presentation/presentation.txt"
-        val str = FileUtil.readTxt(path)
-
-
-    }
-
-    override fun initPresenter(): PresentationPresenter {
-        return PresentationPresenter()
-    }
-}

+ 1 - 1
app/src/main/java/com/grkj/iscs/iview/IPresentationView.kt → app/src/main/java/com/grkj/iscs/presentation/IPresentationView.kt

@@ -1,4 +1,4 @@
-package com.grkj.iscs.iview
+package com.grkj.iscs.presentation
 
 import com.grkj.iscs.base.IView
 

+ 80 - 0
app/src/main/java/com/grkj/iscs/presentation/PresentationActivity.kt

@@ -0,0 +1,80 @@
+package com.grkj.iscs.presentation
+
+import android.os.Environment
+import com.grkj.iscs.base.BaseMvpActivity
+import com.grkj.iscs.databinding.ActivityPresentationBinding
+import com.grkj.iscs.util.FileUtil
+import com.grkj.iscs.widget.SelectableInput
+import java.util.stream.Collectors
+
+class PresentationActivity :
+    BaseMvpActivity<IPresentationView, PresentationPresenter, ActivityPresentationBinding>() {
+
+    override val viewBinding: ActivityPresentationBinding
+        get() = ActivityPresentationBinding.inflate(layoutInflater)
+
+    companion object {
+        private val mSopList = mutableListOf(
+            PresentationBean(
+                "士力架车间",
+                "打包线1",
+                "士力架包装车间-打包线1-保养",
+                "士力架包装车间-打包线1-保养",
+                "SOP001",
+                "保养",
+                mutableListOf("E-1", "E-2", "E-3")
+            ),
+            PresentationBean(
+                "德芙车间",
+                "打包线2",
+                "德芙包装车间-打包线2-维护",
+                "德芙包装车间-打包线2-维护",
+                "SOP002",
+                "维护",
+                mutableListOf("E-5", "E-6", "E-7")
+            )
+        )
+
+        // 上锁人
+        private val mLockerList = mutableListOf("上锁人1", "上锁人2", "上锁人3")
+        // 安全员
+        private val mSafetyList = mutableListOf("安全员1", "安全员2", "安全员3")
+
+    }
+
+    override fun initView() {
+        val path =
+            Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).absolutePath + "/presentation/presentation.txt"
+        val str = FileUtil.readTxt(path)
+
+        println("Mac Json : $str")
+
+        mBinding?.siSop?.mOptionList = mSopList.stream().map { it.sop }.collect(Collectors.toList())
+        mBinding?.siSop?.setOnSpinnerSelectListener(object : SelectableInput.OnSpinnerSelectListener {
+            override fun onSelect(str: String?, index: Int) {
+                val sop = mSopList[index]
+                mBinding?.siWorkshop?.setText(sop.workshop)
+                mBinding?.siLine?.setText(sop.line)
+                mBinding?.siTicketName?.setText(sop.ticketName)
+                mBinding?.siTicketNumber?.setText(sop.ticketNumber)
+                mBinding?.siTicketType?.setText(sop.type)
+                mBinding?.siSegregationPoint?.setText(sop.pointList.toString())
+            }
+        })
+
+        mBinding?.siPersonLock?.mOptionList = mLockerList
+        mBinding?.siPersonSafety?.mOptionList = mSafetyList
+
+        mBinding?.confirm?.setOnClickListener {
+            confirm()
+        }
+    }
+
+    private fun confirm() {
+
+    }
+
+    override fun initPresenter(): PresentationPresenter {
+        return PresentationPresenter()
+    }
+}

+ 18 - 0
app/src/main/java/com/grkj/iscs/presentation/PresentationBean.kt

@@ -0,0 +1,18 @@
+package com.grkj.iscs.presentation
+
+data class PresentationBean(
+    // 车间
+    var workshop: String? = null,
+    // 产线
+    var line: String? = null,
+    // SOP
+    var sop: String? = null,
+    // 作业票名称
+    var ticketName: String? = null,
+    // 作业票编号
+    var ticketNumber: String? = null,
+    // 作业类型
+    var type: String? = null,
+    // 隔离点
+    var pointList: MutableList<String> = mutableListOf()
+)

+ 1 - 2
app/src/main/java/com/grkj/iscs/presenter/PresentationPresenter.kt → app/src/main/java/com/grkj/iscs/presentation/PresentationPresenter.kt

@@ -1,6 +1,5 @@
-package com.grkj.iscs.presenter
+package com.grkj.iscs.presentation
 
 import com.grkj.iscs.base.BasePresenter
-import com.grkj.iscs.iview.IPresentationView
 
 class PresentationPresenter : BasePresenter<IPresentationView>() {}

+ 25 - 1
app/src/main/java/com/grkj/iscs/widget/SelectableInput.kt

@@ -5,8 +5,10 @@ import android.util.AttributeSet
 import android.view.LayoutInflater
 import android.view.View
 import android.view.ViewGroup
+import android.view.inputmethod.InputMethodManager
 import android.widget.LinearLayout
 import android.widget.PopupWindow
+import androidx.appcompat.content.res.AppCompatResources
 import com.grkj.iscs.R
 import com.grkj.iscs.databinding.LayoutSelectableInputBinding
 import com.grkj.iscs.databinding.LayoutSelectableinputSpinnerBinding
@@ -38,7 +40,10 @@ class SelectableInput(private val ctx: Context, attrs: AttributeSet) : LinearLay
         setMode(mode)
 
         val isRequired = attrSet.getBoolean(R.styleable.SelectableInput_required, false)
-        mBinding.tvPrefix.visibility = if (isRequired) View.VISIBLE else View.GONE
+        mBinding.tvPrefix.visibility = if (isRequired) View.VISIBLE else View.INVISIBLE
+
+        val isEnabled = attrSet.getBoolean(R.styleable.SelectableInput_enabled, true)
+        mBinding.et.isEnabled = isEnabled
 
         mBinding.tvName.text = attrSet.getString(R.styleable.SelectableInput_name)
         mBinding.et.hint = attrSet.getString(R.styleable.SelectableInput_edittext_hint)
@@ -48,16 +53,20 @@ class SelectableInput(private val ctx: Context, attrs: AttributeSet) : LinearLay
 
     private fun setMode(mode: Int) {
         if (mode == MODE_SELECT) {
+            mBinding.et.background = AppCompatResources.getDrawable(ctx, R.drawable.selectable_input_spinner_bg)
 //            mBinding.et.isEnabled = false
             mBinding.et.inputType = 0
 
 //            btnDropdown.visibility = View.VISIBLE
             mBinding.et.setOnClickListener {
+                println("haha : ${mOptionList.isNotEmpty()}")
                 if (mOptionList.isNotEmpty()) {
                     showDropdown()
                 }
             }
         } else {
+
+            mBinding.et.background = AppCompatResources.getDrawable(ctx, R.drawable.selectable_input_text_bg)
             mBinding.et.isEnabled = true
 
 //            btnDropdown.visibility = View.GONE
@@ -67,7 +76,22 @@ class SelectableInput(private val ctx: Context, attrs: AttributeSet) : LinearLay
 //                val imm = context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
 //                imm.showSoftInput(editText, 0)
 //            }
+            mBinding.et.setOnFocusChangeListener { view, b ->
+                if (!b) {
+                    val imm = ctx.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
+                    imm.hideSoftInputFromWindow(view.windowToken, 0)
+                }
+            }
+        }
+    }
+
+    fun setText(v: String?) {
+        isSkipListener = true
+        mBinding.et.setText(v)
+        v?.let {
+            mBinding.et.setSelection(it.length)
         }
+        isSkipListener = false
     }
 
     private fun showDropdown() {

+ 12 - 0
app/src/main/res/drawable/selectable_input_text_bg.xml

@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
+    <item>
+        <shape android:shape="rectangle">
+            <solid android:color="@color/white" />
+            <corners android:radius="@dimen/selectable_input_radius" />
+            <stroke
+                android:width="@dimen/selectable_input_stroke"
+                android:color="@color/main_color" />
+        </shape>
+    </item>
+</layer-list>

+ 121 - 3
app/src/main/res/layout/activity_presentation.xml

@@ -1,10 +1,128 @@
 <?xml version="1.0" encoding="utf-8"?>
-<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:app="http://schemas.android.com/apk/res-auto"
     xmlns:tools="http://schemas.android.com/tools"
     android:id="@+id/main"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
-    tools:context=".activity.PresentationActivity">
+    android:orientation="vertical"
+    android:paddingHorizontal="100px"
+    android:paddingTop="100px"
+    android:scrollbars="none"
+    tools:context=".presentation.PresentationActivity">
 
-</androidx.constraintlayout.widget.ConstraintLayout>
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:orientation="vertical">
+
+        <com.grkj.iscs.widget.SelectableInput
+            android:id="@+id/si_sop"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            app:edittext_hint="@string/presentation_hint_name"
+            app:mode="select"
+            app:name="@string/presentation_select_sop"
+            app:required="true" />
+
+        <com.grkj.iscs.widget.SelectableInput
+            android:id="@+id/si_workshop"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_marginTop="20px"
+            app:edittext_hint="@string/presentation_hint_workshop"
+            app:enabled="false"
+            app:mode="input"
+            app:name="@string/presentation_select_workshop" />
+
+        <com.grkj.iscs.widget.SelectableInput
+            android:id="@+id/si_line"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_marginTop="20px"
+            app:edittext_hint="@string/presentation_hint_line"
+            app:enabled="false"
+            app:mode="input"
+            app:name="@string/presentation_select_line" />
+
+        <com.grkj.iscs.widget.SelectableInput
+            android:id="@+id/si_ticket_name"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_marginTop="20px"
+            app:edittext_hint="@string/presentation_hint_name"
+            app:mode="input"
+            app:name="@string/presentation_ticket_name" />
+
+        <com.grkj.iscs.widget.SelectableInput
+            android:id="@+id/si_ticket_number"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_marginTop="20px"
+            app:edittext_hint="@string/presentation_hint_number"
+            app:enabled="false"
+            app:mode="input"
+            app:name="@string/presentation_ticket_number" />
+
+        <com.grkj.iscs.widget.SelectableInput
+            android:id="@+id/si_ticket_type"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_marginTop="20px"
+            app:edittext_hint="@string/presentation_hint_type"
+            app:enabled="false"
+            app:mode="input"
+            app:name="@string/presentation_ticket_type" />
+
+        <com.grkj.iscs.widget.SelectableInput
+            android:id="@+id/si_segregation_point"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_marginTop="20px"
+            app:edittext_hint="@string/presentation_hint_point"
+            app:enabled="false"
+            app:mode="input"
+            app:name="@string/presentation_segregation_point" />
+
+        <com.grkj.iscs.widget.SelectableInput
+            android:id="@+id/si_person_lock"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_marginTop="20px"
+            app:edittext_hint="@string/presentation_hint_locker"
+            app:mode="select"
+            app:name="@string/presentation_person_lock"
+            app:required="true" />
+
+        <com.grkj.iscs.widget.SelectableInput
+            android:id="@+id/si_person_lock_together"
+            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" />
+
+        <com.grkj.iscs.widget.SelectableInput
+            android:id="@+id/si_person_safety"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_marginTop="20px"
+            app:edittext_hint="@string/presentation_hint_safety"
+            app:mode="select"
+            app:name="@string/presentation_person_safety" />
+
+        <Button
+            android:id="@+id/confirm"
+            android:layout_width="200dp"
+            android:layout_height="50dp"
+            android:minWidth="0dp"
+            android:minHeight="0dp"
+            android:text="确定"
+            android:textSize="10sp"
+            android:layout_margin="5dp"
+            android:layout_gravity="center_horizontal"/>
+    </LinearLayout>
+</androidx.core.widget.NestedScrollView>

+ 1 - 0
app/src/main/res/values/attrs.xml

@@ -13,5 +13,6 @@
         <attr name="name" format="string" />
         <attr name="spinner_hint" format="string" />
         <attr name="edittext_hint" format="string" />
+        <attr name="enabled" format="boolean" />
     </declare-styleable>
 </resources>

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

@@ -12,7 +12,7 @@
     <dimen name="home_navi_height">600px</dimen>
     <dimen name="home_navi_width">400px</dimen>
 
-    <dimen name="selectable_input_width">150px</dimen>
+    <dimen name="selectable_input_width">250px</dimen>
     <dimen name="selectable_input_radius">6px</dimen>
     <dimen name="selectable_input_stroke">2px</dimen>
     <dimen name="selectable_input_min_height">70px</dimen>

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

@@ -23,4 +23,27 @@
     <string name="end_time">结束时间</string>
     <string name="current_time">当前时间</string>
     <string name="current_sop_number">当前作业票</string>
+
+    <!--  演示页  -->
+    <string name="presentation_select_sop">选择SOP</string>
+    <string name="presentation_select_workshop">选择车间</string>
+    <string name="presentation_select_line">选择产线</string>
+    <string name="presentation_ticket_name">作业票名称</string>
+    <string name="presentation_ticket_number">作业票编号</string>
+    <string name="presentation_ticket_type">作业票类型</string>
+    <string name="presentation_segregation_point">隔离点</string>
+    <string name="presentation_person_lock">上锁人</string>
+    <string name="presentation_person_lock_together">共锁人</string>
+    <string name="presentation_person_safety">安全员</string>
+
+    <string name="presentation_hint_workshop">请选择车间</string>
+    <string name="presentation_hint_line">请选择产线</string>
+    <string name="presentation_hint_sop">请选择...</string>
+    <string name="presentation_hint_name">请选择</string>
+    <string name="presentation_hint_number">请输入作业编号</string>
+    <string name="presentation_hint_type">请选择作业类型</string>
+    <string name="presentation_hint_point">请输入隔离点</string>
+    <string name="presentation_hint_locker">请选择上锁人</string>
+    <string name="presentation_hint_together">请输入共锁人</string>
+    <string name="presentation_hint_safety">请选择安全员</string>
 </resources>