lmw
2024-07-19 cd13751df41c6504b3934cd3f1bd441c4ba172ff
app/src/main/java/com/dollearn/student/ui/home/IncludeFragment.kt
@@ -48,7 +48,7 @@
    private val act by lazy { requireActivity() as IncludeActivity }
    private var voiceIndex = -1 //点击播放的声音序号 0-5取值
    private val voiceViews by lazy { arrayListOf(cl_voice1,cl_voice2,cl_voice3,cl_voice4,cl_voice5,cl_voice6) }
    private val voiceViews by lazy { arrayListOf(cl_voice1_real,cl_voice2_real,cl_voice3_real,cl_voice4_real,cl_voice5_real,cl_voice6_real) }
    private var playing = false
    private val answerImg = arrayListOf<String>() //随机答案图片
@@ -87,13 +87,23 @@
        }
        data?.apply {
            val originList = subjectList[group]
            iv_1.setImageURI(originList[0].img)
            iv_2.setImageURI(originList[1].img)
            iv_4.setImageURI(originList[3].img)
            answerImg.clear()
            answerImg.add(originList[2].img)
            answerImg.add(originList[4].img)
            answerImg.add(originList[5].img)
            cl_voice1_real.postDelayed({
                iv_1.setImageURI(originList[0].img)
                iv_2.setImageURI(originList[1].img)
                iv_4.setImageURI(originList[3].img)
                if (cl_1.width > dip(203)){
                    voiceViews.forEach {
                        it.layoutParams.width = dip(159)
                        it.layoutParams.height = dip(52)
                        it.requestLayout()
                    }
                }
                voiceViews.forEach { it.visible() }
            },500)
        }
        voiceViews.forEachIndexed { index, constraintLayout ->
            if (index == 0)
@@ -111,11 +121,11 @@
    private fun initClick() {
        voiceViews.forEachIndexed { index, constraintLayout ->
            constraintLayout.clickDelay {
            constraintLayout.setOnClickListener {
                if (!playing){
                    if (index!=0&&!data!!.subjectList[group][index-1].listend){
                        myToast("请按顺序听语音")
                        return@clickDelay
                        return@setOnClickListener
                    }
                    voiceIndex = index
                    handler?.sendEmptyMessage(PLAY_VOICE)