|
@@ -8,6 +8,7 @@ import com.yingyang.mmse.databinding.FragmentRecordActionBinding
|
|
import com.yingyangfly.baselib.base.BaseFragment
|
|
import com.yingyangfly.baselib.base.BaseFragment
|
|
import com.yingyangfly.baselib.db.QuestionsBean
|
|
import com.yingyangfly.baselib.db.QuestionsBean
|
|
import com.yingyangfly.baselib.ext.setOnSingleClickListener
|
|
import com.yingyangfly.baselib.ext.setOnSingleClickListener
|
|
|
|
+import com.yingyangfly.baselib.voice.PlayVoice
|
|
|
|
|
|
/**
|
|
/**
|
|
* 听录音做动作
|
|
* 听录音做动作
|
|
@@ -17,29 +18,43 @@ class RecordActionFragment : BaseFragment<FragmentRecordActionBinding>() {
|
|
/**
|
|
/**
|
|
* 问题id
|
|
* 问题id
|
|
*/
|
|
*/
|
|
- var questionId = 0
|
|
|
|
- var question: QuestionsBean? = null
|
|
|
|
|
|
+ private var questionId = 0
|
|
|
|
+ private var question: QuestionsBean? = null
|
|
|
|
+ private var firstWord = ""
|
|
|
|
+ private var secondWord = ""
|
|
|
|
+ private var thirdWord = ""
|
|
|
|
+
|
|
|
|
+ private var playVoice: PlayVoice? = null
|
|
|
|
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
- questionId = arguments?.getInt("questionId") ?: 25
|
|
|
|
|
|
+ questionId = arguments?.getInt("questionId") ?: 26
|
|
super.onCreate(savedInstanceState)
|
|
super.onCreate(savedInstanceState)
|
|
}
|
|
}
|
|
|
|
|
|
override fun initViews() {
|
|
override fun initViews() {
|
|
-
|
|
|
|
|
|
+ playVoice = PlayVoice()
|
|
|
|
+ playVoice?.setContext(mContext)
|
|
}
|
|
}
|
|
|
|
|
|
override fun initListener() {
|
|
override fun initListener() {
|
|
binding {
|
|
binding {
|
|
btnPrevious.setOnSingleClickListener {
|
|
btnPrevious.setOnSingleClickListener {
|
|
|
|
+ val bundle = bundleOf("questionId" to 25)
|
|
val controller = Navigation.findNavController(it)
|
|
val controller = Navigation.findNavController(it)
|
|
- controller.navigate(R.id.action_recordActionFragment_to_readFragment)
|
|
|
|
|
|
+ controller.navigate(R.id.action_recordActionFragment_to_readFragment, bundle)
|
|
}
|
|
}
|
|
|
|
|
|
btnNext.setOnSingleClickListener {
|
|
btnNext.setOnSingleClickListener {
|
|
val bundle = bundleOf("questionId" to 26)
|
|
val bundle = bundleOf("questionId" to 26)
|
|
val controller = Navigation.findNavController(it)
|
|
val controller = Navigation.findNavController(it)
|
|
- controller.navigate(R.id.action_recordActionFragment_to_multipleChoiceFragment, bundle)
|
|
|
|
|
|
+ controller.navigate(
|
|
|
|
+ R.id.action_recordActionFragment_to_multipleChoiceFragment,
|
|
|
|
+ bundle
|
|
|
|
+ )
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ soundImage.setOnSingleClickListener {
|
|
|
|
+ playVoice?.speakWithParagraph(firstWord, secondWord, thirdWord)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -47,4 +62,36 @@ class RecordActionFragment : BaseFragment<FragmentRecordActionBinding>() {
|
|
override fun initData() {
|
|
override fun initData() {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ override fun onResume() {
|
|
|
|
+ super.onResume()
|
|
|
|
+ loadData()
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 加载数据
|
|
|
|
+ */
|
|
|
|
+ private fun loadData() {
|
|
|
|
+ val firstquestion = dao?.getQuestion(questionId)
|
|
|
|
+ if (firstquestion != null) {
|
|
|
|
+ firstWord = firstquestion.reviewItem
|
|
|
|
+ }
|
|
|
|
+ val secondQuestionnId = questionId + 1
|
|
|
|
+ val secondQuestion = dao?.getQuestion(secondQuestionnId)
|
|
|
|
+ if (secondQuestion != null) {
|
|
|
|
+ secondWord = secondQuestion.reviewItem
|
|
|
|
+ }
|
|
|
|
+ val thirdQuestionId = questionId + 2
|
|
|
|
+ val thirdQuestion = dao?.getQuestion(thirdQuestionId)
|
|
|
|
+ if (thirdQuestion != null) {
|
|
|
|
+ thirdWord = thirdQuestion.reviewItem
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ override fun onPause() {
|
|
|
|
+ super.onPause()
|
|
|
|
+ if (playVoice != null) {
|
|
|
|
+ playVoice?.stop()
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|