罗明文
1 天以前 aa512ff5fc428fbee046d6bc0761c3675023769e
app/src/main/java/com/dollearn/student/ui/home/IncludeFragment.kt
@@ -16,8 +16,11 @@
import com.dollearn.student.R
import com.dollearn.student.utils.AudioUtils
import com.dollearn.student.utils.Const
import com.dollearn.student.utils.event.EmptyEvent
import com.dollearn.student.utils.extention.clickDelay
import kotlinx.android.synthetic.main.fragment_include.*
import org.greenrobot.eventbus.EventBus
import org.greenrobot.eventbus.Subscribe
import org.jetbrains.anko.support.v4.dip
import org.jetbrains.anko.support.v4.startActivity
@@ -63,6 +66,7 @@
    override fun onFirstVisibleToUser() {
        player.setOnAudioStatusUpdateListener(this)
        player.stopPlayMusic()
        EventBus.getDefault().register(this)
        handler = object : Handler(Looper.getMainLooper()){
            override fun handleMessage(msg: Message) {
                super.handleMessage(msg)
@@ -121,8 +125,6 @@
        }
        initClick()
        showVoiceEnable()
        isAutoPlaying = true
        voiceViews[0].callOnClick()
    }
    private fun initClick() {
@@ -367,6 +369,16 @@
        })
    }
    @Subscribe
    fun onEvent(e: EmptyEvent){
        if (e.code == Const.EventCode.RECOVERD){
            if (act.fragments[act.vp.currentItem] == this){ //自动播放
                isAutoPlaying = true
                voiceViews[0].callOnClick()
            }
        }
    }
    /**
     * 回到上一题,恢复状态
     */
@@ -382,6 +394,10 @@
            it.listend = false
        }
        showVoiceEnable()
        if (act.fragments[act.vp.currentItem] == this&&act.recoverd) { //自动播放
            isAutoPlaying = true
            voiceViews[0].callOnClick()
        }
    }
    companion object{
@@ -535,5 +551,6 @@
    override fun onDestroy() {
        super.onDestroy()
        handler?.removeCallbacksAndMessages(null)
        EventBus.getDefault().unregister(this)
    }
}