|
@@ -6,6 +6,7 @@ import androidx.navigation.Navigation
|
|
|
import com.yingyang.mmse.R
|
|
|
import com.yingyang.mmse.databinding.FragmentMultipleChoiceBinding
|
|
|
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.ChoiceAdapter
|
|
@@ -20,7 +21,7 @@ class MultipleChoiceFragment : BaseFragment<FragmentMultipleChoiceBinding>() {
|
|
|
*/
|
|
|
var questionId = 0
|
|
|
|
|
|
- private val choiceItemList = mutableListOf<String>()
|
|
|
+ private val choiceItemList = mutableListOf<QuestionsBean>()
|
|
|
private val adapter by lazy { ChoiceAdapter() }
|
|
|
|
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
@@ -28,17 +29,12 @@ class MultipleChoiceFragment : BaseFragment<FragmentMultipleChoiceBinding>() {
|
|
|
super.onCreate(savedInstanceState)
|
|
|
}
|
|
|
|
|
|
-
|
|
|
override fun initViews() {
|
|
|
binding {
|
|
|
rvChoice.adapter = adapter
|
|
|
- adapter.onNumClickListener = { bean, type ->
|
|
|
+ adapter.onNumClickListener = { bean ->
|
|
|
if (dao != null) {
|
|
|
- val questionsBean = dao?.getQuestionByReviewItem(bean)
|
|
|
- if (questionsBean != null) {
|
|
|
- questionsBean.inputString = type
|
|
|
- dao?.update(questionsBean)
|
|
|
- }
|
|
|
+ dao?.update(bean)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -85,15 +81,15 @@ class MultipleChoiceFragment : BaseFragment<FragmentMultipleChoiceBinding>() {
|
|
|
if (dao != null) {
|
|
|
val firstquestion = dao?.getQuestion(11)
|
|
|
if (firstquestion != null) {
|
|
|
- choiceItemList.add(firstquestion.reviewItem)
|
|
|
+ choiceItemList.add(firstquestion)
|
|
|
}
|
|
|
val secondQuestion = dao?.getQuestion(12)
|
|
|
if (secondQuestion != null) {
|
|
|
- choiceItemList.add(secondQuestion.reviewItem)
|
|
|
+ choiceItemList.add(secondQuestion)
|
|
|
}
|
|
|
val thirdQuestion = dao?.getQuestion(13)
|
|
|
if (thirdQuestion != null) {
|
|
|
- choiceItemList.add(thirdQuestion.reviewItem)
|
|
|
+ choiceItemList.add(thirdQuestion)
|
|
|
}
|
|
|
}
|
|
|
adapter.setData(choiceItemList)
|