| | |
| | | import org.jetbrains.anko.imageResource |
| | | |
| | | |
| | | //todo 1.首次播放播放中图标不显示 2.选择正确后不能再选择 3.选择正确后处理语音条位置 |
| | | //todo 2.选择正确后不能再选择 3.选择正确后处理语音条位置 |
| | | class MatchFragment : BaseFragment(), AudioUtils.OnAudioStatusUpdateListener { |
| | | override fun contentViewId() = R.layout.fragment_match |
| | | |
| | |
| | | } |
| | | TO_NEXT->{ |
| | | if (isAdded&&!playing){ |
| | | (requireActivity() as IncludeActivity).next() |
| | | (requireActivity() as MatchActivity).next() |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | private fun initClick() { |
| | | cover_3.setOnClickListener { } |
| | | cover_2.setOnClickListener { } |
| | | cover_1.setOnClickListener { } |
| | | cover_4.setOnClickListener { } |
| | | voiceViews.forEachIndexed { index, constraintLayout -> |
| | | constraintLayout.clickDelay { |
| | | if (!playing){ |
| | |
| | | } |
| | | |
| | | cl_1.clickDelay { |
| | | val voiceIndex = voiceIndex |
| | | if (playing||voiceIndex == -1) //未播放或者正在播放,不可点击 |
| | | return@clickDelay |
| | | if (data!!.subjectList[group][0].completed) //已作答不可点击 |
| | |
| | | end = R.id.end_4_1 |
| | | } |
| | | } |
| | | voiceViews[voiceIndex].callOnClick() |
| | | motion.setTransitionListener(object :MotionLayout.TransitionListener{ |
| | | override fun onTransitionStarted(p0: MotionLayout?, p1: Int, p2: Int) { |
| | | |
| | | } |
| | | |
| | | override fun onTransitionChange( |
| | | p0: MotionLayout?, |
| | | p1: Int, |
| | | p2: Int, |
| | | p3: Float |
| | | ) { |
| | | } |
| | | |
| | | override fun onTransitionCompleted(p0: MotionLayout?, p1: Int) { |
| | | cl_voice_end_1.visible() |
| | | when(voiceIndex){ |
| | | 0->cover_1.visible() |
| | | 1->cover_2.visible() |
| | | 2->cover_3.visible() |
| | | 3->cover_4.visible() |
| | | } |
| | | } |
| | | |
| | | override fun onTransitionTrigger( |
| | | p0: MotionLayout?, |
| | | p1: Int, |
| | | p2: Boolean, |
| | | p3: Float |
| | | ) { |
| | | } |
| | | }) |
| | | motion.setTransition(start,end) |
| | | motion.transitionToEnd() |
| | | }else{ |
| | |
| | | } |
| | | |
| | | cl_2.clickDelay { |
| | | val voiceIndex = voiceIndex |
| | | |
| | | if (playing||voiceIndex == -1) //未播放或者正在播放,不可点击 |
| | | return@clickDelay |
| | | if (data!!.subjectList[group][1].completed) //已作答不可点击 |
| | |
| | | end = R.id.end_4_2 |
| | | } |
| | | } |
| | | voiceViews[voiceIndex].callOnClick() |
| | | |
| | | motion.setTransitionListener(object :MotionLayout.TransitionListener{ |
| | | override fun onTransitionStarted(p0: MotionLayout?, p1: Int, p2: Int) { |
| | | |
| | | } |
| | | |
| | | override fun onTransitionChange( |
| | | p0: MotionLayout?, |
| | | p1: Int, |
| | | p2: Int, |
| | | p3: Float |
| | | ) { |
| | | } |
| | | |
| | | override fun onTransitionCompleted(p0: MotionLayout?, p1: Int) { |
| | | cl_voice_end_2.visible() |
| | | when(voiceIndex){ |
| | | 0->cover_1.visible() |
| | | 1->cover_2.visible() |
| | | 2->cover_3.visible() |
| | | 3->cover_4.visible() |
| | | } |
| | | } |
| | | |
| | | override fun onTransitionTrigger( |
| | | p0: MotionLayout?, |
| | | p1: Int, |
| | | p2: Boolean, |
| | | p3: Float |
| | | ) { |
| | | } |
| | | }) |
| | | motion.setTransition(start,end) |
| | | motion.transitionToEnd() |
| | | }else{ |
| | |
| | | } |
| | | |
| | | cl_3.clickDelay { |
| | | val voiceIndex = voiceIndex |
| | | |
| | | if (playing||voiceIndex == -1) //未播放或者正在播放,不可点击 |
| | | return@clickDelay |
| | | if (data!!.subjectList[group][2].completed) //已作答不可点击 |
| | |
| | | end = R.id.end_4_3 |
| | | } |
| | | } |
| | | voiceViews[voiceIndex].callOnClick() |
| | | |
| | | motion.setTransitionListener(object :MotionLayout.TransitionListener{ |
| | | override fun onTransitionStarted(p0: MotionLayout?, p1: Int, p2: Int) { |
| | | |
| | | } |
| | | |
| | | override fun onTransitionChange( |
| | | p0: MotionLayout?, |
| | | p1: Int, |
| | | p2: Int, |
| | | p3: Float |
| | | ) { |
| | | } |
| | | |
| | | override fun onTransitionCompleted(p0: MotionLayout?, p1: Int) { |
| | | cl_voice_end_3.visible() |
| | | when(voiceIndex){ |
| | | 0->cover_1.visible() |
| | | 1->cover_2.visible() |
| | | 2->cover_3.visible() |
| | | 3->cover_4.visible() |
| | | } |
| | | } |
| | | |
| | | override fun onTransitionTrigger( |
| | | p0: MotionLayout?, |
| | | p1: Int, |
| | | p2: Boolean, |
| | | p3: Float |
| | | ) { |
| | | } |
| | | }) |
| | | motion.setTransition(start,end) |
| | | motion.transitionToEnd() |
| | | }else{ |
| | |
| | | } |
| | | |
| | | cl_4.clickDelay { |
| | | val voiceIndex = voiceIndex |
| | | if (playing||voiceIndex == -1) //未播放或者正在播放,不可点击 |
| | | return@clickDelay |
| | | if (data!!.subjectList[group][3].completed) //已作答不可点击 |
| | |
| | | end = R.id.end_4_4 |
| | | } |
| | | } |
| | | voiceViews[voiceIndex].callOnClick() |
| | | |
| | | motion.setTransitionListener(object :MotionLayout.TransitionListener{ |
| | | override fun onTransitionStarted(p0: MotionLayout?, p1: Int, p2: Int) { |
| | | |
| | | } |
| | | |
| | | override fun onTransitionChange( |
| | | p0: MotionLayout?, |
| | | p1: Int, |
| | | p2: Int, |
| | | p3: Float |
| | | ) { |
| | | } |
| | | |
| | | override fun onTransitionCompleted(p0: MotionLayout?, p1: Int) { |
| | | cl_voice_end_4.visible() |
| | | when(voiceIndex){ |
| | | 0->cover_1.visible() |
| | | 1->cover_2.visible() |
| | | 2->cover_3.visible() |
| | | 3->cover_4.visible() |
| | | } |
| | | } |
| | | |
| | | override fun onTransitionTrigger( |
| | | p0: MotionLayout?, |
| | | p1: Int, |
| | | p2: Boolean, |
| | | p3: Float |
| | | ) { |
| | | } |
| | | }) |
| | | motion.setTransition(start,end) |
| | | motion.transitionToEnd() |
| | | }else{ |
| | | result_4.imageResource = R.mipmap.zhifushibai |
| | | } |
| | | showResultAnim(cl_4) |
| | | } |
| | | |
| | | cl_voice_end_1.setOnClickListener { |
| | | voiceIndex = 4 |
| | | player.startPlayMusic(requireContext(),data!!.subjectList[group][0].correct) |
| | | } |
| | | cl_voice_end_2.setOnClickListener { |
| | | voiceIndex = 5 |
| | | player.startPlayMusic(requireContext(),data!!.subjectList[group][1].correct) |
| | | |
| | | } |
| | | cl_voice_end_3.setOnClickListener { |
| | | voiceIndex = 6 |
| | | player.startPlayMusic(requireContext(),data!!.subjectList[group][2].correct) |
| | | |
| | | } |
| | | cl_voice_end_4.setOnClickListener { |
| | | voiceIndex = 7 |
| | | player.startPlayMusic(requireContext(),data!!.subjectList[group][3].correct) |
| | | |
| | | } |
| | | } |
| | | |
| | |
| | | it.completed = false |
| | | it.listend = false |
| | | } |
| | | |
| | | cover_1.gone() |
| | | cover_2.gone() |
| | | cover_3.gone() |
| | | cover_4.gone() |
| | | tv_name.text ="" |
| | | cl_voice_end_1.gone() |
| | | cl_voice_end_2.gone() |
| | | cl_voice_end_3.gone() |
| | | cl_voice_end_4.gone() |
| | | } |
| | | |
| | | companion object{ |
| | |
| | | override fun onStartPlay() { |
| | | playing = true |
| | | val list = data!!.subjectList[group] |
| | | if (voiceIndex in 0..3) |
| | | tv_name.text = list[list.map { it.correct }.indexOf(voiceList[voiceIndex])].name |
| | | when(voiceIndex){ |
| | | 0->{ |
| | | iv1_1.gone() |
| | | iv2_1.gone() |
| | | iv_playing_1.visible() |
| | | iv_playing_1.visible() |
| | | } |
| | | 1->{ |
| | |
| | | iv_playing_4.visible() |
| | | } |
| | | |
| | | 4->{ |
| | | iv1_1_end.gone() |
| | | iv2_1_end.gone() |
| | | iv_playing_1_end.visible() |
| | | } |
| | | 5->{ |
| | | iv1_2_end.gone() |
| | | iv2_2_end.gone() |
| | | iv_playing_2_end.visible() |
| | | } |
| | | 6->{ |
| | | iv1_3_end.gone() |
| | | iv2_3_end.gone() |
| | | iv_playing_3_end.visible() |
| | | } |
| | | 7->{ |
| | | iv1_4_end.gone() |
| | | iv2_4_end.gone() |
| | | iv_playing_4_end.visible() |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | override fun onFinishPlay() { |
| | | playing = false |
| | | val subject = data!!.subjectList[group][voiceIndex] |
| | | subject.listend = true |
| | | when(voiceIndex){ |
| | | 0->{ |
| | | iv1_1.visible() |
| | |
| | | iv2_4.visible() |
| | | iv_playing_4.gone() |
| | | } |
| | | |
| | | 4->{ |
| | | iv1_1_end.visible() |
| | | iv2_1_end.visible() |
| | | iv_playing_1_end.gone() |
| | | } |
| | | 5->{ |
| | | iv1_2_end.visible() |
| | | iv2_2_end.visible() |
| | | iv_playing_2_end.gone() |
| | | } |
| | | 6->{ |
| | | iv1_3_end.visible() |
| | | iv2_3_end.visible() |
| | | iv_playing_3_end.gone() |
| | | } |
| | | 7->{ |
| | | iv1_4_end.visible() |
| | | iv2_4_end.visible() |
| | | iv_playing_4_end.gone() |
| | | } |
| | | } |
| | | if (data!!.subjectList[group].filter { it.completed }.size == 4){ //全部答对 |
| | | handler?.sendEmptyMessage(TO_NEXT) |
| | | } |
| | | } |
| | | } |