|
|
|
@@ -62,10 +62,11 @@ class LearnWordActivity : BaseActivityVM<ActivityLearnWordBinding, LearnWordView |
|
|
|
private lateinit var bindingWord : IncLearnWordBinding |
|
|
|
|
|
|
|
//详情布局 |
|
|
|
private lateinit var incWorcDetailBinding: IncWordDetailBinding |
|
|
|
private lateinit var incWorcDetailBinding : IncWordDetailBinding |
|
|
|
|
|
|
|
//拼写内容布局 |
|
|
|
private lateinit var bindingSpell : IncLearnSpellBinding |
|
|
|
|
|
|
|
//拼写前的提示 |
|
|
|
private lateinit var incSpellTipBinding : IncSpellLearnTipBinding |
|
|
|
|
|
|
|
@@ -105,13 +106,21 @@ class LearnWordActivity : BaseActivityVM<ActivityLearnWordBinding, LearnWordView |
|
|
|
setBackgroundColor(Color.parseColor("#1A5082E6")) |
|
|
|
setTextColor(ContextCompat.getColor(this@LearnWordActivity, R.color.theme_color)) |
|
|
|
} |
|
|
|
} else if (vm.learnData.isReview) { |
|
|
|
binding.tvBanner.apply { |
|
|
|
visibility = View.VISIBLE |
|
|
|
setText(R.string.smart_reviewing) |
|
|
|
setBackgroundColor(Color.parseColor("#1A5082E6")) |
|
|
|
setTextColor(ContextCompat.getColor(this@LearnWordActivity, R.color.theme_color)) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** 标题初始 */ |
|
|
|
private fun initTitle() { |
|
|
|
binding.incLearnTitle.run { |
|
|
|
showProgress = false |
|
|
|
//复习时显示复习正确的进度,学习、自动播放不显示进度 |
|
|
|
showProgress = vm.learnData.isReview |
|
|
|
imgBack.click { onBackPressed() } |
|
|
|
tvTitle.text = vm.learnData.lesson.lessonName |
|
|
|
when (vm.learnData.lesson.coursePackType) { |
|
|
|
@@ -135,9 +144,9 @@ class LearnWordActivity : BaseActivityVM<ActivityLearnWordBinding, LearnWordView |
|
|
|
|
|
|
|
/** 历史轨迹初始 */ |
|
|
|
private fun initHistoricalRoute() { |
|
|
|
val initCourseType = when{ |
|
|
|
val initCourseType = when { |
|
|
|
//自动播放时,将历史轨迹的课时类型修改为单词类型,避免辨音课程自动播放时显示横线 |
|
|
|
vm.learnData.isAutoPlay -> AppConstants.COURSE_TYPE_ENGLISH_DISCERN |
|
|
|
vm.learnData.isAutoPlay -> AppConstants.COURSE_TYPE_ENGLISH_DISCERN |
|
|
|
else -> vm.learnData.lesson.courseType |
|
|
|
} |
|
|
|
adapterHistorical = AdapterHistoricalRoute(initCourseType).apply { |
|
|
|
@@ -178,7 +187,7 @@ class LearnWordActivity : BaseActivityVM<ActivityLearnWordBinding, LearnWordView |
|
|
|
//拼写纠错按钮 点击事件 |
|
|
|
bindingSpell.tvControlError.click { |
|
|
|
when (it.tag as Int) { |
|
|
|
SPELL_TAG_ALL_RIGHT -> vm.currentSpellIsCorrect = false |
|
|
|
SPELL_TAG_ALL_RIGHT -> vm.currentSpellIsCorrect = false |
|
|
|
SPELL_TAG_IN_ERROR -> { |
|
|
|
vm.currentSpellIsCorrect = true |
|
|
|
//下一条显示 |
|
|
|
@@ -191,8 +200,7 @@ class LearnWordActivity : BaseActivityVM<ActivityLearnWordBinding, LearnWordView |
|
|
|
} |
|
|
|
bindingSpell.incWord.tvWord.click { |
|
|
|
//拼写完成点击才有效,拼写中点击无效 |
|
|
|
if (!spellAdapter.isSpelling) |
|
|
|
readWord() |
|
|
|
if (!spellAdapter.isSpelling) readWord() |
|
|
|
} |
|
|
|
} |
|
|
|
AppConstants.COURSE_TYPE_ENGLISH_VOICE -> { |
|
|
|
@@ -222,9 +230,9 @@ class LearnWordActivity : BaseActivityVM<ActivityLearnWordBinding, LearnWordView |
|
|
|
incWorcDetailBinding.root.visibility = it |
|
|
|
} |
|
|
|
} |
|
|
|
if (vm.learnData.lesson.courseType == AppConstants.COURSE_TYPE_CHINESE_COMPOSITION){ |
|
|
|
if (vm.learnData.lesson.courseType == AppConstants.COURSE_TYPE_CHINESE_COMPOSITION) { |
|
|
|
bindingWord.imgWord.visibility = View.GONE |
|
|
|
val layoutParams = bindingWord.incWord.root.layoutParams as ConstraintLayout.LayoutParams |
|
|
|
val layoutParams = bindingWord.incWord.root.layoutParams as ConstraintLayout.LayoutParams |
|
|
|
layoutParams.goneTopMargin = ScreenUtil.dp2px(12f).toInt() |
|
|
|
bindingWord.incWord.root.requestLayout() |
|
|
|
} |
|
|
|
@@ -233,8 +241,8 @@ class LearnWordActivity : BaseActivityVM<ActivityLearnWordBinding, LearnWordView |
|
|
|
//初始化按钮 |
|
|
|
private fun initControlButton() { |
|
|
|
//自动播放隐藏操作按钮 |
|
|
|
if (vm.learnData.isAutoPlay){ |
|
|
|
binding.incControlButton.root.visibility= View.GONE |
|
|
|
if (vm.learnData.isAutoPlay) { |
|
|
|
binding.incControlButton.root.visibility = View.GONE |
|
|
|
return |
|
|
|
} |
|
|
|
//其他课程默认按钮全部隐藏 |
|
|
|
@@ -268,12 +276,12 @@ class LearnWordActivity : BaseActivityVM<ActivityLearnWordBinding, LearnWordView |
|
|
|
} |
|
|
|
|
|
|
|
//最底部 |
|
|
|
private fun initBottom(){ |
|
|
|
private fun initBottom() { |
|
|
|
//有效时间 |
|
|
|
vm.validTime.observe(this){ |
|
|
|
binding.tvValidTime.text = "本次学习 ${DateUtil.formatGMT(it,DateUtil.FORMAT_2)}" |
|
|
|
vm.validTime.observe(this) { |
|
|
|
binding.tvValidTime.text = "本次学习 ${DateUtil.formatGMT(it, DateUtil.FORMAT_2)}" |
|
|
|
} |
|
|
|
if (vm.learnData.isAutoPlay){ |
|
|
|
if (vm.learnData.isAutoPlay) { |
|
|
|
binding.tvPlay.run { |
|
|
|
visibility = View.VISIBLE |
|
|
|
tag = 1 |
|
|
|
@@ -285,7 +293,7 @@ class LearnWordActivity : BaseActivityVM<ActivityLearnWordBinding, LearnWordView |
|
|
|
} |
|
|
|
|
|
|
|
binding.tvPlay.click { |
|
|
|
when(binding.tvPlay.tag as Int){ |
|
|
|
when (binding.tvPlay.tag as Int) { |
|
|
|
1 -> { //暂停播放 |
|
|
|
vm.isAutoPlaying = false |
|
|
|
binding.tvPlay.apply { |
|
|
|
@@ -297,7 +305,7 @@ class LearnWordActivity : BaseActivityVM<ActivityLearnWordBinding, LearnWordView |
|
|
|
binding.tvBanner.apply { |
|
|
|
setText(R.string.auto_play_banner_paused) |
|
|
|
setBackgroundColor(Color.parseColor("#1AF26255")) |
|
|
|
setTextColor(ContextCompat.getColor(this@LearnWordActivity,R.color.red_1)) |
|
|
|
setTextColor(ContextCompat.getColor(this@LearnWordActivity, R.color.red_1)) |
|
|
|
} |
|
|
|
} |
|
|
|
2 -> { //继续播放 |
|
|
|
@@ -318,19 +326,20 @@ class LearnWordActivity : BaseActivityVM<ActivityLearnWordBinding, LearnWordView |
|
|
|
} |
|
|
|
} |
|
|
|
//停止播放 |
|
|
|
binding.tvPlayStop.click {onBackPressed()} |
|
|
|
binding.tvPlayStop.click { onBackPressed() } |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** 发音监听 */ |
|
|
|
private val impListener = object : IMPListener { |
|
|
|
override fun onMpState(state : EMediaState) { |
|
|
|
when{ |
|
|
|
vm.learnData.isAutoPlay -> when (state) { |
|
|
|
when { |
|
|
|
vm.learnData.isAutoPlay -> when (state) { |
|
|
|
EMediaState.COMPLETE, EMediaState.ERROR -> { |
|
|
|
//播放次数+1 |
|
|
|
vm.currentPlayTime ++ |
|
|
|
vm.currentPlayTime++ |
|
|
|
//继续播放,或获取下一条 |
|
|
|
LiveEventBus.get<Int>("auto_play").postDelay(0,700) |
|
|
|
LiveEventBus.get<Int>("auto_play").postDelay(0, 700) |
|
|
|
} |
|
|
|
} |
|
|
|
else -> when (state) { |
|
|
|
@@ -345,10 +354,10 @@ class LearnWordActivity : BaseActivityVM<ActivityLearnWordBinding, LearnWordView |
|
|
|
override fun loadData() { |
|
|
|
vm.loadNext() |
|
|
|
//如果自动播放,监听信息 |
|
|
|
if (vm.learnData.isAutoPlay){ |
|
|
|
LiveEventBus.get<Int>("auto_play").observe(this){ |
|
|
|
if (vm.learnData.isAutoPlay) { |
|
|
|
LiveEventBus.get<Int>("auto_play").observe(this) { |
|
|
|
if (!vm.isAutoPlaying) return@observe |
|
|
|
when(vm.currentPlayTime){ |
|
|
|
when (vm.currentPlayTime) { |
|
|
|
vm.learnData.autoPlayTime -> vm.loadNext() |
|
|
|
else -> readWord() |
|
|
|
} |
|
|
|
@@ -358,19 +367,20 @@ class LearnWordActivity : BaseActivityVM<ActivityLearnWordBinding, LearnWordView |
|
|
|
//发音数据 |
|
|
|
AudioCache.initAudioLiveData().observe(this) { |
|
|
|
//自动播放的单词音频数据 |
|
|
|
if (vm.learnData.isAutoPlay){ |
|
|
|
if (vm.learnData.isAutoPlay) { |
|
|
|
it?.run { |
|
|
|
MPManager.play(it,listener = impListener) |
|
|
|
}?:let { |
|
|
|
MPManager.play(it, listener = impListener) |
|
|
|
} ?: let { |
|
|
|
showToast("未找到发音文件") |
|
|
|
//获取下一条 |
|
|
|
vm.loadNext() |
|
|
|
} |
|
|
|
return@observe |
|
|
|
} |
|
|
|
//学习、复习时的发音数据 |
|
|
|
it?.run { |
|
|
|
if (vm.learnData.lesson.courseType == AppConstants.COURSE_TYPE_ENGLISH_VOICE && bindingWord.ivVoice.visibility == View.VISIBLE) |
|
|
|
MPManager.play(it, listener = impListener) |
|
|
|
if (vm.learnData.lesson.courseType == AppConstants.COURSE_TYPE_ENGLISH_VOICE && bindingWord.ivVoice.visibility == View.VISIBLE) MPManager.play( |
|
|
|
it, listener = impListener) |
|
|
|
else MPManager.play(it) |
|
|
|
} ?: showToast("未找到发音文件") |
|
|
|
} |
|
|
|
@@ -379,7 +389,7 @@ class LearnWordActivity : BaseActivityVM<ActivityLearnWordBinding, LearnWordView |
|
|
|
//图片数据 |
|
|
|
PhotoCache.initPhotoLiveData().observe(this) { |
|
|
|
it?.run { |
|
|
|
if(vm.learnData.isAutoPlay)bindingWord.imgWord.visibility = View.VISIBLE |
|
|
|
if (vm.learnData.isAutoPlay) bindingWord.imgWord.visibility = View.VISIBLE |
|
|
|
ImageLoader.loadImage(bindingWord.imgWord, it) |
|
|
|
} ?: let { bindingWord.imgWord.visibility = View.GONE } |
|
|
|
} |
|
|
|
@@ -392,7 +402,8 @@ class LearnWordActivity : BaseActivityVM<ActivityLearnWordBinding, LearnWordView |
|
|
|
adapterHistorical.addData(it) |
|
|
|
binding.rvHistoricalRoute.scrollToPosition(adapterHistorical.itemCount - 1) |
|
|
|
} |
|
|
|
if (vm.learnData.isAutoPlay){ |
|
|
|
//自动播放界面初始 |
|
|
|
if (vm.learnData.isAutoPlay) { |
|
|
|
initAutoPlayWord(it) |
|
|
|
return@observe |
|
|
|
} |
|
|
|
@@ -413,9 +424,9 @@ class LearnWordActivity : BaseActivityVM<ActivityLearnWordBinding, LearnWordView |
|
|
|
//上传数据后的处理 |
|
|
|
vm.saveDataLiveData.observe(this) { |
|
|
|
when { |
|
|
|
//学习完成的保存数据 |
|
|
|
//学习完成的保存数据后显示学习完成弹窗 |
|
|
|
it -> showLearnOverDialog() |
|
|
|
//学习未完成的保存数据 |
|
|
|
//学习未完成的保存数据,直接关闭 |
|
|
|
else -> finish() |
|
|
|
} |
|
|
|
} |
|
|
|
@@ -434,10 +445,10 @@ class LearnWordActivity : BaseActivityVM<ActivityLearnWordBinding, LearnWordView |
|
|
|
//单词内容 |
|
|
|
bindingWord.incWord.tvWord.apply { |
|
|
|
//识字需单独处理 |
|
|
|
if (vm.learnData.lesson.courseType == AppConstants.COURSE_TYPE_CHINESE_LITERACY){ |
|
|
|
setHtml(ViewUtil.literacyToHtmlWord(learnWord.word, learnWord.showColor)) |
|
|
|
if (vm.learnData.lesson.courseType == AppConstants.COURSE_TYPE_CHINESE_LITERACY) { |
|
|
|
setHtml(ViewUtil.literacyToHtmlWord(learnWord.word, learnWord.showColor)) |
|
|
|
} else { |
|
|
|
text = learnWord.word |
|
|
|
text = learnWord.word |
|
|
|
} |
|
|
|
setTextColor(ContextCompat.getColor(this@LearnWordActivity, learnWord.showColor)) //单词显示颜色 |
|
|
|
} |
|
|
|
@@ -506,7 +517,7 @@ class LearnWordActivity : BaseActivityVM<ActivityLearnWordBinding, LearnWordView |
|
|
|
} |
|
|
|
binding.incControlButton.tvCenter.visibility = View.INVISIBLE |
|
|
|
binding.incControlButton.tvRight.visibility = when (vm.learnData.lesson.coursePackType) { |
|
|
|
AppConstants.COURSEPACK_TYPE_CHINESE_COMPOSITION,AppConstants.COURSEPACK_TYPE_ENGLISH_SOUNDMARK -> View.INVISIBLE |
|
|
|
AppConstants.COURSEPACK_TYPE_CHINESE_COMPOSITION, AppConstants.COURSEPACK_TYPE_ENGLISH_SOUNDMARK -> View.INVISIBLE |
|
|
|
else -> View.VISIBLE |
|
|
|
} |
|
|
|
|
|
|
|
@@ -569,8 +580,8 @@ class LearnWordActivity : BaseActivityVM<ActivityLearnWordBinding, LearnWordView |
|
|
|
} |
|
|
|
binding.incControlButton.tvCenter.visibility = View.VISIBLE |
|
|
|
//音标,显示重读 |
|
|
|
when(vm.learnData.lesson.coursePackType){ |
|
|
|
AppConstants.COURSEPACK_TYPE_ENGLISH_SOUNDMARK ->binding.incControlButton.tvRight.visibility = View.VISIBLE |
|
|
|
when (vm.learnData.lesson.coursePackType) { |
|
|
|
AppConstants.COURSEPACK_TYPE_ENGLISH_SOUNDMARK -> binding.incControlButton.tvRight.visibility = View.VISIBLE |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
@@ -602,17 +613,16 @@ class LearnWordActivity : BaseActivityVM<ActivityLearnWordBinding, LearnWordView |
|
|
|
/**点击下一条*/ |
|
|
|
private fun clickNext() { |
|
|
|
//拼写,需要处理历史轨迹 和在下一条的时候保存当前学习数据 |
|
|
|
if (vm.learnData.lesson.courseType == AppConstants.COURSE_TYPE_ENGLISH_SPELL){ |
|
|
|
if (vm.learnData.lesson.courseType == AppConstants.COURSE_TYPE_ENGLISH_SPELL) { |
|
|
|
adapterHistorical.currentLearnOver() |
|
|
|
when{ |
|
|
|
when { |
|
|
|
//正确 |
|
|
|
vm.currentSpellIsCorrect -> { |
|
|
|
//传递正确 |
|
|
|
vm.clickCorrect(adapterHistorical.currentIsLastSelect) |
|
|
|
val value = vm.currentLearnWord.value!! |
|
|
|
// 正常第一次不需要移除,第一个表达式则判断为第一次出现但是为学前测试错误 ,第二个表达式为小循环但不为小循环最后一次且后面还有数据则需要移除 |
|
|
|
if ((value.first && value.repeatNum == 1) || (!value.first && value.repeatNum <vm.learnRuleUtil.insertInterval.size && vm.learnRuleUtil.isHaveNext)) |
|
|
|
adapterHistorical.spellNeedRemoveCurrent() |
|
|
|
if ((value.first && value.repeatNum == 1) || (!value.first && value.repeatNum < vm.learnRuleUtil.insertInterval.size && vm.learnRuleUtil.isHaveNext)) adapterHistorical.spellNeedRemoveCurrent() |
|
|
|
} |
|
|
|
else -> { |
|
|
|
vm.clickError(adapterHistorical.currentIsLastSelect) |
|
|
|
@@ -622,7 +632,7 @@ class LearnWordActivity : BaseActivityVM<ActivityLearnWordBinding, LearnWordView |
|
|
|
} |
|
|
|
|
|
|
|
//当前数据为历史轨迹点击 且 最后一条学习未完成 且不为最后一条 |
|
|
|
if (!adapterHistorical.currentIsLastSelect && vm.currentIsHistoricalItemClick && !adapterHistorical.lastIsLearnOver) { |
|
|
|
if (!adapterHistorical.currentIsLastSelect && vm.currentIsHistoricalItemClick && !adapterHistorical.lastIsLearnOver) { |
|
|
|
skipToHistoricalLastItem() |
|
|
|
} else { |
|
|
|
vm.loadNext() |
|
|
|
@@ -631,17 +641,18 @@ class LearnWordActivity : BaseActivityVM<ActivityLearnWordBinding, LearnWordView |
|
|
|
|
|
|
|
/** 滑动到最后一项进行点击 */ |
|
|
|
private fun skipToHistoricalLastItem() { |
|
|
|
binding.rvHistoricalRoute.post{ |
|
|
|
binding.rvHistoricalRoute.post { |
|
|
|
val position = adapterHistorical.itemCount - 1 //最后item的位置 |
|
|
|
val last = historicalLayoutManager.findLastCompletelyVisibleItemPosition() //最后完全可见 |
|
|
|
if (position > last ){ //需要操作的位置大于当前最后显示的位置,则进行滚动 |
|
|
|
if (position > last) { //需要操作的位置大于当前最后显示的位置,则进行滚动 |
|
|
|
binding.rvHistoricalRoute.addOnScrollListener(historicalScrollListener) |
|
|
|
binding.rvHistoricalRoute.smoothScrollToPosition(position) |
|
|
|
}else { //position view 可见 |
|
|
|
} else { //position view 可见 |
|
|
|
historicalLayoutManager.findViewByPosition(position)?.performClick() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private val historicalScrollListener = object : OnScrollListener() { |
|
|
|
override fun onScrollStateChanged(recyclerView : RecyclerView, newState : Int) { |
|
|
|
super.onScrollStateChanged(recyclerView, newState) |
|
|
|
@@ -733,7 +744,7 @@ class LearnWordActivity : BaseActivityVM<ActivityLearnWordBinding, LearnWordView |
|
|
|
private val itemSpellRecoveryClick = { showValue : SpannableStringBuilder, isOver : Boolean, nextPosition : Int -> |
|
|
|
bindingSpell.incWord.tvWord.text = showValue |
|
|
|
//纠错完成 |
|
|
|
if (isOver){ |
|
|
|
if (isOver) { |
|
|
|
binding.incControlButton.tvLeft.visibility = View.VISIBLE |
|
|
|
} |
|
|
|
bindingSpell.spellRecyclerView.scrollToPosition(nextPosition) |
|
|
|
@@ -763,9 +774,9 @@ class LearnWordActivity : BaseActivityVM<ActivityLearnWordBinding, LearnWordView |
|
|
|
|
|
|
|
override fun dispatchTouchEvent(ev : MotionEvent?) : Boolean { |
|
|
|
//执行有效计时 |
|
|
|
when{ |
|
|
|
when { |
|
|
|
//自动播放只有在非播放时触摸有效 |
|
|
|
vm.learnData.isAutoPlay -> when{ |
|
|
|
vm.learnData.isAutoPlay -> when { |
|
|
|
!vm.isAutoPlaying -> vm.executeLearnValidTime() |
|
|
|
} |
|
|
|
else -> vm.executeLearnValidTime() |
|
|
|
@@ -775,16 +786,41 @@ class LearnWordActivity : BaseActivityVM<ActivityLearnWordBinding, LearnWordView |
|
|
|
|
|
|
|
/** 返回 */ |
|
|
|
override fun onBackPressed() { |
|
|
|
when { |
|
|
|
vm.isAllOver -> finish() |
|
|
|
else -> when { |
|
|
|
vm.learnData.isAutoPlay -> autoPlayBackDialog() |
|
|
|
vm.isHasLearned -> learnBackDialog() |
|
|
|
else -> finish() |
|
|
|
} |
|
|
|
backDialog() |
|
|
|
} |
|
|
|
|
|
|
|
private fun backDialog() { |
|
|
|
vm.showOrDismissBackDialogForTime(true) |
|
|
|
val commonDialogBean = when { |
|
|
|
vm.learnData.isAutoPlay -> CommonDialogBean(titleText = R.string.quit_auto_play_title, leftText = R.string.cancel, |
|
|
|
rightText = R.string.quit) |
|
|
|
else -> CommonDialogBean(titleText = R.string.quit_learn_title, contentText = R.string.quit_learn_content, |
|
|
|
leftText = R.string.quit, rightText = R.string.cancel) |
|
|
|
} |
|
|
|
CommonDialog.newInstance(commonDialogBean).apply { |
|
|
|
onCommonDialogButtonClickListener = { dialog, isRightClick -> |
|
|
|
dialog.dismissAllowingStateLoss() |
|
|
|
when { |
|
|
|
//自动播放 |
|
|
|
vm.learnData.isAutoPlay -> when { |
|
|
|
isRightClick -> vm.saveData() |
|
|
|
else -> { |
|
|
|
vm.showOrDismissBackDialogForTime(false) |
|
|
|
LiveEventBus.get<Int>("auto_play").post(0) |
|
|
|
} |
|
|
|
} |
|
|
|
//学习、复习 |
|
|
|
else -> when { |
|
|
|
isRightClick -> vm.showOrDismissBackDialogForTime(false) |
|
|
|
else -> vm.saveData() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}.show(supportFragmentManager, "learn_word_activity") |
|
|
|
} |
|
|
|
/** 学习时的返回弹窗 */ |
|
|
|
|
|
|
|
/* */ |
|
|
|
/** 学习时的返回弹窗 *//* |
|
|
|
private fun learnBackDialog() { |
|
|
|
vm.showOrDismissBackDialogForTime(true) |
|
|
|
CommonDialog.newInstance( |
|
|
|
@@ -798,7 +834,8 @@ class LearnWordActivity : BaseActivityVM<ActivityLearnWordBinding, LearnWordView |
|
|
|
} |
|
|
|
}.show(supportFragmentManager, "learn_back_dialog") |
|
|
|
} |
|
|
|
/** 自动播放时的返回弹窗 */ |
|
|
|
*/ |
|
|
|
/** 自动播放时的返回弹窗 *//* |
|
|
|
private fun autoPlayBackDialog() { |
|
|
|
vm.showOrDismissBackDialogForTime(true) |
|
|
|
CommonDialog.newInstance( |
|
|
|
@@ -814,17 +851,19 @@ class LearnWordActivity : BaseActivityVM<ActivityLearnWordBinding, LearnWordView |
|
|
|
} |
|
|
|
} |
|
|
|
}.show(supportFragmentManager, "auto_play_back_dialog") |
|
|
|
} |
|
|
|
}*/ |
|
|
|
|
|
|
|
/** 学习完成 */ |
|
|
|
private fun showLearnOverDialog() { |
|
|
|
when{ |
|
|
|
when { |
|
|
|
//自动播放完成弹窗 |
|
|
|
vm.learnData.isAutoPlay -> showAutoPlayOverDialog() |
|
|
|
//复习完成 |
|
|
|
vm.learnData.isReview -> showReviewOverDialog() |
|
|
|
//作文知识点完成 |
|
|
|
vm.learnData.lesson.courseType == AppConstants.COURSE_TYPE_CHINESE_COMPOSITION -> showCompositionKnowLeageLearningOver() |
|
|
|
vm.learnData.lesson.courseType == AppConstants.COURSE_TYPE_CHINESE_COMPOSITION -> showCompositionKnowLeageLearningOver() |
|
|
|
//其他单词类,带学后测试的课时完成 |
|
|
|
else -> showLessonWordLearningOver() |
|
|
|
else -> showLessonWordLearningOver() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@@ -847,7 +886,8 @@ class LearnWordActivity : BaseActivityVM<ActivityLearnWordBinding, LearnWordView |
|
|
|
dialog.dismissAllowingStateLoss() |
|
|
|
//发送动作 : 学后测试 |
|
|
|
LiveEventBus.get<LearnEventData>(AppConstants.EVENT_LESSON_ACTION) |
|
|
|
.post(LearnEventData(vm.learnData.lesson.subjectId, vm.learnData.lesson.courseId, AppConstants.ACTION_LESSON_AFTER_TEST_AGAIN).apply { |
|
|
|
.post(LearnEventData(vm.learnData.lesson.subjectId, vm.learnData.lesson.courseId, |
|
|
|
AppConstants.ACTION_LESSON_AFTER_TEST_AGAIN).apply { |
|
|
|
leesonPositionIndex = vm.learnData.lesson.lessonPositionInList |
|
|
|
}) |
|
|
|
finish() |
|
|
|
@@ -862,9 +902,9 @@ class LearnWordActivity : BaseActivityVM<ActivityLearnWordBinding, LearnWordView |
|
|
|
* 自动播放完成弹窗 |
|
|
|
*/ |
|
|
|
private fun showAutoPlayOverDialog() { |
|
|
|
val drawable = DrawableUti.changeSvgSizeAndColor(resources, R.drawable.ic_right, R.color.theme_color,3) |
|
|
|
CommonDialog.newInstance(CommonDialogBean(titleText = R.string.quit_auto_play_title_over, |
|
|
|
rightText = R.string.sure),drawable).apply { |
|
|
|
val drawable = DrawableUti.changeSvgSizeAndColor(resources, R.drawable.ic_right, R.color.theme_color, 3) |
|
|
|
CommonDialog.newInstance(CommonDialogBean(titleText = R.string.quit_auto_play_title_over, rightText = R.string.sure), |
|
|
|
drawable).apply { |
|
|
|
onCommonDialogButtonClickListener = { dialog, _ -> |
|
|
|
dialog.dismissAllowingStateLoss() |
|
|
|
finish() |
|
|
|
@@ -872,18 +912,34 @@ class LearnWordActivity : BaseActivityVM<ActivityLearnWordBinding, LearnWordView |
|
|
|
}.show(supportFragmentManager, "auto_play_back_dialog") |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 复习完成弹窗 |
|
|
|
*/ |
|
|
|
private fun showReviewOverDialog() { |
|
|
|
LearnDialog.newInstance(LearnDialogBean(AppConstants.DIALOG_TYPE_REVIEW_OVER).apply { |
|
|
|
correctNumber = vm.currentLessonLearnedPosition + 1 //本次已复习完成数量 |
|
|
|
errorNumber = vm.newVocabularyList.size //大循环复习完成数量 |
|
|
|
}).apply { |
|
|
|
onDialogListener = { action, dialog -> |
|
|
|
//完成 关闭,不处理 |
|
|
|
dialog.dismissAllowingStateLoss() |
|
|
|
finish() |
|
|
|
} |
|
|
|
}.show(supportFragmentManager, "review_over") |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 作文知识点学习完成弹窗 |
|
|
|
*/ |
|
|
|
private fun showCompositionKnowLeageLearningOver(){ |
|
|
|
private fun showCompositionKnowLeageLearningOver() { |
|
|
|
LearnDialog.newInstance(LearnDialogBean(AppConstants.DIALOG_TYPE_LESSON_COMPOSITION_KNOWLEDGE_LEARNING_OVER).apply { |
|
|
|
correctNumber = vm.learnData.lesson.correctNumber |
|
|
|
errorNumber = vm.learnData.lesson.errorNumber |
|
|
|
}).apply { |
|
|
|
onDialogListener = { action, dialog -> |
|
|
|
when(action){ |
|
|
|
when (action) { |
|
|
|
//重学,重学弹窗提示 |
|
|
|
AppConstants.DIALOG_LESSON_RELEARN -> lessonRelearnDialog(dialog) |
|
|
|
AppConstants.DIALOG_LESSON_RELEARN -> lessonRelearnDialog(dialog) |
|
|
|
//完成 关闭,不处理 |
|
|
|
AppConstants.DIALOG_OVER -> { |
|
|
|
dialog.dismissAllowingStateLoss() |
|
|
|
@@ -891,7 +947,7 @@ class LearnWordActivity : BaseActivityVM<ActivityLearnWordBinding, LearnWordView |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}.show(supportFragmentManager,"composition_knowledge_learn_over") |
|
|
|
}.show(supportFragmentManager, "composition_knowledge_learn_over") |
|
|
|
} |
|
|
|
|
|
|
|
/*** |
|
|
|
@@ -908,7 +964,8 @@ class LearnWordActivity : BaseActivityVM<ActivityLearnWordBinding, LearnWordView |
|
|
|
dialog.dismissAllowingStateLoss() |
|
|
|
//发送动作 : 重新学习 |
|
|
|
LiveEventBus.get<LearnEventData>(AppConstants.EVENT_LESSON_ACTION) |
|
|
|
.post(LearnEventData(vm.learnData.lesson.subjectId, vm.learnData.lesson.courseId, AppConstants.ACTION_LESSON_AFTER_TEST_RELEARN).apply { |
|
|
|
.post(LearnEventData(vm.learnData.lesson.subjectId, vm.learnData.lesson.courseId, |
|
|
|
AppConstants.ACTION_LESSON_AFTER_TEST_RELEARN).apply { |
|
|
|
leesonPositionIndex = vm.learnData.lesson.lessonPositionInList |
|
|
|
}) |
|
|
|
finish() |
|
|
|
@@ -917,7 +974,5 @@ class LearnWordActivity : BaseActivityVM<ActivityLearnWordBinding, LearnWordView |
|
|
|
}.show(dialog.childFragmentManager, "lesson_relearn_tip") |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |