|
|
@@ -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)
|
|
|
}
|
|
|
}
|