Ver código fonte

1.添加获取moca试题库module

王鹏鹏 2 anos atrás
pai
commit
7a7b9bf0b5

+ 1 - 0
.idea/misc.xml

@@ -124,6 +124,7 @@
         <entry key="..\:/workspace/hcp-pad/moca/src/main/res/layout/activity_main.xml" value="0.23697916666666666" />
         <entry key="..\:/workspace/hcp-pad/moca/src/main/res/layout/activity_moca.xml" value="0.23697916666666666" />
         <entry key="..\:/workspace/hcp-pad/moca/src/main/res/layout/fragment_alternating_connection.xml" value="0.23697916666666666" />
+        <entry key="..\:/workspace/hcp-pad/moca/src/main/res/layout/fragment_computation.xml" value="0.536" />
         <entry key="..\:/workspace/hcp-pad/moca/src/main/res/layout/fragment_designs_choice.xml" value="0.23697916666666666" />
         <entry key="..\:/workspace/hcp-pad/moca/src/main/res/layout/fragment_draw_design.xml" value="0.22239583333333332" />
         <entry key="..\:/workspace/hcp-pad/moca/src/main/res/layout/fragment_identify_picture.xml" value="0.23697916666666666" />

+ 4 - 4
moca/src/main/java/com/yingyangfly/moca/adapter/NumberAdapter.kt

@@ -2,7 +2,7 @@ package com.yingyangfly.moca.adapter
 
 import android.text.TextUtils
 import com.yingyang.moca.R
-import com.yingyang.moca.databinding.ItemNumberBinding
+import com.yingyang.moca.databinding.ItemMocaNumberBinding
 import com.yingyangfly.baselib.adapter.BaseDataBindingAdapter
 import com.yingyangfly.baselib.ext.setOnSingleClickListener
 import com.yingyangfly.baselib.ext.setTextColorResource
@@ -10,12 +10,12 @@ import com.yingyangfly.baselib.ext.setTextColorResource
 /**
  * 年adapter
  */
-class NumberAdapter(override val layoutId: Int = R.layout.item_number) :
-    BaseDataBindingAdapter<String, ItemNumberBinding>() {
+class NumberAdapter(override val layoutId: Int = R.layout.item_moca_number) :
+    BaseDataBindingAdapter<String, ItemMocaNumberBinding>() {
 
     var onNumClickListener: ((bean: String, type: String) -> Unit)? = null
 
-    override fun onBindViewHolder(binding: ItemNumberBinding, item: String, position: Int) {
+    override fun onBindViewHolder(binding: ItemMocaNumberBinding, item: String, position: Int) {
         binding.data = item
         if (TextUtils.equals("删除", item)) {
             binding.tvNumber.setTextColorResource(R.color.color_FFCF0404)

+ 87 - 1
moca/src/main/java/com/yingyangfly/moca/numberrecords/NumberRecordsFragment.kt

@@ -2,18 +2,60 @@ package com.yingyangfly.moca.numberrecords
 
 import androidx.core.os.bundleOf
 import androidx.navigation.Navigation
+import androidx.recyclerview.widget.GridLayoutManager
 import com.yingyang.moca.R
 import com.yingyang.moca.databinding.FragmentNumberRecordsBinding
 import com.yingyangfly.baselib.base.BaseFragment
+import com.yingyangfly.baselib.db.QuestionsBean
 import com.yingyangfly.baselib.ext.setOnSingleClickListener
+import com.yingyangfly.moca.adapter.NumberAdapter
 
 /**
  * 记录患者错了几次
  */
 class NumberRecordsFragment : BaseFragment<FragmentNumberRecordsBinding>() {
 
+    private val numberList = mutableListOf<String>()
+    private val numberAdapter by lazy { NumberAdapter() }
+    private val stringBuffer = StringBuffer()
+    var question: QuestionsBean? = null
+
     override fun initViews() {
+        binding.rvNum.layoutManager = GridLayoutManager(mContext, 3)
+        binding.rvNum.adapter = numberAdapter
+        numberAdapter.onNumClickListener = { bean, type ->
+            when (type) {
+                "0" -> {
+                    binding.editTime.post {
+                        stringBuffer.append(bean)
+                        binding.editTime.setText(stringBuffer.toString())
+                        binding.editTime.setSelection(stringBuffer.toString().length)
+                    }
+                }
+                "1" -> {
+                    binding.editTime.post {
+                        if (stringBuffer.toString().isNullOrEmpty().not()) {
+                            val size = stringBuffer.toString().length - 1
+                            stringBuffer.deleteCharAt(size)
+                            binding.editTime.setText(stringBuffer.toString())
+                            binding.editTime.setSelection(stringBuffer.toString().length)
+                        }
+                    }
+                }
+                "2" -> {
+                    if (dao != null) {
+                        if (question != null) {
+                            question!!.inputString = binding.editTime.text.toString().trim()
+                            question!!.reviewId = question!!.id
+                            question!!.reviewAnswer = binding.editTime.text.toString().trim()
+                            question!!.correct = ""
+                            dao?.update(question!!)
+                        }
+                    }
+                }
+            }
 
+        }
     }
 
     override fun initListener() {
@@ -27,7 +69,12 @@ class NumberRecordsFragment : BaseFragment<FragmentNumberRecordsBinding>() {
                 )
             }
             btnNext.setOnSingleClickListener {
-
+                val controller = Navigation.findNavController(it)
+                val bundle = bundleOf("questionId" to 52)
+                controller.navigate(
+                    R.id.action_numberRecordsFragment_to_computationFragment,
+                    bundle
+                )
             }
         }
     }
@@ -35,4 +82,43 @@ class NumberRecordsFragment : BaseFragment<FragmentNumberRecordsBinding>() {
     override fun initData() {
 
     }
+
+    override fun onResume() {
+        super.onResume()
+        loadData()
+    }
+
+    /**
+     * 加载数据
+     */
+    private fun loadData() {
+        numberList.clear()
+        for (i in 1..9) {
+            numberList.add(i.toString())
+        }
+        numberList.add("删除")
+        numberList.add("0")
+        numberList.add("确定")
+        numberAdapter.setData(numberList)
+        binding.editTime.requestFocus()
+        binding.editTime.isFocusable = true
+        binding.editTime.isFocusableInTouchMode = true
+        binding.editTime.postDelayed({ closeKeyBord(binding.editTime, mContext) }, 300)
+        if (dao != null) {
+            question = dao?.getQuestion(1)
+            if (question != null) {
+                binding.data = question
+                if (question!!.inputString.isNullOrEmpty().not()) {
+                    binding.editTime.post {
+                        if (stringBuffer.toString().isNullOrEmpty().not()) {
+                            stringBuffer.delete(0, question!!.inputString.length - 1)
+                        }
+                        stringBuffer.append(question!!.inputString)
+                        binding.editTime.setText(question!!.inputString)
+                        binding.editTime.setSelection(question!!.inputString.length)
+                    }
+                }
+            }
+        }
+    }
 }

+ 39 - 0
moca/src/main/java/com/yingyangfly/moca/omputation/ComputationFragment.kt

@@ -0,0 +1,39 @@
+package com.yingyangfly.moca.omputation
+
+import androidx.core.os.bundleOf
+import androidx.navigation.Navigation
+import com.yingyang.moca.R
+import com.yingyang.moca.databinding.FragmentComputationBinding
+import com.yingyangfly.baselib.base.BaseFragment
+import com.yingyangfly.baselib.ext.setOnSingleClickListener
+
+/**
+ * 计算题
+ */
+class ComputationFragment : BaseFragment<FragmentComputationBinding>() {
+
+    override fun initViews() {
+
+    }
+
+    override fun initListener() {
+        binding {
+            btnPrevious.setOnSingleClickListener {
+                val controller = Navigation.findNavController(it)
+                val bundle = bundleOf("questionId" to 51)
+                controller.navigate(
+                    R.id.action_computationFragment_to_numberRecordsFragment,
+                    bundle
+                )
+            }
+
+            btnNext.setOnSingleClickListener {
+
+            }
+        }
+    }
+
+    override fun initData() {
+
+    }
+}

+ 239 - 0
moca/src/main/res/layout/fragment_computation.xml

@@ -0,0 +1,239 @@
+<?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>
+
+        <import type="android.text.InputType" />
+    </data>
+
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:orientation="vertical">
+
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="0dp"
+            android:layout_weight="1"
+            android:orientation="horizontal">
+
+            <androidx.constraintlayout.widget.ConstraintLayout
+                android:layout_width="0dp"
+                android:layout_height="match_parent"
+                android:layout_weight="1">
+
+                <androidx.appcompat.widget.AppCompatTextView
+                    android:id="@+id/tvHundredMinusSeven"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_marginStart="@dimen/divider_205px"
+                    android:layout_marginTop="@dimen/divider_118px"
+                    android:text="@string/please_calculate_one_hundred_minus_seven"
+                    android:textColor="@color/color_FF333333"
+                    android:textSize="@dimen/divider_34px"
+                    android:textStyle="bold"
+                    app:layout_constraintStart_toStartOf="parent"
+                    app:layout_constraintTop_toTopOf="parent" />
+
+                <EditText
+                    android:id="@+id/editResultOne"
+                    android:layout_width="@dimen/divider_80px"
+                    android:layout_height="@dimen/divider_53px"
+                    android:layout_marginStart="@dimen/divider_20px"
+                    android:layout_marginTop="@dimen/divider_118px"
+                    android:background="@drawable/bg_calculation_results"
+                    android:gravity="center"
+                    android:imeOptions="actionDone"
+                    android:inputType="@{InputType.TYPE_CLASS_NUMBER}"
+                    android:textColor="@color/color_FF333333"
+                    android:textSize="@dimen/divider_34px"
+                    android:textStyle="bold"
+                    app:layout_constraintStart_toEndOf="@+id/tvHundredMinusSeven"
+                    app:layout_constraintTop_toTopOf="parent" />
+
+                <androidx.appcompat.widget.AppCompatTextView
+                    android:id="@+id/tvHundredMinusSevenTwo"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_marginStart="@dimen/divider_205px"
+                    android:layout_marginTop="@dimen/divider_25px"
+                    android:text="@string/subtract_seven_more"
+                    android:textColor="@color/color_FF333333"
+                    android:textSize="@dimen/divider_34px"
+                    android:textStyle="bold"
+                    app:layout_constraintStart_toStartOf="parent"
+                    app:layout_constraintTop_toBottomOf="@+id/tvHundredMinusSeven" />
+
+                <EditText
+                    android:id="@+id/editResultTwo"
+                    android:layout_width="@dimen/divider_80px"
+                    android:layout_height="@dimen/divider_53px"
+                    android:layout_marginStart="@dimen/divider_20px"
+                    android:layout_marginTop="@dimen/divider_15px"
+                    android:background="@drawable/bg_calculation_results"
+                    android:gravity="center"
+                    android:imeOptions="actionDone"
+                    android:inputType="@{InputType.TYPE_CLASS_NUMBER}"
+                    android:textColor="@color/color_FF333333"
+                    android:textSize="@dimen/divider_34px"
+                    android:textStyle="bold"
+                    app:layout_constraintStart_toEndOf="@+id/tvHundredMinusSevenTwo"
+                    app:layout_constraintTop_toBottomOf="@+id/editResultOne" />
+
+                <androidx.appcompat.widget.AppCompatTextView
+                    android:id="@+id/tvHundredMinusSeventhree"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_marginStart="@dimen/divider_205px"
+                    android:layout_marginTop="@dimen/divider_22px"
+                    android:text="@string/subtract_seven_more"
+                    android:textColor="@color/color_FF333333"
+                    android:textSize="@dimen/divider_34px"
+                    android:textStyle="bold"
+                    app:layout_constraintStart_toStartOf="parent"
+                    app:layout_constraintTop_toBottomOf="@+id/tvHundredMinusSevenTwo" />
+
+                <EditText
+                    android:id="@+id/editResultThree"
+                    android:layout_width="@dimen/divider_80px"
+                    android:layout_height="@dimen/divider_53px"
+                    android:layout_marginStart="@dimen/divider_20px"
+                    android:layout_marginTop="@dimen/divider_15px"
+                    android:background="@drawable/bg_calculation_results"
+                    android:gravity="center"
+                    android:imeOptions="actionDone"
+                    android:inputType="@{InputType.TYPE_CLASS_NUMBER}"
+                    android:textColor="@color/color_FF333333"
+                    android:textSize="@dimen/divider_34px"
+                    android:textStyle="bold"
+                    app:layout_constraintStart_toEndOf="@+id/tvHundredMinusSeventhree"
+                    app:layout_constraintTop_toBottomOf="@+id/editResultTwo" />
+
+
+                <androidx.appcompat.widget.AppCompatTextView
+                    android:id="@+id/tvHundredMinusSevenFour"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_marginStart="@dimen/divider_205px"
+                    android:layout_marginTop="@dimen/divider_22px"
+                    android:text="@string/subtract_seven_more"
+                    android:textColor="@color/color_FF333333"
+                    android:textSize="@dimen/divider_34px"
+                    android:textStyle="bold"
+                    app:layout_constraintStart_toStartOf="parent"
+                    app:layout_constraintTop_toBottomOf="@+id/tvHundredMinusSeventhree" />
+
+                <EditText
+                    android:id="@+id/editResultFour"
+                    android:layout_width="@dimen/divider_80px"
+                    android:layout_height="@dimen/divider_53px"
+                    android:layout_marginStart="@dimen/divider_20px"
+                    android:layout_marginTop="@dimen/divider_15px"
+                    android:background="@drawable/bg_calculation_results"
+                    android:gravity="center"
+                    android:imeOptions="actionDone"
+                    android:inputType="@{InputType.TYPE_CLASS_NUMBER}"
+                    android:textColor="@color/color_FF333333"
+                    android:textSize="@dimen/divider_34px"
+                    android:textStyle="bold"
+                    app:layout_constraintStart_toEndOf="@+id/tvHundredMinusSevenFour"
+                    app:layout_constraintTop_toBottomOf="@+id/editResultThree" />
+
+                <androidx.appcompat.widget.AppCompatTextView
+                    android:id="@+id/tvHundredMinusSevenFive"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_marginStart="@dimen/divider_205px"
+                    android:layout_marginTop="@dimen/divider_23px"
+                    android:text="@string/subtract_seven_more"
+                    android:textColor="@color/color_FF333333"
+                    android:textSize="@dimen/divider_34px"
+                    android:textStyle="bold"
+                    app:layout_constraintStart_toStartOf="parent"
+                    app:layout_constraintTop_toBottomOf="@+id/tvHundredMinusSevenFour" />
+
+                <EditText
+                    android:id="@+id/editResultFive"
+                    android:layout_width="@dimen/divider_80px"
+                    android:layout_height="@dimen/divider_53px"
+                    android:layout_marginStart="@dimen/divider_20px"
+                    android:layout_marginTop="@dimen/divider_15px"
+                    android:background="@drawable/bg_calculation_results"
+                    android:gravity="center"
+                    android:imeOptions="actionDone"
+                    android:inputType="@{InputType.TYPE_CLASS_NUMBER}"
+                    android:textColor="@color/color_FF333333"
+                    android:textSize="@dimen/divider_34px"
+                    android:textStyle="bold"
+                    app:layout_constraintStart_toEndOf="@+id/tvHundredMinusSevenFive"
+                    app:layout_constraintTop_toBottomOf="@+id/editResultFour" />
+
+            </androidx.constraintlayout.widget.ConstraintLayout>
+
+            <LinearLayout
+                android:layout_width="0dp"
+                android:layout_height="match_parent"
+                android:layout_weight="1">
+
+                <com.google.android.material.card.MaterialCardView
+                    android:layout_width="@dimen/divider_398px"
+                    android:layout_height="wrap_content"
+                    android:layout_marginTop="@dimen/divider_119px"
+                    android:theme="@style/Theme.MaterialComponents.NoActionBar"
+                    app:cardBackgroundColor="@android:color/white"
+                    app:cardCornerRadius="@dimen/divider_20px"
+                    app:strokeColor="@color/color_FF979797"
+                    app:strokeWidth="@dimen/divider_1px">
+
+                    <androidx.recyclerview.widget.RecyclerView
+                        android:id="@+id/rvInput"
+                        android:layout_width="match_parent"
+                        android:layout_height="wrap_content"
+                        android:layout_marginStart="@dimen/divider_28px"
+                        android:layout_marginTop="@dimen/divider_10px"
+                        android:layout_marginBottom="@dimen/divider_30px" />
+
+                </com.google.android.material.card.MaterialCardView>
+            </LinearLayout>
+        </LinearLayout>
+
+        <androidx.constraintlayout.widget.ConstraintLayout
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_marginStart="@dimen/divider_307px"
+            android:layout_marginEnd="@dimen/divider_305px"
+            android:layout_marginBottom="@dimen/divider_60px">
+
+            <androidx.appcompat.widget.AppCompatButton
+                android:id="@+id/btnPrevious"
+                android:layout_width="@dimen/divider_240px"
+                android:layout_height="@dimen/divider_68px"
+                android:background="@drawable/bg_previous_question"
+                android:gravity="center"
+                android:text="@string/previous_page"
+                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: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>
+
+    </LinearLayout>
+
+</layout>

+ 7 - 25
moca/src/main/res/layout/fragment_number_records.xml

@@ -37,6 +37,7 @@
                 android:textStyle="bold" />
 
             <androidx.appcompat.widget.AppCompatEditText
+                android:id="@+id/editTime"
                 android:layout_width="@dimen/divider_80px"
                 android:layout_height="wrap_content"
                 android:layout_marginStart="@dimen/divider_6px"
@@ -71,33 +72,14 @@
             app:strokeColor="@color/color_FF979797"
             app:strokeWidth="@dimen/divider_1px">
 
-            <LinearLayout
+            <androidx.recyclerview.widget.RecyclerView
+                android:id="@+id/rvNum"
                 android:layout_width="match_parent"
                 android:layout_height="match_parent"
-                android:orientation="vertical">
-
-                <EditText
-                    android:id="@+id/editYear"
-                    android:layout_width="match_parent"
-                    android:layout_height="@dimen/divider_62px"
-                    android:background="@color/color_FF4A76FF"
-                    android:gravity="center_vertical"
-                    android:inputType="@{InputType.TYPE_CLASS_NUMBER}"
-                    android:paddingStart="@dimen/divider_43px"
-                    android:paddingEnd="@dimen/divider_43px"
-                    android:textColor="@android:color/white"
-                    android:textSize="@dimen/divider_34px"
-                    android:textStyle="bold" />
-
-                <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>
+                android:layout_marginStart="@dimen/divider_13px"
+                android:layout_marginTop="@dimen/divider_6px"
+                android:layout_marginEnd="@dimen/divider_13px" />
+
         </com.google.android.material.card.MaterialCardView>
 
         <androidx.appcompat.widget.AppCompatButton

+ 0 - 0
moca/src/main/res/layout/item_number.xml → moca/src/main/res/layout/item_moca_number.xml


+ 16 - 0
moca/src/main/res/navigation/nav_moca.xml

@@ -178,6 +178,22 @@
             android:id="@+id/action_numberRecordsFragment_to_memorizeNumbersFragment"
             app:destination="@id/memorizeNumbersFragment" />
 
+        <action
+            android:id="@+id/action_numberRecordsFragment_to_computationFragment"
+            app:destination="@id/computationFragment" />
+
+    </fragment>
+
+    <fragment
+        android:id="@+id/computationFragment"
+        android:name="com.yingyangfly.moca.omputation.ComputationFragment"
+        android:label="computationFragment">
+
+        <action
+            android:id="@+id/action_computationFragment_to_numberRecordsFragment"
+            app:destination="@id/numberRecordsFragment" />
+
     </fragment>
 
+
 </navigation>