|
@@ -1,12 +1,14 @@
|
|
|
package com.yingyangfly.mmse.fragment
|
|
|
|
|
|
import android.os.Bundle
|
|
|
+import android.util.Log
|
|
|
import androidx.core.os.bundleOf
|
|
|
import androidx.navigation.Navigation
|
|
|
import androidx.recyclerview.widget.GridLayoutManager
|
|
|
import com.yingyang.mmse.R
|
|
|
import com.yingyang.mmse.databinding.FragmentCountBinding
|
|
|
import com.yingyangfly.baselib.base.BaseFragment
|
|
|
+import com.yingyangfly.baselib.db.QuestionsBean
|
|
|
import com.yingyangfly.baselib.ext.setOnSingleClickListener
|
|
|
import com.yingyangfly.baselib.ext.toast
|
|
|
import com.yingyangfly.mmse.adapter.NumberAdapter
|
|
@@ -25,6 +27,12 @@ class CountFragment : BaseFragment<FragmentCountBinding>() {
|
|
|
private val numberList = mutableListOf<String>()
|
|
|
private val adapter by lazy { NumberAdapter() }
|
|
|
|
|
|
+ private var firstquestion: QuestionsBean? = null
|
|
|
+ private var secondQuestion: QuestionsBean? = null
|
|
|
+ private var thirdQuestion: QuestionsBean? = null
|
|
|
+ private var fourthQuestion: QuestionsBean? = null
|
|
|
+ private var fifthQuestion: QuestionsBean? = null
|
|
|
+
|
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
|
questionId = arguments?.getInt("questionId") ?: 14
|
|
|
choiceItems = arguments?.getString("choiceItems") ?: ""
|
|
@@ -50,7 +58,7 @@ class CountFragment : BaseFragment<FragmentCountBinding>() {
|
|
|
binding {
|
|
|
btnPrevious.setOnSingleClickListener {
|
|
|
val bundle = Bundle()
|
|
|
- bundle.putInt("questionId", 19)
|
|
|
+ bundle.putInt("questionId", 11)
|
|
|
bundle.putString("choiceItems", choiceItems)
|
|
|
val controller = Navigation.findNavController(it)
|
|
|
controller.navigate(
|
|
@@ -60,14 +68,14 @@ class CountFragment : BaseFragment<FragmentCountBinding>() {
|
|
|
}
|
|
|
|
|
|
btnNext.setOnSingleClickListener {
|
|
|
- if (judge()) {
|
|
|
- val bundle = bundleOf("questionId" to 22)
|
|
|
- val controller = Navigation.findNavController(it)
|
|
|
- controller.navigate(
|
|
|
- R.id.action_countFragment_to_recognitionImageFragment,
|
|
|
- bundle
|
|
|
- )
|
|
|
- }
|
|
|
+// if (judge()) {
|
|
|
+ val bundle = bundleOf("questionId" to 22)
|
|
|
+ val controller = Navigation.findNavController(it)
|
|
|
+ controller.navigate(
|
|
|
+ R.id.action_countFragment_to_recognitionImageFragment,
|
|
|
+ bundle
|
|
|
+ )
|
|
|
+// }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -86,48 +94,53 @@ class CountFragment : BaseFragment<FragmentCountBinding>() {
|
|
|
*/
|
|
|
private fun loadData() {
|
|
|
if (dao != null) {
|
|
|
- val firstquestion = dao?.getQuestion(questionId)
|
|
|
+ firstquestion = dao?.getQuestion(questionId)
|
|
|
+ Log.e("wpp", "firstquestion-----------------" + firstquestion?.inputString)
|
|
|
if (firstquestion != null) {
|
|
|
- binding.tvResultOne.text = if (firstquestion.inputString.isNullOrEmpty()) {
|
|
|
+ binding.tvResultOne.text = if (firstquestion?.inputString.isNullOrEmpty()) {
|
|
|
""
|
|
|
} else {
|
|
|
- firstquestion.inputString
|
|
|
+ firstquestion?.inputString
|
|
|
}
|
|
|
}
|
|
|
val secondQuestionnId = questionId + 1
|
|
|
- val secondQuestion = dao?.getQuestion(secondQuestionnId)
|
|
|
+ secondQuestion = dao?.getQuestion(secondQuestionnId)
|
|
|
+ Log.e("wpp", "secondQuestion-----------------" + secondQuestion?.inputString)
|
|
|
if (secondQuestion != null) {
|
|
|
- binding.tvResultTwo.text = if (secondQuestion.inputString.isNullOrEmpty()) {
|
|
|
+ binding.tvResultTwo.text = if (secondQuestion?.inputString.isNullOrEmpty()) {
|
|
|
""
|
|
|
} else {
|
|
|
- secondQuestion.inputString
|
|
|
+ secondQuestion?.inputString
|
|
|
}
|
|
|
}
|
|
|
val thirdQuestionId = questionId + 2
|
|
|
- val thirdQuestion = dao?.getQuestion(thirdQuestionId)
|
|
|
+ thirdQuestion = dao?.getQuestion(thirdQuestionId)
|
|
|
+ Log.e("wpp", "thirdQuestion-----------------" + thirdQuestion?.inputString)
|
|
|
if (thirdQuestion != null) {
|
|
|
- binding.tvResultThree.text = if (thirdQuestion.inputString.isNullOrEmpty()) {
|
|
|
+ binding.tvResultThree.text = if (thirdQuestion?.inputString.isNullOrEmpty()) {
|
|
|
""
|
|
|
} else {
|
|
|
- thirdQuestion.inputString
|
|
|
+ thirdQuestion?.inputString
|
|
|
}
|
|
|
}
|
|
|
val fourthQuestionId = questionId + 3
|
|
|
- val fourthQuestion = dao?.getQuestion(fourthQuestionId)
|
|
|
+ fourthQuestion = dao?.getQuestion(fourthQuestionId)
|
|
|
+ Log.e("wpp", "fourthQuestion-----------------" + fourthQuestion?.inputString)
|
|
|
if (fourthQuestion != null) {
|
|
|
- binding.tvResultFour.text = if (fourthQuestion.inputString.isNullOrEmpty()) {
|
|
|
+ binding.tvResultFour.text = if (fourthQuestion?.inputString.isNullOrEmpty()) {
|
|
|
""
|
|
|
} else {
|
|
|
- fourthQuestion.inputString
|
|
|
+ fourthQuestion?.inputString
|
|
|
}
|
|
|
}
|
|
|
val fifthQuestionId = questionId + 4
|
|
|
- val fifthQuestion = dao?.getQuestion(fifthQuestionId)
|
|
|
+ fifthQuestion = dao?.getQuestion(fifthQuestionId)
|
|
|
+ Log.e("wpp", "fifthQuestion-----------------" + fifthQuestion?.inputString)
|
|
|
if (fifthQuestion != null) {
|
|
|
- binding.tvResultFive.text = if (fifthQuestion.inputString.isNullOrEmpty()) {
|
|
|
+ binding.tvResultFive.text = if (fifthQuestion?.inputString.isNullOrEmpty()) {
|
|
|
""
|
|
|
} else {
|
|
|
- fifthQuestion.inputString
|
|
|
+ fifthQuestion?.inputString
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -142,54 +155,45 @@ class CountFragment : BaseFragment<FragmentCountBinding>() {
|
|
|
"请输入第一道题目的答案".toast()
|
|
|
return false
|
|
|
} else {
|
|
|
- val firstquestion = dao?.getQuestion(questionId)
|
|
|
if (firstquestion != null) {
|
|
|
- firstquestion.inputString = binding.tvResultOne.text.toString()
|
|
|
- dao?.update(firstquestion)
|
|
|
+ firstquestion?.inputString = binding.tvResultOne.text.toString()
|
|
|
+ dao?.update(firstquestion!!)
|
|
|
}
|
|
|
}
|
|
|
if (binding.tvResultTwo.text.toString().isNullOrEmpty()) {
|
|
|
"请输入第二道题目的答案".toast()
|
|
|
return false
|
|
|
} else {
|
|
|
- val secondQuestionnId = questionId + 1
|
|
|
- val secondQuestion = dao?.getQuestion(secondQuestionnId)
|
|
|
if (secondQuestion != null) {
|
|
|
- secondQuestion.inputString = binding.tvResultTwo.text.toString()
|
|
|
- dao?.update(secondQuestion)
|
|
|
+ secondQuestion?.inputString = binding.tvResultTwo.text.toString()
|
|
|
+ dao?.update(secondQuestion!!)
|
|
|
}
|
|
|
}
|
|
|
if (binding.tvResultThree.text.toString().isNullOrEmpty()) {
|
|
|
"请输入第三道题目的答案".toast()
|
|
|
return false
|
|
|
} else {
|
|
|
- val thirdQuestionId = questionId + 2
|
|
|
- val thirdQuestion = dao?.getQuestion(thirdQuestionId)
|
|
|
if (thirdQuestion != null) {
|
|
|
- thirdQuestion.inputString = binding.tvResultThree.text.toString()
|
|
|
- dao?.update(thirdQuestion)
|
|
|
+ thirdQuestion?.inputString = binding.tvResultThree.text.toString()
|
|
|
+ dao?.update(thirdQuestion!!)
|
|
|
}
|
|
|
}
|
|
|
if (binding.tvResultFour.text.toString().isNullOrEmpty()) {
|
|
|
"请输入第四道题目的答案".toast()
|
|
|
return false
|
|
|
} else {
|
|
|
- val fourthQuestionId = questionId + 3
|
|
|
- val fourthQuestion = dao?.getQuestion(fourthQuestionId)
|
|
|
if (fourthQuestion != null) {
|
|
|
- fourthQuestion.inputString = binding.tvResultFour.text.toString()
|
|
|
- dao?.update(fourthQuestion)
|
|
|
+ fourthQuestion?.inputString = binding.tvResultFour.text.toString()
|
|
|
+ dao?.update(fourthQuestion!!)
|
|
|
}
|
|
|
}
|
|
|
if (binding.tvResultFive.text.toString().isNullOrEmpty()) {
|
|
|
"请输入第五道题目的答案".toast()
|
|
|
return false
|
|
|
} else {
|
|
|
- val fifthQuestionId = questionId + 4
|
|
|
- val fifthQuestion = dao?.getQuestion(fifthQuestionId)
|
|
|
if (fifthQuestion != null) {
|
|
|
- fifthQuestion.inputString = binding.tvResultFive.text.toString()
|
|
|
- dao?.update(fifthQuestion)
|
|
|
+ fifthQuestion?.inputString = binding.tvResultFive.text.toString()
|
|
|
+ dao?.update(fifthQuestion!!)
|
|
|
}
|
|
|
}
|
|
|
}
|