Parcourir la source

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

王鹏鹏 il y a 2 ans
Parent
commit
54bed374f7

+ 1 - 1
.idea/misc.xml

@@ -103,7 +103,7 @@
         <entry key="..\:/workspace/hcp-pad/mmse/src/main/res/layout/fragment_multiple_choice.xml" value="0.2845528455284553" />
         <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_recognition_image.xml" value="0.22239583333333332" />
-        <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_selected_item.xml" value="0.264" />
         <entry key="..\:/workspace/hcp-pad/mmse/src/main/res/layout/fragment_single_judgment.xml" value="0.22239583333333332" />
         <entry key="..\:/workspace/hcp-pad/mmse/src/main/res/layout/fragment_sound_record.xml" value="0.4421768707482993" />
         <entry key="..\:/workspace/hcp-pad/mmse/src/main/res/layout/fragment_year.xml" value="0.23697916666666666" />

+ 10 - 1
mmse/src/main/java/com/yingyangfly/mmse/fragment/CountFragment.kt

@@ -1,5 +1,6 @@
 package com.yingyangfly.mmse.fragment
 
+import android.os.Bundle
 import androidx.core.os.bundleOf
 import androidx.navigation.Navigation
 import androidx.recyclerview.widget.GridLayoutManager
@@ -14,9 +15,15 @@ import com.yingyangfly.mmse.adapter.NumberAdapter
  */
 class CountFragment : BaseFragment<FragmentCountBinding>() {
 
+    var choiceItems = ""
     private val numberList = mutableListOf<String>()
     private val adapter by lazy { NumberAdapter() }
 
+    override fun onCreate(savedInstanceState: Bundle?) {
+        choiceItems = arguments?.getString("choiceItems") ?: ""
+        super.onCreate(savedInstanceState)
+    }
+
     override fun initViews() {
         binding {
             numberList.clear()
@@ -35,7 +42,9 @@ class CountFragment : BaseFragment<FragmentCountBinding>() {
     override fun initListener() {
         binding {
             btnPrevious.setOnSingleClickListener {
-                val bundle = bundleOf("questionId" to 19)
+                val bundle = Bundle()
+                bundle.putInt("questionId", 19)
+                bundle.putString("choiceItems", choiceItems)
                 val controller = Navigation.findNavController(it)
                 controller.navigate(
                     R.id.action_countFragment_to_multipleChoiceFragment,

+ 15 - 11
mmse/src/main/java/com/yingyangfly/mmse/fragment/MultipleChoiceFragment.kt

@@ -19,14 +19,11 @@ class MultipleChoiceFragment : BaseFragment<FragmentMultipleChoiceBinding>() {
      */
     var questionId = 0
 
-    var choiceItems = ""
-
     private val choiceItemList = mutableListOf<String>()
     private val adapter by lazy { ChoiceAdapter() }
 
     override fun onCreate(savedInstanceState: Bundle?) {
         questionId = arguments?.getInt("questionId") ?: 11
-        choiceItems = arguments?.getString("choiceItems") ?: ""
         super.onCreate(savedInstanceState)
     }
 
@@ -48,7 +45,8 @@ class MultipleChoiceFragment : BaseFragment<FragmentMultipleChoiceBinding>() {
                 )
             }
             btnNext.setOnSingleClickListener {
-                val bundle = bundleOf("questionId" to 14)
+                val bundle = Bundle()
+                bundle.putInt("questionId", 14)
                 val controller = Navigation.findNavController(it)
                 controller.navigate(
                     R.id.action_multipleChoiceFragment_to_countFragment,
@@ -72,14 +70,20 @@ class MultipleChoiceFragment : BaseFragment<FragmentMultipleChoiceBinding>() {
      */
     private fun loadData() {
         choiceItemList.clear()
-        if (choiceItems.isNullOrEmpty().not()) {
-            val choiceList = choiceItems.split(",")
-            if (choiceList.isNullOrEmpty().not()) {
-                choiceList.forEach {
-                    choiceItemList.add(it)
-                }
+        if (dao != null) {
+            val firstquestion = dao?.getQuestion(11)
+            if (firstquestion != null) {
+                choiceItemList.add(firstquestion.reviewItem)
+            }
+            val secondQuestion = dao?.getQuestion(12)
+            if (secondQuestion != null) {
+                choiceItemList.add(secondQuestion.reviewItem)
+            }
+            val thirdQuestion = dao?.getQuestion(13)
+            if (thirdQuestion != null) {
+                choiceItemList.add(thirdQuestion.reviewItem)
             }
-            adapter.setData(choiceItemList)
         }
+        adapter.setData(choiceItemList)
     }
 }

+ 0 - 6
mmse/src/main/java/com/yingyangfly/mmse/fragment/SoundRecordFragment.kt

@@ -7,7 +7,6 @@ import com.yingyang.mmse.R
 import com.yingyang.mmse.databinding.FragmentSoundRecordBinding
 import com.yingyangfly.baselib.base.BaseFragment
 import com.yingyangfly.baselib.ext.setOnSingleClickListener
-import com.yingyangfly.baselib.ext.toast
 import com.yingyangfly.baselib.voice.PlayVoice
 
 /**
@@ -49,13 +48,8 @@ class SoundRecordFragment : BaseFragment<FragmentSoundRecordBinding>() {
 
             }
             btnNext.setOnSingleClickListener {
-                val stringBuffer = StringBuffer()
-                stringBuffer.append(firstWord).append(",")
-                    .append(secondWord).append(",")
-                    .append(thirdWord)
                 val bundle = Bundle()
                 bundle.putInt("questionId", questionId)
-                bundle.putString("choiceItems", stringBuffer.toString())
                 val controller = Navigation.findNavController(it)
                 controller.navigate(
                     R.id.action_soundRecordFragment_to_multipleChoiceFragment,