Browse Source

修改课程排序、视频播放释放

master
suliang 1 year ago
parent
commit
60da80bfbb

+ 12
- 20
app/src/main/java/com/xkl/cdl/data/bean/course/CoursePack.kt View File

@@ -1,5 +1,7 @@
package com.xkl.cdl.data.bean.course

import android.os.Parcel
import android.os.Parcelable
import androidx.databinding.BaseObservable
import androidx.databinding.Bindable
import com.xkl.cdl.BR
@@ -29,6 +31,10 @@ data class CoursePack(
var downLoadZipUrl : String = "" //压缩包下载地址
var isDown = false //是否下载
//阶段id
var stageId = 0
//年级id
var gradeId = 0
//在CourseManger中的subjectWithCoursePackMap对应subject下的list中所在的位置
@@ -50,37 +56,23 @@ data class CoursePack(
field = value
notifyPropertyChanged(BR.reviewNumber)
}
override fun equals(other : Any?) : Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false
other as CoursePack
if (coursePackId != other.coursePackId) return false
if (coursePackName != other.coursePackName) return false
if (cover != other.cover) return false
if (summary != other.summary) return false
if (subjectId != other.subjectId) return false
if (coursePackType != other.coursePackType) return false
if (inCoursePackPosition != other.inCoursePackPosition) return false
if (childrenCourses != other.childrenCourses) return false
if (learnProgress != other.learnProgress) return false
return true
}
override fun hashCode() : Int {
var result = coursePackId.hashCode()
result = 31 * result + coursePackName.hashCode()
result = 31 * result + cover.hashCode()
result = 31 * result + summary.hashCode()
result = 31 * result + subjectId
result = 31 * result + coursePackType
result = 31 * result + cover.hashCode()
result = 31 * result + downLoadZipUrl.hashCode()
result = 31 * result + isDown.hashCode()
result = 31 * result + stageId
result = 31 * result + gradeId
result = 31 * result + inCoursePackPosition
result = 31 * result + childrenCourses.hashCode()
result = 31 * result + learnProgress.hashCode()
return result
}
}

+ 3
- 0
app/src/main/java/com/xkl/cdl/module/learn/LearnCVideoActivity.kt View File

@@ -358,6 +358,9 @@ class LearnCVideoActivity : BaseActivityVM<ActivityLearnCvideoBinding, LearnCVid
}
override fun onDestroy() {
mPlayer?.setCompletionListener(null)
mPlayer?.setOnStopListener(null)
mPlayer?.setPlayingListener(null)
mPlayer?.release()
super.onDestroy()
}

+ 23
- 3
app/src/main/java/com/xkl/cdl/module/splash/SplashViewModel.kt View File

@@ -1,6 +1,5 @@
package com.xkl.cdl.module.splash

import android.os.Handler
import androidx.lifecycle.MutableLiveData
import com.suliang.common.base.viewmodel.BaseViewModel
import com.suliang.common.util.LogUtil
@@ -21,6 +20,7 @@ import okhttp3.MediaType.Companion.toMediaType
import okhttp3.Request
import okhttp3.RequestBody.Companion.toRequestBody
import okhttp3.Response
import org.json.JSONException
import org.json.JSONObject
import java.io.*
import java.util.zip.ZipEntry
@@ -113,7 +113,7 @@ class SplashViewModel : BaseViewModel() {
})
}
@Throws(JSONException::class)
private fun decodeBinderCourseJson(json : String) : MutableList<CoursePack>? {
if (json.isEmpty()) return null
val result = mutableListOf<CoursePack>()
@@ -131,6 +131,9 @@ class SplashViewModel : BaseViewModel() {
//定义课程包
val coursePack = CoursePack(coursePackId, coursePackName, summary, subject_id, coursePackType)
coursePack.gradeId = cp.getInt("grade_id")
coursePack.stageId = cp.getInt("stage_id")
//定义课程列表集合
val courseList = mutableListOf<Course>()
val courseMap = mutableMapOf<Int, Course>() // key : typeId value : Course
@@ -169,6 +172,16 @@ class SplashViewModel : BaseViewModel() {
coursePack.childrenCourses = courseList
result.add(coursePack)
}
//排序
result.sortWith { o1, o2 ->
var compareResult = o2.stageId.compareTo(o1.stageId)
if (compareResult == 0) {
compareResult = o2.gradeId.compareTo(o1.gradeId)
}
compareResult
}
return result
}
@@ -285,6 +298,11 @@ class SplashViewModel : BaseViewModel() {
}
}
}
//课程排序
// englishCoursePack.sortBy {
// it.
// }
//
CourseManager.subjectWithCoursePackMap[AppConstants.SUBJECT_ENGLISH] = englishCoursePack.toList()
CourseManager.subjectWithCoursePackMap[AppConstants.SUBJECT_CHINESE] = chineseCoursePack.toList()
mergeCoursePackResult.postValue(true)
@@ -479,10 +497,12 @@ class SplashViewModel : BaseViewModel() {
it.flush()
}
}
zipInputStream?.close()
outPut.forEach {
it.flush()
it.close()
}
zipInputStream?.close()
}
}
}

Loading…
Cancel
Save