Jelajahi Sumber

1.添加获取mmse试题库UI跳转

王鹏鹏 2 tahun lalu
induk
melakukan
c20505e696

+ 1 - 0
.idea/misc.xml

@@ -90,6 +90,7 @@
         <entry key="..\:/workspace/hcp-pad/mmse/src/main/res/layout/activity_number.xml" value="0.23697916666666666" />
         <entry key="..\:/workspace/hcp-pad/mmse/src/main/res/layout/activity_questions.xml" value="0.4" />
         <entry key="..\:/workspace/hcp-pad/mmse/src/main/res/layout/activity_signature.xml" value="0.23697916666666666" />
+        <entry key="..\:/workspace/hcp-pad/mmse/src/main/res/layout/fragment_input.xml" value="0.23697916666666666" />
         <entry key="..\:/workspace/hcp-pad/mmse/src/main/res/layout/fragment_number.xml" value="0.23697916666666666" />
         <entry key="..\:/workspace/hcp-pad/mmse/src/main/res/layout/fragment_selected_item.xml" value="0.23697916666666666" />
         <entry key="..\:/workspace/hcp-pad/mmse/src/main/res/layout/fragment_single_judgment.xml" value="0.22239583333333332" />

+ 103 - 0
mmse/src/main/java/com/yingyangfly/mmse/fragment/InputFragment.kt

@@ -0,0 +1,103 @@
+package com.yingyangfly.mmse.fragment
+
+import android.os.Bundle
+import androidx.core.os.bundleOf
+import androidx.navigation.Navigation
+import androidx.recyclerview.widget.GridLayoutManager
+import com.yingyang.mmse.R
+import com.yingyang.mmse.databinding.FragmentInputBinding
+import com.yingyangfly.baselib.base.BaseFragment
+import com.yingyangfly.baselib.db.QuestionsBean
+import com.yingyangfly.baselib.ext.setOnSingleClickListener
+import com.yingyangfly.mmse.adapter.NumberAdapter
+
+/**
+ * 输入框类型
+ */
+class InputFragment : BaseFragment<FragmentInputBinding>() {
+
+    /**
+     * 原始问题id
+     */
+    var questionId = 0
+
+    /**
+     * 翻页问题id
+     */
+    var nextQuestionId = 0
+
+    private var toastInfo = ""
+    private val numberList = mutableListOf<String>()
+    private val numberAdapter by lazy { NumberAdapter() }
+    private val stringBuffer = StringBuffer()
+    var question: QuestionsBean? = null
+
+    override fun onCreate(savedInstanceState: Bundle?) {
+        questionId = arguments?.getInt("questionId") ?: 3
+        nextQuestionId = arguments?.getInt("questionId") ?: 3
+        super.onCreate(savedInstanceState)
+    }
+
+    override fun initViews() {
+        numberList.clear()
+        for (i in 1..9) {
+            numberList.add(i.toString())
+        }
+        numberList.add("删除")
+        numberList.add("0")
+        numberList.add("确定")
+        binding.rvNum.layoutManager = GridLayoutManager(mContext, 3)
+        binding.rvNum.adapter = numberAdapter
+        numberAdapter.setData(numberList)
+    }
+
+    override fun initListener() {
+        binding {
+            //上一页
+            btnPrevious.setOnSingleClickListener { view ->
+                if (questionId == nextQuestionId) {
+                    //跳转第二道题目
+                    val controller = Navigation.findNavController(view)
+                    controller.navigate(R.id.action_inputFragment_to_selectedItemFragment)
+                } else {
+                    nextQuestionId--
+                    loadData()
+                }
+            }
+            //下一页
+            btnNext.setOnSingleClickListener { view ->
+                nextQuestionId++
+                if (nextQuestionId < 6) {
+                    loadData()
+                } else {
+                    val bundle = bundleOf("questionId" to nextQuestionId)
+                    val controller = Navigation.findNavController(view)
+                    controller.navigate(R.id.action_inputFragment_to_judgmentFragment, bundle)
+                }
+            }
+        }
+    }
+
+    override fun initData() {
+
+    }
+
+    override fun onResume() {
+        super.onResume()
+        loadData()
+    }
+
+    /**
+     * 加载数据
+     */
+    private fun loadData() {
+        if (dao != null) {
+            question = dao?.getQuestion(nextQuestionId)
+            if (question != null) {
+                binding.data = question
+                toastInfo = question!!.reviewItem
+                binding.tvYear.text = question!!.inputString
+            }
+        }
+    }
+}

+ 2 - 2
mmse/src/main/java/com/yingyangfly/mmse/fragment/SingleJudgmentFragment.kt → mmse/src/main/java/com/yingyangfly/mmse/fragment/JudgmentFragment.kt

@@ -1,12 +1,12 @@
 package com.yingyangfly.mmse.fragment
 
-import com.yingyang.mmse.databinding.FragmentSingleJudgmentBinding
+import com.yingyang.mmse.databinding.FragmentJudgmentBinding
 import com.yingyangfly.baselib.base.BaseFragment
 
 /**
  * 录入单个判断
  */
-class SingleJudgmentFragment : BaseFragment<FragmentSingleJudgmentBinding>() {
+class JudgmentFragment : BaseFragment<FragmentJudgmentBinding>() {
 
     override fun initViews() {
 

+ 7 - 4
mmse/src/main/java/com/yingyangfly/mmse/fragment/SelectedItemFragment.kt

@@ -1,6 +1,7 @@
 package com.yingyangfly.mmse.fragment
 
 import android.os.Bundle
+import androidx.core.os.bundleOf
 import androidx.navigation.Navigation
 import com.google.android.flexbox.FlexWrap
 import com.google.android.flexbox.FlexboxLayoutManager
@@ -57,15 +58,17 @@ class SelectedItemFragment : BaseFragment<FragmentSelectedItemBinding>() {
                 controller.navigate(R.id.action_selectedItemFragment_to_yearFragment)
             }
 
-            btnNext.setOnSingleClickListener {
+            btnNext.setOnSingleClickListener { view ->
                 if (question != null) {
                     if (question!!.inputString.isNullOrEmpty()) {
                         val str = "请选择" + question!!.reviewItem
                         str.toast()
                     } else {
-
-
-
+                        //跳转下一道题目
+                        questionId++
+                        val bundle = bundleOf("questionId" to questionId)
+                        val controller = Navigation.findNavController(view)
+                        controller.navigate(R.id.action_selectedItemFragment_to_inputFragment, bundle)
                     }
                 }
             }

+ 105 - 0
mmse/src/main/res/layout/fragment_input.xml

@@ -0,0 +1,105 @@
+<?xml version="1.0" encoding="utf-8"?>
+<layout 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"
+    tools:ignore="ResourceName">
+
+    <data>
+
+        <variable
+            name="data"
+            type="com.yingyangfly.baselib.db.QuestionsBean" />
+    </data>
+
+    <androidx.constraintlayout.widget.ConstraintLayout
+        android:layout_width="match_parent"
+        android:layout_height="match_parent">
+
+        <TextView
+            android:id="@+id/tvTitle"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginTop="@dimen/divider_27px"
+            android:text="@{data.reviewItem}"
+            android:textColor="@color/color_FF222222"
+            android:textSize="@dimen/divider_34px"
+            android:textStyle="bold"
+            app:layout_constraintEnd_toEndOf="parent"
+            app:layout_constraintStart_toStartOf="parent"
+            app:layout_constraintTop_toTopOf="parent" />
+
+        <com.google.android.material.card.MaterialCardView
+            android:layout_width="@dimen/divider_398px"
+            android:layout_height="@dimen/divider_448px"
+            android:layout_marginTop="@dimen/divider_28px"
+            android:theme="@style/Theme.MaterialComponents.NoActionBar"
+            app:cardBackgroundColor="@android:color/white"
+            app:cardCornerRadius="@dimen/divider_20px"
+            app:layout_constraintEnd_toEndOf="parent"
+            app:layout_constraintStart_toStartOf="parent"
+            app:layout_constraintTop_toBottomOf="@+id/tvTitle"
+            app:strokeColor="@color/color_FF979797"
+            app:strokeWidth="@dimen/divider_1px">
+
+            <LinearLayout
+                android:layout_width="match_parent"
+                android:layout_height="match_parent"
+                android:orientation="vertical">
+
+                <androidx.appcompat.widget.AppCompatTextView
+                    android:id="@+id/tvYear"
+                    android:layout_width="match_parent"
+                    android:layout_height="@dimen/divider_62px"
+                    android:background="@color/color_FF4A76FF"
+                    android:gravity="center_vertical"
+                    android:paddingStart="@dimen/divider_43px"
+                    android:textColor="@android:color/white"
+                    android:textSize="@dimen/divider_34px"
+                    android:textStyle="bold"
+                    tools:ignore="RtlSymmetry"
+                    tools:text="@string/app_name" />
+
+                <androidx.recyclerview.widget.RecyclerView
+                    android:id="@+id/rvNum"
+                    android:layout_width="match_parent"
+                    android:layout_height="match_parent"
+                    android:layout_marginStart="@dimen/divider_13px"
+                    android:layout_marginTop="@dimen/divider_6px"
+                    android:layout_marginEnd="@dimen/divider_13px" />
+
+            </LinearLayout>
+        </com.google.android.material.card.MaterialCardView>
+
+        <androidx.appcompat.widget.AppCompatButton
+            android:id="@+id/btnPrevious"
+            android:layout_width="@dimen/divider_240px"
+            android:layout_height="@dimen/divider_68px"
+            android:layout_marginStart="@dimen/divider_307px"
+            android:layout_marginBottom="@dimen/divider_60px"
+            android:background="@drawable/bg_previous_question"
+            android:gravity="center"
+            android:text="@string/previous_question"
+            android:textColor="@color/color_FF4A76FF"
+            android:textSize="@dimen/divider_28px"
+            android:textStyle="bold"
+            app:layout_constraintBottom_toBottomOf="parent"
+            app:layout_constraintStart_toStartOf="parent" />
+
+        <androidx.appcompat.widget.AppCompatButton
+            android:id="@+id/btnNext"
+            android:layout_width="@dimen/divider_240px"
+            android:layout_height="@dimen/divider_68px"
+            android:layout_marginEnd="@dimen/divider_305px"
+            android:layout_marginBottom="@dimen/divider_60px"
+            android:background="@drawable/bg_next_question"
+            android:gravity="center"
+            android:text="@string/next_question"
+            android:textColor="@android:color/white"
+            android:textSize="@dimen/divider_28px"
+            android:textStyle="bold"
+            app:layout_constraintBottom_toBottomOf="parent"
+            app:layout_constraintEnd_toEndOf="parent" />
+
+    </androidx.constraintlayout.widget.ConstraintLayout>
+
+</layout>

+ 0 - 0
mmse/src/main/res/layout/fragment_single_judgment.xml → mmse/src/main/res/layout/fragment_judgment.xml


+ 0 - 1
mmse/src/main/res/layout/item_selected_item.xml

@@ -1,6 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
 <layout 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"
     tools:ignore="ResourceName">
 

+ 26 - 0
mmse/src/main/res/navigation/nav_home.xml

@@ -12,6 +12,10 @@
         <action
             android:id="@+id/action_selectedItemFragment_to_yearFragment"
             app:destination="@id/yearFragment" />
+
+        <action
+            android:id="@+id/action_selectedItemFragment_to_inputFragment"
+            app:destination="@id/inputFragment" />
     </fragment>
     <fragment
         android:id="@+id/yearFragment"
@@ -22,4 +26,26 @@
             android:id="@+id/action_yearFragment_to_selectedItemFragment"
             app:destination="@id/selectedItemFragment" />
     </fragment>
+
+    <fragment
+        android:id="@+id/inputFragment"
+        android:name="com.yingyangfly.mmse.fragment.InputFragment"
+        android:label="inputFragment">
+        <action
+            android:id="@+id/action_inputFragment_to_selectedItemFragment"
+            app:destination="@id/selectedItemFragment" />
+
+        <action
+            android:id="@+id/action_inputFragment_to_judgmentFragment"
+            app:destination="@id/judgmentFragment" />
+    </fragment>
+
+    <fragment
+        android:id="@+id/judgmentFragment"
+        android:name="com.yingyangfly.mmse.fragment.JudgmentFragment"
+        android:label="judgmentFragment">
+        <action
+            android:id="@+id/action_judgmentFragment_to_inputFragment"
+            app:destination="@id/inputFragment" />
+    </fragment>
 </navigation>