Explorar o código

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

王鹏鹏 %!s(int64=2) %!d(string=hai) anos
pai
achega
373db386db

+ 18 - 0
mmse/src/main/java/com/yingyangfly/mmse/fragment/DrawDesignsFragment.kt

@@ -1,7 +1,12 @@
 package com.yingyangfly.mmse.fragment
 
+import android.os.Bundle
+import androidx.core.os.bundleOf
+import androidx.navigation.Navigation
+import com.yingyang.mmse.R
 import com.yingyang.mmse.databinding.FragmentDrawDesignsBinding
 import com.yingyangfly.baselib.base.BaseFragment
+import com.yingyangfly.baselib.ext.setOnSingleClickListener
 
 /**
  * 画图
@@ -12,7 +17,20 @@ class DrawDesignsFragment : BaseFragment<FragmentDrawDesignsBinding>() {
     }
 
     override fun initListener() {
+        binding {
+            btnPrevious.setOnSingleClickListener {
+                val bundle = bundleOf("questionId" to 29)
+                val controller = Navigation.findNavController(it)
+                controller.navigate(
+                    R.id.action_countFragment_to_multipleChoiceFragment,
+                    bundle
+                )
+            }
 
+            btnNext.setOnSingleClickListener {
+
+            }
+        }
     }
 
     override fun initData() {

+ 35 - 21
mmse/src/main/java/com/yingyangfly/mmse/fragment/JudgmentFragment.kt

@@ -35,36 +35,50 @@ class JudgmentFragment : BaseFragment<FragmentJudgmentBinding>() {
     override fun initListener() {
         binding {
             btnPrevious.setOnSingleClickListener {
-                questionId--
-                if (questionId == 5) {
-                    val bundle = bundleOf("questionId" to questionId)
+                if (questionId == 29) {
+                    val bundle = bundleOf("questionId" to 26)
                     val controller = Navigation.findNavController(it)
                     controller.navigate(
-                        R.id.action_judgmentFragment_to_selectedItemFragment,
+                        R.id.action_judgmentFragment_to_multipleChoiceFragment,
                         bundle
                     )
                 } else {
-                    judgeRadio.clearCheck()
-                    loadData()
+                    questionId--
+                    if (questionId == 5) {
+                        val bundle = bundleOf("questionId" to questionId)
+                        val controller = Navigation.findNavController(it)
+                        controller.navigate(
+                            R.id.action_judgmentFragment_to_selectedItemFragment,
+                            bundle
+                        )
+                    } else {
+                        judgeRadio.clearCheck()
+                        loadData()
+                    }
                 }
             }
             btnNext.setOnSingleClickListener {
-                if (question != null) {
-                    if (question!!.inputString.isNullOrEmpty()) {
-                        val str = "请判断受试者的回答是否正确"
-                        str.toast()
-                    } else {
-                        questionId++
-                        if (questionId < 11) {
-                            judgeRadio.clearCheck()
-                            loadData()
+                if (questionId == 29) {
+                    val controller = Navigation.findNavController(it)
+                    controller.navigate(R.id.action_judgmentFragment_to_multipleChoiceFragment)
+                } else {
+                    if (question != null) {
+                        if (question!!.inputString.isNullOrEmpty()) {
+                            val str = "请判断受试者的回答是否正确"
+                            str.toast()
                         } else {
-                            val bundle = bundleOf("questionId" to questionId)
-                            val controller = Navigation.findNavController(it)
-                            controller.navigate(
-                                R.id.action_judgmentFragment_to_soundRecordFragment,
-                                bundle
-                            )
+                            questionId++
+                            if (questionId < 11) {
+                                judgeRadio.clearCheck()
+                                loadData()
+                            } else {
+                                val bundle = bundleOf("questionId" to questionId)
+                                val controller = Navigation.findNavController(it)
+                                controller.navigate(
+                                    R.id.action_judgmentFragment_to_soundRecordFragment,
+                                    bundle
+                                )
+                            }
                         }
                     }
                 }

+ 37 - 18
mmse/src/main/java/com/yingyangfly/mmse/fragment/MultipleChoiceFragment.kt

@@ -43,24 +43,39 @@ class MultipleChoiceFragment : BaseFragment<FragmentMultipleChoiceBinding>() {
     override fun initListener() {
         binding {
             btnPrevious.setOnSingleClickListener {
-                val bundle = bundleOf("questionId" to questionId)
-                val controller = Navigation.findNavController(it)
-                controller.navigate(
-                    R.id.action_multipleChoiceFragment_to_soundRecordFragment,
-                    bundle
-                )
-            }
-            btnNext.setOnSingleClickListener {
-                if (judge()) {
-                    val bundle = Bundle()
-                    bundle.putInt("questionId", 14)
+                if (questionId == 26) {
+                    val controller = Navigation.findNavController(it)
+                    controller.navigate(R.id.action_multipleChoiceFragment_to_recordActionFragment)
+                } else {
+                    val bundle = bundleOf("questionId" to questionId)
                     val controller = Navigation.findNavController(it)
                     controller.navigate(
-                        R.id.action_multipleChoiceFragment_to_countFragment,
+                        R.id.action_multipleChoiceFragment_to_soundRecordFragment,
                         bundle
                     )
                 }
             }
+            btnNext.setOnSingleClickListener {
+                if (judge()) {
+                    if (questionId == 26) {
+                        val bundle = Bundle()
+                        bundle.putInt("questionId", 29)
+                        val controller = Navigation.findNavController(it)
+                        controller.navigate(
+                            R.id.action_multipleChoiceFragment_to_judgmentFragment,
+                            bundle
+                        )
+                    } else {
+                        val bundle = Bundle()
+                        bundle.putInt("questionId", 14)
+                        val controller = Navigation.findNavController(it)
+                        controller.navigate(
+                            R.id.action_multipleChoiceFragment_to_countFragment,
+                            bundle
+                        )
+                    }
+                }
+            }
         }
     }
 
@@ -79,15 +94,17 @@ class MultipleChoiceFragment : BaseFragment<FragmentMultipleChoiceBinding>() {
     private fun loadData() {
         choiceItemList.clear()
         if (dao != null) {
-            val firstquestion = dao?.getQuestion(11)
+            val firstquestion = dao?.getQuestion(questionId)
             if (firstquestion != null) {
                 choiceItemList.add(firstquestion)
             }
-            val secondQuestion = dao?.getQuestion(12)
+            val secondQuestionnId = questionId + 1
+            val secondQuestion = dao?.getQuestion(secondQuestionnId)
             if (secondQuestion != null) {
                 choiceItemList.add(secondQuestion)
             }
-            val thirdQuestion = dao?.getQuestion(13)
+            val thirdQuestionId = questionId + 1
+            val thirdQuestion = dao?.getQuestion(thirdQuestionId)
             if (thirdQuestion != null) {
                 choiceItemList.add(thirdQuestion)
             }
@@ -100,17 +117,19 @@ class MultipleChoiceFragment : BaseFragment<FragmentMultipleChoiceBinding>() {
      */
     private fun judge(): Boolean {
         if (dao != null) {
-            val firstquestion = dao?.getQuestion(11)
+            val firstquestion = dao?.getQuestion(questionId)
             if (firstquestion != null && firstquestion.inputString.isNullOrEmpty()) {
                 "请判断是否正确".toast()
                 return false
             }
-            val secondQuestion = dao?.getQuestion(12)
+            val secondQuestionnId = questionId + 1
+            val secondQuestion = dao?.getQuestion(secondQuestionnId)
             if (secondQuestion != null && secondQuestion.inputString.isNullOrEmpty()) {
                 "请判断是否正确".toast()
                 return false
             }
-            val thirdQuestion = dao?.getQuestion(13)
+            val thirdQuestionId = questionId + 1
+            val thirdQuestion = dao?.getQuestion(thirdQuestionId)
             if (thirdQuestion != null && thirdQuestion.inputString.isNullOrEmpty()) {
                 "请判断是否正确".toast()
                 return false

+ 4 - 1
mmse/src/main/java/com/yingyangfly/mmse/fragment/RecordActionFragment.kt

@@ -1,5 +1,6 @@
 package com.yingyangfly.mmse.fragment
 
+import androidx.core.os.bundleOf
 import androidx.navigation.Navigation
 import com.yingyang.mmse.R
 import com.yingyang.mmse.databinding.FragmentRecordActionBinding
@@ -22,7 +23,9 @@ class RecordActionFragment : BaseFragment<FragmentRecordActionBinding>() {
             }
 
             btnNext.setOnSingleClickListener {
-
+                val bundle = bundleOf("questionId" to 26)
+                val controller = Navigation.findNavController(it)
+                controller.navigate(R.id.action_recordActionFragment_to_multipleChoiceFragment, bundle)
             }
         }
     }

+ 32 - 2
mmse/src/main/res/layout/fragment_draw_designs.xml

@@ -1,6 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
-<layout xmlns:tools="http://schemas.android.com/tools"
-    xmlns:android="http://schemas.android.com/apk/res/android"
+<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">
 
     <androidx.constraintlayout.widget.ConstraintLayout
@@ -8,5 +9,34 @@
         android:layout_height="match_parent">
 
 
+        <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/continues"
+            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>

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

@@ -59,6 +59,14 @@
         <action
             android:id="@+id/action_judgmentFragment_to_soundRecordFragment"
             app:destination="@id/soundRecordFragment" />
+
+        <action
+            android:id="@+id/action_judgmentFragment_to_multipleChoiceFragment"
+            app:destination="@id/multipleChoiceFragment" />
+
+        <action
+            android:id="@+id/action_judgmentFragment_to_drawDesignsFragment"
+            app:destination="@id/drawDesignsFragment" />
     </fragment>
 
     <fragment
@@ -86,6 +94,15 @@
         <action
             android:id="@+id/action_multipleChoiceFragment_to_countFragment"
             app:destination="@id/countFragment" />
+
+        <action
+            android:id="@+id/action_multipleChoiceFragment_to_recordActionFragment"
+            app:destination="@id/recordActionFragment" />
+
+        <action
+            android:id="@+id/action_multipleChoiceFragment_to_judgmentFragment"
+            app:destination="@id/judgmentFragment" />
+
     </fragment>
 
     <fragment
@@ -146,5 +163,18 @@
         <action
             android:id="@+id/action_recordActionFragment_to_readFragment"
             app:destination="@id/readFragment" />
+
+        <action
+            android:id="@+id/action_recordActionFragment_to_multipleChoiceFragment"
+            app:destination="@id/multipleChoiceFragment" />
+    </fragment>
+
+    <fragment
+        android:id="@+id/drawDesignsFragment"
+        android:name="com.yingyangfly.mmse.fragment.DrawDesignsFragment"
+        android:label="drawDesignsFragment">
+        <action
+            android:id="@+id/action_drawDesignsFragment_to_judgmentFragment"
+            app:destination="@id/judgmentFragment" />
     </fragment>
 </navigation>