| | |
| | | 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_q_a.* |
| | | import org.greenrobot.eventbus.EventBus |
| | | import org.greenrobot.eventbus.Subscribe |
| | | import org.jetbrains.anko.support.v4.dip |
| | | |
| | | class QAFragment:BaseFragment(), AudioUtils.OnAudioStatusUpdateListener { |
| | |
| | | |
| | | |
| | | override fun onFirstVisibleToUser() { |
| | | EventBus.getDefault().register(this) |
| | | player.setOnAudioStatusUpdateListener(this) |
| | | player.stopPlayMusic() |
| | | handler = object : Handler(Looper.getMainLooper()){ |
| | |
| | | },2000) |
| | | } |
| | | } |
| | | |
| | | isAutoPlaying = 1 |
| | | voiceViews.filterIndexed { index, constraintLayout -> |
| | | val subject = list[index] |
| | | constraintLayout.isEnabled&&subject.isQuestion == 1 |
| | | }.firstOrNull()?.callOnClick() |
| | | } |
| | | |
| | | @Subscribe |
| | | fun onEvent(e: EmptyEvent){ |
| | | if (e.code == Const.EventCode.RECOVERD){ |
| | | if (act.fragments[act.vp.currentItem] == this){ //自动播放 |
| | | isAutoPlaying = 1 |
| | | voiceViews.filterIndexed { index, constraintLayout -> |
| | | val subject = list[index] |
| | | constraintLayout.isEnabled&&subject.isQuestion == 1 |
| | | }.firstOrNull()?.callOnClick() |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 恢复答案和题目ui |
| | |
| | | showVoiceUi() |
| | | list.forEach { it.completed = false } |
| | | recoverAnswer() |
| | | if (act.fragments[act.vp.currentItem] == this&&act.recoverd) { //自动播放 |
| | | isAutoPlaying = 1 |
| | | voiceViews.filterIndexed { index, constraintLayout -> |
| | | val subject = list[index] |
| | | constraintLayout.isEnabled&&subject.isQuestion == 1 |
| | | }.firstOrNull()?.callOnClick() |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | override fun onDestroy() { |
| | | super.onDestroy() |
| | | handler?.removeCallbacksAndMessages(null) |
| | | EventBus.getDefault().unregister(this) |
| | | } |
| | | } |