@@ -0,0 +1 @@ | |||
XklLocal |
@@ -18,11 +18,8 @@ import java.io.* | |||
import java.lang.Exception | |||
import java.math.BigDecimal | |||
import java.math.RoundingMode | |||
import java.text.DateFormat | |||
import java.text.DecimalFormat | |||
import java.text.SimpleDateFormat | |||
import java.util.* | |||
import java.util.zip.ZipFile | |||
import java.util.zip.ZipInputStream | |||
/** | |||
@@ -494,11 +491,19 @@ object CourseManager { | |||
} | |||
/** 获取课程的数量 */ | |||
fun getTotalCourseSize() : Int { | |||
fun getTotalCourseSize(projectId : Int) : Int { | |||
var result = 0 | |||
subjectWithCoursePackMap.forEach { entry -> | |||
entry.value.forEach { coursePack -> | |||
result += coursePack.childrenCourses.size | |||
when(projectId){ | |||
0 -> subjectWithCoursePackMap.forEach { entry -> | |||
entry.value.forEach { coursePack -> | |||
result += coursePack.childrenCourses.size | |||
} | |||
} | |||
AppConstants.SUBJECT_ENGLISH -> subjectWithCoursePackMap[AppConstants.SUBJECT_ENGLISH]?.forEach { | |||
result += it.childrenCourses.size | |||
} | |||
AppConstants.SUBJECT_CHINESE -> subjectWithCoursePackMap[AppConstants.SUBJECT_CHINESE]?.forEach { | |||
result += it.childrenCourses.size | |||
} | |||
} | |||
return result |
@@ -157,14 +157,14 @@ object DBCourseManager { | |||
mutableList.add(lesson) | |||
positionIndex += 1 | |||
// TODO: 2022/5/9 对课时数量进行限制,课时太多,开发人员不好进行测试 | |||
// val needBreak = when (base.coursePackType) { | |||
// AppConstants.COURSEPACK_TYPE_CHINESE_COMPOSITION -> positionIndex == 10 //保留十个课时 | |||
// AppConstants.COURSEPACK_TYPE_ENGLISH_SPOKEN -> positionIndex == 6 //保留六个课时 | |||
// else -> positionIndex == 3 //保留三个课时 | |||
// } | |||
// if (needBreak) { | |||
// break | |||
// } | |||
val needBreak = when (base.coursePackType) { | |||
AppConstants.COURSEPACK_TYPE_CHINESE_COMPOSITION -> positionIndex == 10 //保留十个课时 | |||
AppConstants.COURSEPACK_TYPE_ENGLISH_SPOKEN -> positionIndex == 6 //保留六个课时 | |||
else -> positionIndex == 6 //保留六个课时 | |||
} | |||
if (needBreak) { | |||
break | |||
} | |||
} | |||
it.close() | |||
} |
@@ -103,13 +103,40 @@ class LearnExamActivity : BaseActivityVM<ActivityLearnExamBinding, LearnExamView | |||
/** 查询到播放数据过来 */ | |||
AudioCache.initAudioLiveData().observe(this) { | |||
if (it == null) { | |||
//发音文件为空 | |||
showToast("未找到发音文件") | |||
} else { | |||
MPManager.play(it, listener = impListener) | |||
//没有完成且非生命周期暂停 | |||
if (!vm.isAllOver && !vm.isLifecyclerPause) { | |||
if (it == null) { | |||
//发音文件为空 | |||
showToast("未找到发音文件") | |||
} else { | |||
MPManager.play(it, listener = impListener) | |||
} | |||
} | |||
} | |||
} | |||
override fun onResume() { | |||
super.onResume() | |||
//继续播放 | |||
if (vm.isLifecyclerPause) { | |||
vm.isLifecyclerPause = false | |||
if (!vm.isAllOver && wordChooseBinding.ivVoice.visibility == View.VISIBLE) { | |||
wordChooseBinding.ivVoice.performClick() | |||
} | |||
} | |||
} | |||
override fun onPause() { | |||
super.onPause() | |||
vm.isLifecyclerPause = true | |||
//辨音测试,停止动画,停止播放 | |||
if (vm.intentData.courseType == AppConstants.COURSE_TYPE_ENGLISH_VOICE) { | |||
if (wordChooseBinding.ivVoice.visibility == View.VISIBLE) { | |||
wordChooseBinding.ivVoice.cancelAnimation() | |||
} | |||
} | |||
MPManager.removePlayListener() | |||
MPManager.stopPlay() | |||
} | |||
//播放监听 | |||
@@ -142,7 +169,7 @@ class LearnExamActivity : BaseActivityVM<ActivityLearnExamBinding, LearnExamView | |||
/** 新单词来了的发音事件 */ | |||
private fun initNewWordRead(it : ExamBean) { | |||
//词汇量测试,新单词发音 | |||
if (vm.intentData.examType == AppConstants.TEST_TYPE_NORMAL){ | |||
if (vm.intentData.examType == AppConstants.TEST_TYPE_NORMAL) { | |||
wordChooseBinding.ivVoice.performClick() | |||
return | |||
} | |||
@@ -295,9 +322,6 @@ class LearnExamActivity : BaseActivityVM<ActivityLearnExamBinding, LearnExamView | |||
} | |||
override fun loadData() { | |||
//初始获取第一条数据 | |||
vm.loadFirst() | |||
//监听倒计时 | |||
vm.currentSuplusTime.observe(this) { | |||
when (vm.intentData.courseType) { | |||
@@ -381,6 +405,8 @@ class LearnExamActivity : BaseActivityVM<ActivityLearnExamBinding, LearnExamView | |||
else -> vm.chooseResult(-1) | |||
} | |||
} | |||
//初始获取第一条数据 | |||
vm.loadFirst() | |||
} | |||
@@ -536,9 +562,10 @@ class LearnExamActivity : BaseActivityVM<ActivityLearnExamBinding, LearnExamView | |||
//口语的音频,有问题,与选项 直接获取其tag获取音频 | |||
currentPlayView?.cancelAnimation() | |||
if (view is LottieAnimationView && view.visibility == View.VISIBLE) currentPlayView = view | |||
when{ | |||
when { | |||
//词汇量测试 | |||
vm.intentData.examType == AppConstants.TEST_TYPE_NORMAL -> AudioCache.getVocabularyVoice(it.word_id, vm.defaultSoundWay) | |||
vm.intentData.examType == AppConstants.TEST_TYPE_NORMAL -> AudioCache.getVocabularyVoice(it.word_id, | |||
vm.defaultSoundWay) | |||
//口语 | |||
isSpokenTotalTest() -> AudioCache.getSpokenVoice(view.tag as String) | |||
//测试 | |||
@@ -607,12 +634,13 @@ class LearnExamActivity : BaseActivityVM<ActivityLearnExamBinding, LearnExamView | |||
/** 测试完成 : 弹窗显示 */ | |||
private fun testOver() { | |||
if (vm.intentData.examType == AppConstants.TEST_TYPE_NORMAL){ | |||
AudioCache.initAudioLiveData().removeObservers(this) | |||
if (vm.intentData.examType == AppConstants.TEST_TYPE_NORMAL) { | |||
vm.intentData.vocabularyItem?.let { | |||
val createTime = DateUtil.format(System.currentTimeMillis(), DateUtil.FORMAT_1) | |||
VocabularyDialog.newInstance(it.level,createTime,vm.scoreValue,vm.vocabularyCoverange).apply { | |||
VocabularyDialog.newInstance(it.level, createTime, vm.scoreValue, vm.vocabularyCoverange).apply { | |||
onDialogListener = { action, dialog -> | |||
when(action){ | |||
when (action) { | |||
//完成 | |||
AppConstants.DIALOG_OVER -> { | |||
dialog.dismissAllowingStateLoss() | |||
@@ -626,7 +654,7 @@ class LearnExamActivity : BaseActivityVM<ActivityLearnExamBinding, LearnExamView | |||
} | |||
} | |||
} | |||
}.show(supportFragmentManager,"vocabulary") | |||
}.show(supportFragmentManager, "vocabulary") | |||
} | |||
return | |||
} | |||
@@ -779,7 +807,7 @@ class LearnExamActivity : BaseActivityVM<ActivityLearnExamBinding, LearnExamView | |||
}.show(supportFragmentManager, javaClass.name) | |||
//如果是学前总测试完成,则标记本课程为已学课程 | |||
if (vm.intentData.examType == AppConstants.TEST_TYPE_BEFORE_TOTAL){ | |||
if (vm.intentData.examType == AppConstants.TEST_TYPE_BEFORE_TOTAL) { | |||
vm.intentData.let { | |||
DataRepository.setLearnedCourseID(it.subjectId.toLong(), it.coursePackId, it.courseId) | |||
} |
@@ -169,6 +169,9 @@ class LearnExamViewModel : LearnBaseViewModel() { | |||
} | |||
} | |||
} | |||
var isLifecyclerPause = false | |||
/** onResume | |||
* isAllOver = true 结束了,不处理了 | |||
* 开启总计时 | |||
@@ -192,6 +195,7 @@ class LearnExamViewModel : LearnBaseViewModel() { | |||
/** onPause时,停止总计时 标记进入后台 如果弹窗显示,就只需要关闭总计时就可以了,否则关闭所有计时 */ | |||
override fun onPause(owner : LifecycleOwner) { | |||
super.onPause(owner) | |||
DictionaryFloatingWindowManager.getInstance().hide() | |||
isInBackground = true | |||
//测试完成,直接返回,已经停止计时了 | |||
if (isAllOver) return | |||
@@ -204,13 +208,8 @@ class LearnExamViewModel : LearnBaseViewModel() { | |||
mHandler.removeCallbacks(currentCountingTimeRunnable) | |||
} | |||
} | |||
DictionaryFloatingWindowManager.getInstance().hide() | |||
} | |||
override fun onDestroy(owner : LifecycleOwner) { | |||
super.onDestroy(owner) | |||
MPManager.removePlayListener() | |||
} | |||
/** 停止获取下一题 */ | |||
fun pauseToNext() { |
@@ -349,7 +349,6 @@ class LearnWordActivity : BaseActivityVM<ActivityLearnWordBinding, LearnWordView | |||
override fun loadData() { | |||
vm.loadNext() | |||
//如果自动播放,监听信息 | |||
if (vm.learnData.isAutoPlay) { | |||
LiveEventBus.get<Int>("auto_play").observe(this) { | |||
@@ -366,7 +365,7 @@ class LearnWordActivity : BaseActivityVM<ActivityLearnWordBinding, LearnWordView | |||
//自动播放的单词音频数据 | |||
if (vm.learnData.isAutoPlay) { | |||
it?.run { | |||
MPManager.play(it, listener = impListener) | |||
MPManager.play(it, listener = if(vm.isAutoPlaying) impListener else null) | |||
} ?: let { | |||
showToast("未找到发音文件") | |||
//获取下一条 | |||
@@ -420,6 +419,7 @@ class LearnWordActivity : BaseActivityVM<ActivityLearnWordBinding, LearnWordView | |||
//上传数据后的处理 | |||
vm.saveDataLiveData.observe(this) { | |||
AudioCache.initAudioLiveData().removeObservers(this@LearnWordActivity) | |||
when { | |||
//学习完成的保存数据后显示学习完成弹窗 | |||
it -> showLearnOverDialog() | |||
@@ -427,6 +427,7 @@ class LearnWordActivity : BaseActivityVM<ActivityLearnWordBinding, LearnWordView | |||
else -> finish() | |||
} | |||
} | |||
vm.loadNext() | |||
} | |||
/**新数据到来,自动播放界面显示*/ |
@@ -6,6 +6,7 @@ import com.jeremyliao.liveeventbus.LiveEventBus | |||
import com.suliang.common.extension.createRandomNewChar | |||
import com.suliang.common.extension.diskIo2Main | |||
import com.suliang.common.util.DateUtil | |||
import com.suliang.common.util.media.MPManager | |||
import com.xkl.cdl.data.AppConstants | |||
import com.xkl.cdl.data.DataTransferHolder | |||
import com.xkl.cdl.data.bean.LearnWord | |||
@@ -398,10 +399,18 @@ class LearnWordViewModel : LearnBaseViewModel() { | |||
}) | |||
} | |||
//自动播放时是否是生命周期影响的暂停,恢复后自动播放 | |||
private var isAutoPlayWithLifecyclerPause = false | |||
override fun onResume(owner : LifecycleOwner) { | |||
super.onResume(owner) | |||
if (!isAllOver) { | |||
//自动播放则手动恢复 | |||
if (learnData.isAutoPlay && isAutoPlayWithLifecyclerPause){ | |||
isAutoPlayWithLifecyclerPause = false | |||
isAutoPlaying = true | |||
//继续播放 | |||
LiveEventBus.get<Int>("auto_play").post(0) | |||
} | |||
if (!isShowBackDialog || (learnData.isAutoPlay && isAutoPlaying)) { | |||
executeLearnValidTime() | |||
} | |||
@@ -417,6 +426,12 @@ class LearnWordViewModel : LearnBaseViewModel() { | |||
super.onPause(owner) | |||
stopTotalCountTing() | |||
DictionaryFloatingWindowManager.getInstance().hide() | |||
//如果是自动播放未完成,且在播放中,手动暂停播放 | |||
if (!isAllOver && learnData.isAutoPlay ){ | |||
isAutoPlayWithLifecyclerPause = isAutoPlaying | |||
isAutoPlaying = false | |||
} | |||
MPManager.removePlayListener() | |||
} | |||
/** |
@@ -80,7 +80,10 @@ class CourseMainFragment : BaseFragmentVM<FragmentCourseMainBinding, CourseMainF | |||
} | |||
} | |||
//学后总测结束传递数据回来。更新数据 | |||
AppConstants.DATA_COURSE_AFTER_TEST_OVER -> vm.courseDetail.st_after = it.scoreValue.toDouble() //学后总分 | |||
AppConstants.DATA_COURSE_AFTER_TEST_OVER -> { | |||
vm.courseDetail.st_after = it.scoreValue.toDouble() | |||
changeFragment(2) | |||
} //学后总分 | |||
//学后总测试结束动作: 再测一次 | |||
AppConstants.ACTION_COURSE_TEST_AFTER_TOTAL_AGAIN -> { |
@@ -110,9 +110,9 @@ class CourseTotalTestFragment : BaseFragmentVM<FragmentCourseTotalTestBinding, C | |||
} | |||
else -> { //有成绩,直接完成 | |||
if (it >= AppConstants.TEST_SCORE_LEVEL_2) { | |||
tvMainTip.setHtml("你已完成学后总测试,上次得分: <font color=\'#5082E6\'>$it</font>") | |||
tvMainTip.setHtml("你已完成学后总测试,上次得分: <font color=\'#5082E6\'>${it.toInt()}</font>") | |||
} else { | |||
tvMainTip.setHtml("你已完成学后总测试,上次得分: <font color=\'#F26255\'>$it</font>") | |||
tvMainTip.setHtml("你已完成学后总测试,上次得分: <font color=\'#F26255\'>${it.toInt()}</font>") | |||
} | |||
tvTips.visibility = View.VISIBLE | |||
tvCountTip.visibility = View.GONE |
@@ -66,7 +66,7 @@ class MemoTestActivity : BaseActivityVM<ActivityMemoTestBinding, MemoTestViewMod | |||
binding.tvTest.click { | |||
val count = when (binding.rgNumber.checkedRadioButtonId) { | |||
R.id.rb_smaller -> 20 | |||
R.id.rb_normal -> 20 | |||
R.id.rb_normal -> 50 | |||
R.id.rb_more -> 100 | |||
else -> 0 | |||
} |
@@ -321,7 +321,7 @@ class CourseStatisticsDetailActivity : BaseActivityVM<ActivityCourseStatisticsDe | |||
binding.rankingEfficient.setProgressNumber(e.toFloat()) | |||
binding.tvEfficient.text = "${NumberUtils.formatHalfUp(e, "0.##")}%" | |||
binding.tvEfficientState.apply { | |||
val instance = lastE - e | |||
val instance = e - lastE | |||
when { | |||
//增长 | |||
instance >= 0 -> { |
@@ -136,7 +136,7 @@ open class StatisticsTimeTopFragmentViewModel : BaseViewModel() { | |||
val result = TimeStatisticItem().apply { | |||
backGround = R.drawable.shape_rounder_4_green_a5 | |||
name = "已学课程" | |||
unit = "/${CourseManager.getTotalCourseSize()}个" | |||
unit = "/${CourseManager.getTotalCourseSize(projectId)}个" | |||
time = "${statistics.sc}" | |||
initIncr(this,statistics.scIncr.toDouble()) | |||
//增量 |