fixed a bug
This commit is contained in:
@@ -85,7 +85,16 @@ internal class CourseCatalogController(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun useCourseInPlace(video: TrainingVideoSummary) {
|
||||||
|
// Keep the current module (e.g. Train) while syncing course selection.
|
||||||
|
if (screenState.courseEnrollment[video.videoHash] != true) {
|
||||||
|
enrollCourse(video)
|
||||||
|
}
|
||||||
|
loadRemoteVideo(video)
|
||||||
|
}
|
||||||
|
|
||||||
fun loadRemoteVideo(video: TrainingVideoSummary) {
|
fun loadRemoteVideo(video: TrainingVideoSummary) {
|
||||||
|
screenState.currentCourse = video
|
||||||
screenState.activeItemId = video.videoHash
|
screenState.activeItemId = video.videoHash
|
||||||
host.onPlayerLoading(video)
|
host.onPlayerLoading(video)
|
||||||
host.onCatalogChanged()
|
host.onCatalogChanged()
|
||||||
|
|||||||
@@ -250,7 +250,7 @@ class MainActivity : Activity() {
|
|||||||
sdk.config.userToken = null
|
sdk.config.userToken = null
|
||||||
screenState.clearCourse()
|
screenState.clearCourse()
|
||||||
controller.pause()
|
controller.pause()
|
||||||
screenState.activeModule = Module.TRAIN
|
screenState.activeModule = Module.COURSE
|
||||||
setRootView()
|
setRootView()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -431,12 +431,8 @@ class MainActivity : Activity() {
|
|||||||
catalogController.selectCourse(video)
|
catalogController.selectCourse(video)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onTrainCatalogVideoClick(video: TrainingVideoSummary, enrolled: Boolean) {
|
override fun onTrainCatalogVideoClick(video: TrainingVideoSummary) {
|
||||||
if (enrolled) {
|
catalogController.useCourseInPlace(video)
|
||||||
catalogController.loadRemoteVideo(video)
|
|
||||||
} else {
|
|
||||||
catalogController.enrollCourse(video)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onLogout() = logout()
|
override fun onLogout() = logout()
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ internal interface TrainScreenActions {
|
|||||||
fun onSeekStart()
|
fun onSeekStart()
|
||||||
fun onSeekStop(progress: Int)
|
fun onSeekStop(progress: Int)
|
||||||
fun onContinuousPlaybackChanged(enabled: Boolean)
|
fun onContinuousPlaybackChanged(enabled: Boolean)
|
||||||
fun onTrainCatalogVideoClick(video: TrainingVideoSummary, enrolled: Boolean)
|
fun onTrainCatalogVideoClick(video: TrainingVideoSummary)
|
||||||
}
|
}
|
||||||
|
|
||||||
internal interface TestScreenActions {
|
internal interface TestScreenActions {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ internal class TrainingScreenState {
|
|||||||
var catalogVideos: List<TrainingVideoSummary> = emptyList()
|
var catalogVideos: List<TrainingVideoSummary> = emptyList()
|
||||||
val courseEnrollment = mutableMapOf<String, Boolean>()
|
val courseEnrollment = mutableMapOf<String, Boolean>()
|
||||||
var catalogStatus = "正在同步"
|
var catalogStatus = "正在同步"
|
||||||
var activeModule = Module.TRAIN
|
var activeModule = Module.COURSE
|
||||||
var currentCourse: TrainingVideoSummary? = null
|
var currentCourse: TrainingVideoSummary? = null
|
||||||
var continuousPlaybackEnabled = false
|
var continuousPlaybackEnabled = false
|
||||||
var testSubtitleVisible = false
|
var testSubtitleVisible = false
|
||||||
|
|||||||
@@ -45,9 +45,9 @@ internal class TrainScreen(
|
|||||||
meta = if (enrolled) {
|
meta = if (enrolled) {
|
||||||
"已选修 · ${video.sentenceCount} 句"
|
"已选修 · ${video.sentenceCount} 句"
|
||||||
} else {
|
} else {
|
||||||
"未选修 · 点击选修"
|
"未选修 · 点击选修并进入"
|
||||||
},
|
},
|
||||||
onClick = { actions.onTrainCatalogVideoClick(video, enrolled) },
|
onClick = { actions.onTrainCatalogVideoClick(video) },
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user