|
@@ -7,6 +7,7 @@ import com.yingyang.mmse.R
|
|
|
import com.yingyang.mmse.databinding.FragmentMultipleChoiceBinding
|
|
|
import com.yingyangfly.baselib.base.BaseFragment
|
|
|
import com.yingyangfly.baselib.ext.setOnSingleClickListener
|
|
|
+import com.yingyangfly.baselib.ext.toast
|
|
|
import com.yingyangfly.mmse.adapter.ChoiceAdapter
|
|
|
|
|
|
/**
|
|
@@ -31,6 +32,15 @@ class MultipleChoiceFragment : BaseFragment<FragmentMultipleChoiceBinding>() {
|
|
|
override fun initViews() {
|
|
|
binding {
|
|
|
rvChoice.adapter = adapter
|
|
|
+ adapter.onNumClickListener = { bean, type ->
|
|
|
+ if (dao != null) {
|
|
|
+ val questionsBean = dao?.getQuestionByReviewItem(bean)
|
|
|
+ if (questionsBean != null) {
|
|
|
+ questionsBean.inputString = type
|
|
|
+ dao?.update(questionsBean)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -45,13 +55,15 @@ class MultipleChoiceFragment : BaseFragment<FragmentMultipleChoiceBinding>() {
|
|
|
)
|
|
|
}
|
|
|
btnNext.setOnSingleClickListener {
|
|
|
- val bundle = Bundle()
|
|
|
- bundle.putInt("questionId", 14)
|
|
|
- val controller = Navigation.findNavController(it)
|
|
|
- controller.navigate(
|
|
|
- R.id.action_multipleChoiceFragment_to_countFragment,
|
|
|
- bundle
|
|
|
- )
|
|
|
+ if (judge()) {
|
|
|
+ val bundle = Bundle()
|
|
|
+ bundle.putInt("questionId", 14)
|
|
|
+ val controller = Navigation.findNavController(it)
|
|
|
+ controller.navigate(
|
|
|
+ R.id.action_multipleChoiceFragment_to_countFragment,
|
|
|
+ bundle
|
|
|
+ )
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -86,4 +98,34 @@ class MultipleChoiceFragment : BaseFragment<FragmentMultipleChoiceBinding>() {
|
|
|
}
|
|
|
adapter.setData(choiceItemList)
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 非空判断
|
|
|
+ */
|
|
|
+ private fun judge(): Boolean {
|
|
|
+ if (dao != null) {
|
|
|
+ val firstquestion = dao?.getQuestion(questionId)
|
|
|
+ if (firstquestion != null) {
|
|
|
+ if (firstquestion.reviewItem.isNullOrEmpty()) {
|
|
|
+ "请判断是否正确".toast()
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ }
|
|
|
+ val secondQuestion = dao?.getQuestion(12)
|
|
|
+ if (secondQuestion != null) {
|
|
|
+ if (secondQuestion.reviewItem.isNullOrEmpty()) {
|
|
|
+ "请判断是否正确".toast()
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ }
|
|
|
+ val thirdQuestion = dao?.getQuestion(13)
|
|
|
+ if (thirdQuestion != null) {
|
|
|
+ if (thirdQuestion.reviewItem.isNullOrEmpty()) {
|
|
|
+ "请判断是否正确".toast()
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true
|
|
|
+ }
|
|
|
}
|