From 855a7e18a795f0db2453a19e3e8f26ba2ff553b4 Mon Sep 17 00:00:00 2001 From: lmw <125975490@qq.com> Date: 星期四, 29 五月 2025 16:32:41 +0800 Subject: [PATCH] UI调整 --- app/src/main/java/com/dollearn/student/ui/home/ListenFragment.kt | 44 ++++++++++++++++++++++++++++++-------------- 1 files changed, 30 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/com/dollearn/student/ui/home/ListenFragment.kt b/app/src/main/java/com/dollearn/student/ui/home/ListenFragment.kt index 9662ece..1e343a0 100644 --- a/app/src/main/java/com/dollearn/student/ui/home/ListenFragment.kt +++ b/app/src/main/java/com/dollearn/student/ui/home/ListenFragment.kt @@ -17,6 +17,7 @@ import com.dollearn.student.utils.AudioUtils import com.dollearn.student.utils.Const import com.dollearn.student.utils.extention.clickDelay +import com.dollearn.student.utils.glide.GlideUtil import kotlinx.android.synthetic.main.fragment_listen.* import org.jetbrains.anko.imageResource @@ -52,6 +53,8 @@ private val randomList by lazy { data?.subjectList!![group].shuffled() }//随机排序后的题目 private val resultViewList by lazy { arrayListOf(result_1,result_2,result_3,result_4) } + + var right = true //true进入下一题为全对,false 一旦答错过就置为false,此时进入下一题,本题算做错误 override fun onFirstVisibleToUser() { player.setOnAudioStatusUpdateListener(this) @@ -94,10 +97,14 @@ data?.apply { val originList = subjectList[group] correctVoice = originList[index].correct - iv_1.setImageURI(randomList[0].img) - iv_2.setImageURI(randomList[1].img) - iv_3.setImageURI(randomList[2].img) - iv_4.setImageURI(randomList[3].img) + GlideUtil.load(requireContext(),randomList[0].img,iv_1,0) + GlideUtil.load(requireContext(),randomList[1].img,iv_2,0) + GlideUtil.load(requireContext(),randomList[2].img,iv_3,0) + GlideUtil.load(requireContext(),randomList[3].img,iv_4,0) +// iv_1.setImageURI(randomList[0].img) +// iv_2.setImageURI(randomList[1].img) +// iv_3.setImageURI(randomList[2].img) +// iv_4.setImageURI(randomList[3].img) resultViewList.forEachIndexed { index, imageView -> imageView.imageResource = if (randomList[index].correct == correctVoice){ motion.setTransition(R.id.start,if (index == 0) R.id.end_1 else if (index == 1) R.id.end_2 else if (index == 2) R.id.end_3 else R.id.end_4) @@ -106,7 +113,7 @@ } } - handler?.sendEmptyMessageDelayed(PLAY_VOICE,1500) //进入题目2秒后播放,这里写1.5秒 预算进网络语音加载时间 + handler?.sendEmptyMessageDelayed(PLAY_VOICE,200) //2025.4.8 立即播放 initClick() } @@ -129,12 +136,13 @@ Log.e(TAG,"回到上一题,恢复答题前的状态") hasListen = false hasRight = false - handler?.sendEmptyMessageDelayed(PLAY_VOICE,1500) //进入题目2秒后播放,这里写1.5秒 预算进网络语音加载时间 - cl_1.progress = 0f - cl_2.progress = 0f - cl_3.progress = 0f - cl_4.progress = 0f - motion.progress = 0f + right = true + handler?.sendEmptyMessageDelayed(PLAY_VOICE,200) //改为立即播放 + cl_1?.progress = 0f + cl_2?.progress = 0f + cl_3?.progress = 0f + cl_4?.progress = 0f + motion?.progress = 0f } companion object{ @@ -158,7 +166,7 @@ private fun setResultAnimation(v:MotionLayout,index: Int){ v.clickDelay { if (!hasListen) { - myToast("请先听题") +// myToast("请先听题") return@clickDelay } if (playing) @@ -169,6 +177,7 @@ v.transitionToEnd() if (randomList[index].correct != correctVoice){ //答案不对,结束后消失 hasListen = false + right = false handler?.sendEmptyMessage(PLAY_ERROR) v.setTransitionListener(object :MotionLayout.TransitionListener{ override fun onTransitionStarted(p0: MotionLayout?, p1: Int, p2: Int) { @@ -209,14 +218,16 @@ iv_playing.gone() if (hasRight&&!playing){ //选对答案后的播放结束3秒后进入下一图 Log.e(TAG,"选对答案后的播放结束3秒后进入下一图") - handler?.sendEmptyMessageDelayed(TO_NEXT,3000) + handler?.sendEmptyMessageDelayed(TO_NEXT,500) //万俊杰:缩短为0.5秒 } if (rightPlaying){ rightPlaying = false hasRight = true handler?.sendEmptyMessage(PLAY_VOICE) - }else if (errorPlaying) + }else if (errorPlaying){ errorPlaying = false + cl_voice.callOnClick() + } else if (!hasRight) hasListen = true } @@ -225,4 +236,9 @@ super.onPause() player.stopPlayMusic() } + + override fun onDestroy() { + super.onDestroy() + handler?.removeCallbacksAndMessages(null) + } } \ No newline at end of file -- Gitblit v1.7.1