| | |
| | | import com.dollearn.student.utils.Const |
| | | import com.dollearn.student.utils.extention.clickDelay |
| | | import kotlinx.android.synthetic.main.fragment_include.* |
| | | import org.jetbrains.anko.support.v4.dip |
| | | import org.jetbrains.anko.support.v4.startActivity |
| | | |
| | | class IncludeFragment : BaseFragment(), AudioUtils.OnAudioStatusUpdateListener { |
| | |
| | | super.handleMessage(msg) |
| | | when(msg.what){ |
| | | PLAY_VOICE->{ |
| | | playing = true |
| | | player.startPlayMusic(requireContext(),data!!.subjectList[group][voiceIndex].correct) |
| | | } |
| | | TO_NEXT->{ |
| | |
| | | } |
| | | } |
| | | PLAY_RIGHT->{ |
| | | playing = true |
| | | rightPlaying = true |
| | | player.startPlayMusic(requireContext(),rightVoice) |
| | | } |
| | | PLAY_ERROR->{ |
| | | playing = true |
| | | errorPlaying = true |
| | | player.startPlayMusic(requireContext(),errorVoice) |
| | | } |
| | |
| | | } |
| | | |
| | | cl_answer_1.clickDelay { |
| | | if (currentImage == 0) |
| | | if (currentImage == 0||!data!!.subjectList[group][currentImage].listend) |
| | | return@clickDelay |
| | | val subject = data!!.subjectList[group][currentImage] |
| | | if (!subject.listend||subject.completed){ |
| | | return@clickDelay |
| | | } |
| | | act.totalCount++ |
| | | data!!.subjectList[group][currentImage].listend = false |
| | | if (answerImg[0] == subject.img){ |
| | | nowVoiceView = voiceViews[currentImage] |
| | | act.rightCount++ |
| | |
| | | } |
| | | |
| | | cl_answer_2.clickDelay { |
| | | if (currentImage == 0) |
| | | if (currentImage == 0||!data!!.subjectList[group][currentImage].listend) |
| | | return@clickDelay |
| | | val subject = data!!.subjectList[group][currentImage] |
| | | if (!subject.listend||subject.completed){ |
| | |
| | | } |
| | | act.totalCount++ |
| | | |
| | | data!!.subjectList[group][currentImage].listend = false |
| | | if (answerImg[1] == subject.img){ |
| | | nowVoiceView = voiceViews[currentImage] |
| | | act.rightCount++ |
| | |
| | | } |
| | | |
| | | cl_answer_3.clickDelay { |
| | | if (currentImage == 0) |
| | | if (currentImage == 0||!data!!.subjectList[group][currentImage].listend) |
| | | return@clickDelay |
| | | val subject = data!!.subjectList[group][currentImage] |
| | | if (!subject.listend||subject.completed){ |
| | |
| | | } |
| | | act.totalCount++ |
| | | |
| | | data!!.subjectList[group][currentImage].listend = false |
| | | if (answerImg[2] == subject.img){ |
| | | nowVoiceView = voiceViews[currentImage] |
| | | act.rightCount++ |
| | |
| | | override fun onFinishPlay() { |
| | | playing = false |
| | | val subject = data!!.subjectList[group][voiceIndex] |
| | | subject.listend = true |
| | | when(voiceIndex){ |
| | | 0->{ |
| | | iv1_1.visible() |
| | |
| | | } |
| | | } |
| | | } |
| | | showVoiceEnable() |
| | | |
| | | if (errorPlaying) |
| | | errorPlaying = false |
| | | if (rightPlaying) { |
| | | else if (rightPlaying) { |
| | | rightPlaying = false |
| | | data!!.subjectList[group][currentImage].completed = true |
| | | nowVoiceView?.callOnClick() |
| | | } |
| | | }else |
| | | subject.listend = true |
| | | showVoiceEnable() |
| | | } |
| | | |
| | | override fun onPause() { |
| | | super.onPause() |
| | | player.stopPlayMusic() |
| | | } |
| | | |
| | | override fun onDestroy() { |
| | | super.onDestroy() |
| | | handler?.removeCallbacksAndMessages(null) |
| | | } |
| | | } |