作者 杨谦

1.课程相关完善

2.部分我的部分
3.首页接口等
正在显示 50 个修改的文件 包含 1149 行增加292 行删除
... ... @@ -191,6 +191,9 @@
<activity
android:name=".ui.view.home.activity.course.LocationSignActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|screenLayout|smallestScreenSize|uiMode" />
<activity android:name=".ui.view.home.activity.course.CoursePractiseActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|screenLayout|smallestScreenSize|uiMode"/>
</application>
</manifest>
\ No newline at end of file
... ...
... ... @@ -3,9 +3,9 @@ package com.br_technology.securitytrain_master.base.network.api
import com.br_technology.securitytrain_master.base.network.response.*
import com.br_technology.securitytrain_master.ui.bean.*
import com.br_technology.securitytrain_master.ui.view.bank.bean.PracticeBean
import com.br_technology.securitytrain_master.ui.view.bank.bean.StartItemBean
import com.br_technology.securitytrain_master.ui.view.bank.bean.SubjectData
import com.br_technology.securitytrain_master.ui.view.bank.bean.TestSubject
import com.br_technology.securitytrain_master.ui.view.bank.bean.StartItemBean
import io.reactivex.rxjava3.core.Observable
import retrofit2.http.Field
import retrofit2.http.FormUrlEncoded
... ... @@ -124,54 +124,6 @@ interface AllItemApi : ApiService {
): Observable<BaseResponse<ChallengeInfo>>
/**
* 提交答题(某一题)
* @param user_item_id 答题记录ID
* @param item_id 题目id
* @param answer 答案
*/
@FormUrlEncoded
@POST("/api/item/item_sub_single")
fun subSingle(
@Field("user_item_id") user_item_id: Int,
@Field("item_id") item_id: Int,
@Field("answer") answer: String
): Observable<BaseResponse<SubSingle>>
/**
* 提交答题
* @param item_id 题目ID
* @param answer 答题结果[{'id':1,'answer':'A'}]
*/
@FormUrlEncoded
@POST("/api/item/item_sub_single")
fun subSingle(
@Field("item_id") item_id: Int,
@Field("answer") answer: String
): Observable<BaseResponse<Void>>
/**
* 提交答题
* @param item_id 题目ID
* @param answer 答题结果[{'id':1,'answer':'A'}]
*/
@FormUrlEncoded
@POST("/api/item/item_sub")
fun subAnswer(
@Field("item_id") item_id: Int,
@Field("answer") answer: String
): Observable<BaseResponse<SubResult>>
/**
* 交卷
* @param user_item_id 题目id
*/
@FormUrlEncoded
@POST("/api/item/item_sub_paper")
fun subPaper(
@Field("user_item_id") user_item_id: Int
): Observable<BaseResponse<SubResult>>
/**
* 错题列表
* @param type 类型1=单选题2=多选题3=判断题
* @param page 页数
... ...
package com.br_technology.securitytrain_master.base.network.api
import com.br_technology.securitytrain_master.base.network.response.*
import com.br_technology.securitytrain_master.ui.bean.FavoriteData
import com.br_technology.securitytrain_master.ui.bean.MaterialDetail
import com.br_technology.securitytrain_master.ui.bean.UploadFileData
import com.br_technology.securitytrain_master.ui.bean.*
import com.br_technology.securitytrain_master.ui.view.bank.bean.PracticeBean
import com.br_technology.securitytrain_master.ui.view.bank.bean.RankListBean
import com.br_technology.securitytrain_master.ui.view.home.bean.*
... ... @@ -266,7 +264,6 @@ interface ApiService {
@Field("id") id: Int
): Observable<BaseResponse<CommonDetail<MaterialDetail>>>
/**
* 收藏
*/
... ... @@ -296,4 +293,40 @@ interface ApiService {
@Field("page") page: Int,
@Field("page_num") page_num: String
): Observable<BaseResponse<CommonDataList<CommonPage<FavoriteData>>>>
/**
* 提交答题(某一题)
* @param user_item_id 答题记录ID
* @param item_id 题目id
* @param answer 答案
*/
@FormUrlEncoded
@POST("/api/item/item_sub_single")
fun subSingle(
@Field("user_item_id") user_item_id: Int,
@Field("item_id") item_id: Int,
@Field("answer") answer: String
): Observable<BaseResponse<SubSingle>>
/**
* 提交答题
* @param item_id 题目ID
* @param answer 答题结果[{'id':1,'answer':'A'}]
*/
@FormUrlEncoded
@POST("/api/item/item_sub")
fun subAnswer(
@Field("item_id") item_id: Int,
@Field("answer") answer: String
): Observable<BaseResponse<SubResult>>
/**
* 交卷
* @param user_item_id 题目id
*/
@FormUrlEncoded
@POST("/api/item/item_sub_paper")
fun subPaper(
@Field("user_item_id") user_item_id: Int
): Observable<BaseResponse<SubResult>>
}
\ No newline at end of file
... ...
package com.br_technology.securitytrain_master.base.network.api
import com.br_technology.securitytrain_master.base.network.response.*
import com.br_technology.securitytrain_master.ui.bean.*
import com.br_technology.securitytrain_master.ui.view.bank.bean.SubjectData
import com.br_technology.securitytrain_master.base.network.response.BaseResponse
import com.br_technology.securitytrain_master.base.network.response.CommonDetail
import com.br_technology.securitytrain_master.base.network.response.CommonList
import com.br_technology.securitytrain_master.base.network.response.CommonPage
import io.reactivex.rxjava3.core.Observable
import retrofit2.http.Field
import retrofit2.http.FormUrlEncoded
... ... @@ -136,14 +133,12 @@ interface TrainApi : ApiService {
/**
* 成长报告
*/
@FormUrlEncoded
@POST("/api/train/train_report")
fun trainReport(): Observable<BaseResponse<TrainReport>>
fun trainReport(): Observable<BaseResponse<CommonReport<TrainReport>>>
/**
* 课程备份列表
*/
@FormUrlEncoded
@GET("/api/train/train_lesson_list_bak")
fun trainLessonBak(): Observable<BaseResponse<Void>>
}
\ No newline at end of file
... ...
... ... @@ -8,6 +8,7 @@ package com.br_technology.securitytrain_master.base.network.response
open class BaseResponse<T>(var data: T, var code: Int = -1, var msg: String = "")
open class CommonList<T>(var list: List<T>)
open class CommonReport<T>(var report: T)
open class CommonDataList<T>(var list: T)
open class CommonDetail<T>(var detail: T)
open class CommonDetailList<T>(var list: T)
... ...
... ... @@ -57,4 +57,13 @@ class DocRepository(loadState: MutableLiveData<State>) : ApiRepository(loadState
) {
addRequest(docService.getCollectTxtLessonList(page, "10"), liveData)
}
fun collect(
type: String,
favorite_id: String,
liveData: MutableLiveData<BaseResponse<Void>>
) {
addRequest(lessonService.collect(type, favorite_id), liveData)
}
}
\ No newline at end of file
... ...
... ... @@ -2,13 +2,15 @@ package com.br_technology.securitytrain_master.base.repository
import androidx.lifecycle.MutableLiveData
import com.br_technology.securitytrain_master.base.common.State
import com.br_technology.securitytrain_master.base.network.response.*
import com.br_technology.securitytrain_master.base.repository.ApiRepository
import com.br_technology.securitytrain_master.base.network.response.BaseResponse
import com.br_technology.securitytrain_master.base.network.response.CommonDetailList
import com.br_technology.securitytrain_master.base.network.response.CommonList
import com.br_technology.securitytrain_master.base.network.response.CommonPage
import com.br_technology.securitytrain_master.ui.bean.*
import com.br_technology.securitytrain_master.ui.view.bank.bean.PracticeBean
import com.br_technology.securitytrain_master.ui.view.bank.bean.StartItemBean
import com.br_technology.securitytrain_master.ui.view.bank.bean.SubjectData
import com.br_technology.securitytrain_master.ui.view.bank.bean.TestSubject
import com.br_technology.securitytrain_master.ui.view.bank.bean.StartItemBean
/**
* Author by YSir
... ... @@ -100,15 +102,6 @@ class ItemRepository(loadState: MutableLiveData<State>) : ApiRepository(loadStat
addRequest(itemService.subSingle(user_item_id, item_id, answer), liveData)
}
//提交答题(某一题)
fun subSingle(
item_id: Int,
answer: String,
liveData: MutableLiveData<BaseResponse<Void>>
) {
addRequest(itemService.subSingle(item_id, answer), liveData)
}
//subAnswer
fun subAnswer(
item_id: Int,
... ...
... ... @@ -2,13 +2,9 @@ package com.br_technology.securitytrain_master.base.repository
import androidx.lifecycle.MutableLiveData
import com.br_technology.securitytrain_master.base.common.State
import com.br_technology.securitytrain_master.base.repository.ApiRepository
import com.br_technology.securitytrain_master.base.network.response.*
import com.br_technology.securitytrain_master.ui.bean.*
import com.br_technology.securitytrain_master.ui.view.bank.bean.SubjectData
import com.br_technology.securitytrain_master.base.network.response.BaseResponse
import com.br_technology.securitytrain_master.base.network.response.CommonDetail
import com.br_technology.securitytrain_master.base.network.response.CommonList
import com.br_technology.securitytrain_master.base.network.response.CommonPage
/**
* Author by YSir
... ... @@ -80,11 +76,35 @@ class TrainRepository(loadState: MutableLiveData<State>) : ApiRepository(loadSta
addRequest(trainService.trainChatRead(train_class_id), liveData)
}
fun trainReport(liveData: MutableLiveData<BaseResponse<TrainReport>>){
fun trainReport(liveData: MutableLiveData<BaseResponse<CommonReport<TrainReport>>>){
addRequest(trainService.trainReport(), liveData)
}
fun trainLessonBak(liveData: MutableLiveData<BaseResponse<Void>>){
addRequest(trainService.trainLessonBak(), liveData)
}
//提交答题(某一题)
fun subSingle(
user_item_id: Int,
item_id: Int,
answer: String,
liveData: MutableLiveData<BaseResponse<SubSingle>>
) {
addRequest(itemService.subSingle(user_item_id, item_id, answer), liveData)
}
//subAnswer
fun subAnswer(
item_id: Int,
answer: String,
liveData: MutableLiveData<BaseResponse<SubResult>>
) {
addRequest(itemService.subAnswer(item_id, answer), liveData)
}
//交卷
fun subPaper(user_item_id: Int, liveData: MutableLiveData<BaseResponse<SubResult>>) {
addRequest(itemService.subPaper(user_item_id), liveData)
}
}
\ No newline at end of file
... ...
... ... @@ -34,12 +34,6 @@ open class OptionArr(
*/
open class SubjectData(
var user_item_id: Int, // 答题id
var type1: Int, // 单选题索引
var type2: Int, // 多选题索引
var type3: Int, // 判断题索引
var type1_num: Int, // 单选题总数
var type2_num: Int, // 多选题总数
var type3_num: Int, // 判断题总数
var over_second: Int, // 答题剩余时间
var list: List<UserSubject>,
var remark: String
... ... @@ -48,24 +42,12 @@ open class SubjectData(
//专项答题
open class SubjectSpecial(
user_item_id: Int, // 答题id
type1: Int, // 单选题索引
type2: Int, // 多选题索引
type3: Int, // 判断题索引
type1_num: Int, // 单选题总数
type2_num: Int, // 多选题总数
type3_num: Int, // 判断题总数
over_second: Int, // 答题剩余时间
list: List<UserSubject>,
remark: String,
var user_answer: String
) : SubjectData(
user_item_id,
type1,
type2,
type3,
type1_num,
type2_num,
type3_num,
over_second,
list,
remark
... ...
... ... @@ -127,39 +127,38 @@ open class TrainDetail(
*/
open class TrainReport(
var user: TrainReportUser,//上报人信息
var create_time_text: String,//var 2021-10-30 09:35", // 答题开始时间
var update_time_text: String,//var 2021-10-30 09:35" // 答题结束时间
var study_list: List<TrainReportStudy>,
var trainclass: TrainReportClass,
// var trainclass: TrainReportClass,
var exam_list: List<TrainReportExam>
)
open class TrainReportUser(
var id: Int,
var nickname: String, // 姓名
var mobile: String,//手机号", // 手机号
var gender: Int, // 性别1=男2=女
// var id: Int,
// var nickname: String, // 姓名
// var mobile: String,//手机号", // 手机号
// var gender: Int, // 性别1=男2=女
var avatar: String,//"https://security.brofirst.cn/uploads/20211030/e777a39142bf8ab8dd3e02b6eb9f9d9f.jpg", // 头像
var score: Int, // 积分
var identity: String, // 身份证号
var user_id: Int,
var createtime: Long, // 建档日期
var class_hours_count: Int, // 培训总学时
var item_count: Int, // 练习题量
var lessons: String, // 结业课程
var is_end: Int, // 是否结业0=否1=是
var class_name: String, // 班级名称
var train_sort_name: String, // 培训类型
var time: String, // 时间
var train_name: String, // 培训单位
var class_hours: Int, // 培训学时
var score: Int
// , // 积分
// var identity: String, // 身份证号
// var user_id: Int,
// var createtime: Long, // 建档日期
// var class_hours_count: Int, // 培训总学时
// var item_count: Int, // 练习题量
// var lessons: String, // 结业课程
// var is_end: Int, // 是否结业0=否1=是
// var class_name: String, // 班级名称
// var train_sort_name: String, // 培训类型
// var time: String, // 时间
// var train_name: String, // 培训单位
// var class_hours: Int, // 培训学时
)
open class TrainStudyTrain(
var id: Int,
var company_id: Int,
var pid: Int,
var train_sort_id: Int,
var train_sort_id: String,
var name: String, // 培训名称
var depart_ids: String,
var pos_ids: String,
... ... @@ -167,7 +166,10 @@ open class TrainStudyTrain(
var plan_num_complete: Int,
var start_time: Long,
var end_time: Long,
var status: String
var status: String,
var trainsort: TrainStudySort,
var update_time_text: String,
var trainclass:TrainClass
)
open class TrainStudySort(
... ... @@ -181,12 +183,11 @@ open class TrainReportStudy(
var id: Int,
var distance: String,
var status: String, // 结业状态0=未结业1=已结业
var view_len: Int,
var view_len: String,
var class_name: String, // 课程名称
var update_time: String, // 时间
var class_hours: Int, // 学时
var train: TrainStudyTrain,
var trainsort: TrainStudySort
var train: TrainStudyTrain
)
open class TrainReportClass(
... ...
... ... @@ -21,6 +21,11 @@ class AnswerSheetActivity : BaseLifeCycleActivity<AnswerSheetViewModel, Activity
ActivityAnswerSheetBinding::inflate
) {
override fun initView() {
super.initView()
val dataResult = intent.getStringExtra("title")
binding.toolBar.setTitle(dataResult ?: "")
}
override fun initData() {
super.initData()
... ... @@ -46,7 +51,7 @@ class AnswerSheetActivity : BaseLifeCycleActivity<AnswerSheetViewModel, Activity
})
// 答题卡适配器
val answerSheetAdapter = AnswerSheetAdapter()
answerSheetAdapter.showCorrect=showCorrect
answerSheetAdapter.showCorrect = showCorrect
val list = dataResult?.toList() as List<String>
sheet.adapter = answerSheetAdapter
answerSheetAdapter.addList(list)
... ...
... ... @@ -6,8 +6,8 @@ import android.view.View
import androidx.activity.result.contract.ActivityResultContracts
import androidx.core.content.ContextCompat
import com.br_technology.securitytrain_master.R
import com.br_technology.securitytrain_master.databinding.ActivityPracticeBinding
import com.br_technology.securitytrain_master.base.common.ConstantType
import com.br_technology.securitytrain_master.databinding.ActivityPracticeBinding
import com.br_technology.securitytrain_master.ui.view.bank.adapter.PracticePaperAdapter
import com.br_technology.securitytrain_master.ui.view.bank.viewmodel.PracticeViewModel
import com.br_technology.securitytrain_master.view.DialogTitle
... ... @@ -58,6 +58,7 @@ class ChallengeActivity :
val intent = Intent(baseContext, AnswerSheetActivity::class.java)
.putStringArrayListExtra("resultData", mPagerAdapter.getArrayList())
.putExtra("showCorrect", mPagerAdapter.showCorrect)
.putExtra("title", binding.toolBar.getTitle())
startForResult.launch(intent)
}
})
... ...
... ... @@ -84,6 +84,7 @@ class ExamDetailActivity :
val intent = Intent(baseContext, AnswerSheetActivity::class.java)
.putStringArrayListExtra("resultData", mPagerAdapter.getArrayList())
.putExtra("showCorrect", mPagerAdapter.showCorrect)
.putExtra("title", binding.toolBar.getTitle())
startForResult.launch(intent)
}
})
... ...
... ... @@ -6,8 +6,8 @@ import android.view.View
import androidx.activity.result.contract.ActivityResultContracts
import androidx.core.content.ContextCompat
import com.br_technology.securitytrain_master.R
import com.br_technology.securitytrain_master.databinding.ActivityPracticeBinding
import com.br_technology.securitytrain_master.base.common.ConstantType
import com.br_technology.securitytrain_master.databinding.ActivityPracticeBinding
import com.br_technology.securitytrain_master.ui.view.bank.adapter.PracticePaperAdapter
import com.br_technology.securitytrain_master.ui.view.bank.viewmodel.PracticeViewModel
import com.br_technology.securitytrain_master.view.DialogDetermine
... ... @@ -81,6 +81,8 @@ class PracticeActivity :
val intent = Intent(this@PracticeActivity, AnswerSheetActivity::class.java)
.putStringArrayListExtra("resultData", mPagerAdapter.getArrayList())
.putExtra("showCorrect", mPagerAdapter.showCorrect)
.putExtra("title", binding.toolBar.getTitle())
startForResult.launch(intent)
}
})
... ...
... ... @@ -6,8 +6,8 @@ import android.view.View
import androidx.activity.result.contract.ActivityResultContracts
import androidx.core.content.ContextCompat
import com.br_technology.securitytrain_master.R
import com.br_technology.securitytrain_master.databinding.ActivityPracticeBinding
import com.br_technology.securitytrain_master.base.common.ConstantType
import com.br_technology.securitytrain_master.databinding.ActivityPracticeBinding
import com.br_technology.securitytrain_master.ui.view.bank.adapter.PracticePaperAdapter
import com.br_technology.securitytrain_master.ui.view.bank.viewmodel.PracticeViewModel
import com.br_technology.securitytrain_master.view.DialogTitle
... ... @@ -82,6 +82,7 @@ class QuestionsActivity :
val intent = Intent(this@QuestionsActivity, AnswerSheetActivity::class.java)
.putStringArrayListExtra("resultData", mPagerAdapter.getArrayList())
.putExtra("showCorrect", mPagerAdapter.showCorrect)
.putExtra("title", binding.toolBar.getTitle())
startForResult.launch(intent)
}
})
... ... @@ -193,4 +194,11 @@ class QuestionsActivity :
}
}
override fun onDestroy() {
if (titleDialog.isShowing) {
titleDialog.dismiss()
}
super.onDestroy()
}
}
\ No newline at end of file
... ...
... ... @@ -8,7 +8,6 @@ import android.text.SpannableString
import android.text.Spanned
import android.text.style.AbsoluteSizeSpan
import android.text.style.ForegroundColorSpan
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
... ... @@ -16,16 +15,17 @@ import android.view.WindowManager
import android.widget.TextView
import androidx.core.content.ContextCompat
import com.br_technology.securitytrain_master.R
import com.br_technology.securitytrain_master.base.common.ConstantType
import com.br_technology.securitytrain_master.base.view.BaseAdapter
import com.br_technology.securitytrain_master.base.view.BaseViewHolder
import com.br_technology.securitytrain_master.databinding.AdapterContentPracticeItemBinding
import com.br_technology.securitytrain_master.databinding.AdapterPictureBinding
import com.br_technology.securitytrain_master.databinding.AdapterTopicBinding
import com.br_technology.securitytrain_master.expand.dp2px
import com.br_technology.securitytrain_master.base.common.ConstantType
import com.br_technology.securitytrain_master.ui.bean.Answer
import com.br_technology.securitytrain_master.ui.view.bank.bean.OptionArr
import com.br_technology.securitytrain_master.ui.view.bank.bean.TestSubject
import com.br_technology.securitytrain_master.ui.view.bank.bean.UserSubject
import com.br_technology.securitytrain_master.util.GlideEnginePic
import com.br_technology.securitytrain_master.view.listener.OnItemClickListener
import com.br_technology.securitytrain_master.view.listener.OnItemListener
... ... @@ -374,6 +374,192 @@ class PracticePaperAdapter(private val isShowPosition: Boolean = true) :
}
class CourseTestPaperAdapter(private val isShowPosition: Boolean = true):
BaseAdapter<UserSubject, AdapterContentPracticeItemBinding>() {
// 是否显示正确答案
var showCorrect = false
var selectResultData = HashMap<Int, List<Int>>()
override fun getViewBinding(
context: Context,
parent: ViewGroup,
viewType: Int,
from: LayoutInflater
): AdapterContentPracticeItemBinding {
return AdapterContentPracticeItemBinding.inflate(from, parent, false)
}
@SuppressLint("SetTextI18n")
override fun onBind(
holder: AdapterContentPracticeItemBinding,
index: Int,
data: UserSubject
) {
val value = if (isShowPosition) {
"(${index + 1}/${itemCount})${data.title}${ConstantType.getType(data.type)}"
} else {
"${data.title}${ConstantType.getType(data.type)}"
}
val span = SpannableString(value)
span.setSpan(
ForegroundColorSpan(Color.parseColor("#C8C9CC")),
value.length - 4,
value.length,
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
)
span.setSpan(
AbsoluteSizeSpan(14.dp2px()),
value.length - 4,
value.length,
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
)
holder.topic.text = span
val adapterChild = TopicAdapter()
adapterChild.addList(data.options_arr)
holder.topicRecycler.adapter = adapterChild
holder.txtCorrect.text = "正确答案:${data.correct}"
holder.txtAnalysis.text = "解析:${data.remark}"
holder.contentAnalysis.visibility = if (showCorrect) View.VISIBLE else View.GONE
adapterChild.let {
val type = data.type.toInt()
it.type = type
it.showCorrect = showCorrect
if (selectResultData.containsKey(index)) {
selectResultData[index]?.let { data ->
if (data.isNotEmpty()) {
it.mSelectIndex = data as MutableList<Int>
}
}
}
it.setItemClickListener(object : OnItemListener {
override fun onItemClick(position: Int) {
if (type == 1 || type == 3) {
if (it.mSelectIndex.isEmpty()) {
it.mSelectIndex.add(position)
} else {
it.mSelectIndex[0] = position
}
it.notifyDataSetChanged()
} else {
it.itemClick(position)
}
selectResultData[index] = it.mSelectIndex
}
})
}
}
override fun addList(t: List<UserSubject>) {
super.addList(t)
for (data in getData()) {
val position = getData().indexOf(data)
selectResultData[position] = listOf()
}
}
private fun getResultData(): ArrayList<List<Int>> {
val data = ArrayList<List<Int>>()
val result = selectResultData.keys
val dataKey = mutableListOf<Int>()
for (item in result) {
dataKey.add(item)
}
dataKey.sort()
for (index in dataKey) {
selectResultData[index]?.let {
data.add(it)
}
}
return data
}
fun getAnswer(): ArrayList<Answer> {
val data = ArrayList<Answer>()
val list = getResultData()
val listSubject = getData()
for (res in list.indices) {
val pos = list[res]
val ppp = listSubject[res]
data.add(Answer(ppp.id, getAnswer(ppp.options_arr, pos)))
}
return data
}
fun getAnswer(optionArr: List<OptionArr>, data: List<Int>): String {
var str = ""
if (data.isNotEmpty()) {
for (res in data) {
if (res < optionArr.size) {
str = str + optionArr[res].option_name + ","
}
}
}
return str.substringBeforeLast(",");
}
fun getCount(): Int {
var count = 0
for (data in selectResultData) {
if (data.value.isNotEmpty()) {
count++
}
}
return count
}
fun getArrayList(): ArrayList<String> {
val list = ArrayList<String>()
val dataList = getResultData()
for (data in getData()) {
val position = getData().indexOf(data)
if (dataList[position].isEmpty()) {
list.add("")
} else {
val element = if (isTrue(data, dataList[position], data.options_arr)
) "1" else "0"
list.add(element)
}
}
return list
}
private fun isTrue(
testSubject: UserSubject,
mSelectIndex: List<Int>,
optionArr: List<OptionArr>
): Boolean {
var bool = false
val type = testSubject.type.toInt()
if (type == 1 || type == 3) {
bool = if (mSelectIndex.isNotEmpty()) {
optionArr[mSelectIndex[0]].is_correct == 1
} else {
false
}
}
if (type == 2) {
var count = 0
var dataCount = 0
for (item in optionArr) {
val position = optionArr.indexOf(item)
if (item.is_correct == 1) {
if (mSelectIndex.contains(position)) {
count++
}
dataCount++;
}
}
bool = count == dataCount && mSelectIndex.size == count
}
return bool
}
}
class PictureAdapter(context: Context) : BaseAdapter<String, AdapterPictureBinding>() {
private val options: RequestOptions
... ...
... ... @@ -58,14 +58,12 @@ class BankFragment :
startActivity(LeaderboardActivity::class.java)
}
// 练习题列表
practiceAdapter = PracticeAdapter(R.layout.adapter_practice, practiceList)
practice.adapter = practiceAdapter
practice.layoutManager = LinearLayoutManager(activity)
practiceAdapter?.setOnItemClickListener { _, _, position ->
activity?.startActivity(
Intent(
activity,
... ...
package com.br_technology.securitytrain_master.ui.view.home.activity.course
import com.br_technology.securitytrain_master.base.common.ConstantParamKey
import com.br_technology.securitytrain_master.databinding.ActivityPracticeBinding
import com.br_technology.securitytrain_master.ui.bean.CourseParam
import com.br_technology.securitytrain_master.ui.view.home.viewmodel.CoursePracticeViewModel
import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleActivity
/**
* Author by YSir
* Date on 2022/1/23.
* description
* PS: Not easy to write code, please indicate.
*/
/**
* 课程练习详情
*/
class CourseExamActivity :
BaseLifeCycleActivity<CoursePracticeViewModel, ActivityPracticeBinding>(ActivityPracticeBinding::inflate) {
override fun initDataObserver() {
}
private var courseBean: CourseParam? = null
override fun initData() {
super.initData()
courseBean = intent.getParcelableExtra(ConstantParamKey.COURSE_BEAN)
courseBean?.let {
mViewModel.startExam(it.mTrainClassId.toInt())
}
}
}
\ No newline at end of file
... ...
package com.br_technology.securitytrain_master.ui.view.home.activity.course
import android.app.Activity
import android.content.Intent
import android.view.View
import androidx.activity.result.contract.ActivityResultContracts
import androidx.core.content.ContextCompat
import com.br_technology.securitytrain_master.R
import com.br_technology.securitytrain_master.base.common.ConstantParamKey
import com.br_technology.securitytrain_master.databinding.ActivityPracticeBinding
import com.br_technology.securitytrain_master.ui.bean.CourseParam
import com.br_technology.securitytrain_master.ui.view.bank.activity.AnswerSheetActivity
import com.br_technology.securitytrain_master.ui.view.bank.adapter.CourseTestPaperAdapter
import com.br_technology.securitytrain_master.ui.view.home.viewmodel.CoursePracticeViewModel
import com.br_technology.securitytrain_master.view.DialogTitle
import com.br_technology.securitytrain_master.view.listener.DialogListener
import com.br_technology.securitytrain_master.view.listener.ToolBarClickListener
import com.luck.picture.lib.tools.ToastUtils
import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleActivity
/**
* Author by YSir
* Date on 2022/1/23.
* description
* PS: Not easy to write code, please indicate.
*/
/**
* 课程练习详情
*/
class CoursePractiseActivity :
BaseLifeCycleActivity<CoursePracticeViewModel, ActivityPracticeBinding>(ActivityPracticeBinding::inflate) {
private var courseBean: CourseParam? = null
private val mPagerAdapter = CourseTestPaperAdapter()
private var userItemId = 0
private var isFinish = false
private val titleDialog by lazy {
DialogTitle(this)
}
private val startForResult =
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
if (result.resultCode == Activity.RESULT_OK) {
//页面返回值
val data = result.data?.getIntExtra("position", 0)
if (data != null) {
binding.previous.visibility = View.VISIBLE
binding.finishJob.visibility = View.GONE
binding.next.visibility = View.VISIBLE
if (data == 0) {
binding.previous.visibility = View.GONE
binding.finishJob.visibility = View.GONE
binding.next.visibility = View.VISIBLE
}
if (data == mPagerAdapter.itemCount - 1) {
binding.previous.visibility = View.VISIBLE
binding.finishJob.visibility = View.VISIBLE
binding.next.visibility = View.GONE
}
if (data in 0 until mPagerAdapter.itemCount) {
binding.practicePager.currentItem = data
}
}
}
}
override fun initData() {
super.initData()
courseBean = intent.getParcelableExtra(ConstantParamKey.COURSE_BEAN)
val isExam = intent.getBooleanExtra("isExam", false)
courseBean?.let {
if (isExam) {
mViewModel.startExam(it.mTrainClassId.toInt())
} else {
mViewModel.startPractise(it.mTrainClassId.toInt())
}
binding.toolBar.setTitle(
if (it.isTrainClass) {
"班级练习"
} else {
"班级考试"
}
)
}
binding.apply {
// 禁止滑动
practicePager.isUserInputEnabled = false
toolBar.setRightText("答题卡")
toolBar.setRightTextDrawable(
ContextCompat.getDrawable(
baseContext,
R.mipmap.answer_sheet
)
)
// 答题卡点击事件
toolBar.addRightListener(object : ToolBarClickListener {
override fun onClick(view: View) {
val intent =
Intent(this@CoursePractiseActivity, AnswerSheetActivity::class.java)
.putStringArrayListExtra("resultData", mPagerAdapter.getArrayList())
.putExtra("showCorrect", mPagerAdapter.showCorrect)
.putExtra("title", binding.toolBar.getTitle())
startForResult.launch(intent)
}
})
// 上一题
previous.setOnClickListener {
val index = practicePager.currentItem
if (index >= 1) {
practicePager.currentItem = index - 1
}
next.visibility = View.VISIBLE
finishJob.visibility = View.GONE
if (index == 1) {
previous.visibility = View.GONE
}
}
// 下一题
next.setOnClickListener {
if (mPagerAdapter.showCorrect) {
modifyStatus()
} else {
next.isClickable = false
val answer = mPagerAdapter.getAnswer()[practicePager.currentItem]
if (answer.answer.isEmpty()) {
next.isClickable = true
ToastUtils.s(baseContext, "请选择题目选项")
return@setOnClickListener
}
mViewModel.subSingle(userItemId, answer.id, answer.answer)
}
}
// 完成
finishJob.setOnClickListener {
// 完成
finishJob.isClickable = false
val answer = mPagerAdapter.getAnswer()[practicePager.currentItem]
if (answer.answer.isEmpty()) {
finishJob.isClickable = true
ToastUtils.s(baseContext, "请选择题目选项")
return@setOnClickListener
}
isFinish = true
mViewModel.subSingle(userItemId, answer.id, answer.answer)
}
}
// 标题弹窗
titleDialog.setListener(object : DialogListener {
override fun determine() {
finish()
}
})
// 查看答题卡
titleDialog.viewAnswerSheetListener {
binding.finishJob.visibility = View.INVISIBLE
mPagerAdapter.showCorrect = true
mPagerAdapter.notifyDataSetChanged()
binding.practicePager.currentItem = 0
binding.previous.visibility = View.GONE
binding.next.visibility = View.VISIBLE
isFinish = false
titleDialog.dismiss()
}
}
override fun initDataObserver() {
mViewModel.exam.observe(this) {
if (it.code == 1) {
userItemId = it.data.user_item_id
mPagerAdapter.addList(it.data.list)
binding.practicePager.adapter = mPagerAdapter
} else {
ToastUtils.s(baseContext, it.msg)
}
}
mViewModel.subSingleData.observe(this) {
binding.next.isClickable = true
modifyStatus()
// 胶卷时调用此接口
if (isFinish) {
mPagerAdapter.notifyDataSetChanged()
mViewModel.subFinish(userItemId)
}
}
mViewModel.subFinish.observe(this) {
if (!titleDialog.isShowing) {
// 点击外部不取消
titleDialog.setInfo("共${mPagerAdapter.itemCount}道题")
titleDialog.setTitleSpan("答对${it.data.correct_count}道题").show()
}
}
}
private fun modifyStatus() {
val index = binding.practicePager.currentItem
if (index < mPagerAdapter.itemCount - 1) {
binding.practicePager.currentItem = index + 1
}
binding.previous.visibility = View.VISIBLE
if (index == mPagerAdapter.itemCount - 2) {
binding.next.visibility = View.GONE
if (!mPagerAdapter.showCorrect) {
binding.finishJob.visibility = View.VISIBLE
}
}
}
override fun onDestroy() {
if (titleDialog.isShowing) {
titleDialog.dismiss()
}
super.onDestroy()
}
}
\ No newline at end of file
... ...
package com.br_technology.securitytrain_master.ui.view.home.activity.course
import android.Manifest
import android.location.LocationManager
import android.util.Log
import com.br_technology.securitytrain_master.base.common.ConstantParamKey.CLASS_ID
import com.br_technology.securitytrain_master.base.view.BaseApplication
... ... @@ -27,8 +28,8 @@ class LocationSignActivity :
ActivityLocationSignBinding::inflate
), TencentLocationListener {
val mClassId: String? = null
var mLocation: TencentLocation? = null
var mClassId: String? = null
private var mLocation: TencentLocation? = null
override fun initView() {
super.initView()
... ... @@ -39,7 +40,7 @@ class LocationSignActivity :
TencentLocationManager.COORDINATE_TYPE_GCJ02;
rvSign.setOnClickListener {
if (mLocation != null && mClassId != null) {
mViewModel.sign(mClassId, "${mLocation?.latitude}", "${mLocation?.longitude}")
mViewModel.sign(mClassId?:"", "${mLocation?.latitude}", "${mLocation?.longitude}")
}
}
}
... ... @@ -47,7 +48,7 @@ class LocationSignActivity :
override fun initData() {
super.initData()
intent.getStringExtra(CLASS_ID)
mClassId = intent.getStringExtra(CLASS_ID)
}
override fun onStart() {
... ... @@ -64,6 +65,9 @@ class LocationSignActivity :
override fun onResume() {
binding.mapView.onResume()
super.onResume()
val lm = getSystemService(LOCATION_SERVICE) as LocationManager
val enable = lm.isProviderEnabled(LocationManager.GPS_PROVIDER)
if (enable) {
initPermissions(
Manifest.permission.ACCESS_FINE_LOCATION,
Manifest.permission.ACCESS_COARSE_LOCATION,
... ... @@ -74,7 +78,9 @@ class LocationSignActivity :
showError("未授权定位,无法打卡.")
}, onDeniedNever = {
})
} else {
showError("GPS定位未开启,无法打卡.")
}
}
override fun onDestroy() {
... ...
package com.br_technology.securitytrain_master.ui.view.home.activity.course
import android.text.TextUtils
import com.br_technology.securitytrain_master.base.common.ConstantParamKey
import com.br_technology.securitytrain_master.databinding.ActivityVideoDetailBinding
import com.br_technology.securitytrain_master.ui.bean.CourseParam
import com.br_technology.securitytrain_master.ui.view.home.viewmodel.VideoDetailViewModel
import com.br_technology.securitytrain_master.view.MyVideoPlayer
import com.shuyu.gsyvideoplayer.GSYVideoManager
import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleActivity
... ... @@ -23,12 +25,20 @@ class VideoDetailActivity : BaseLifeCycleActivity<VideoDetailViewModel, Activity
override fun initView() {
super.initView()
binding.videoPlayer.mStatusChange = object : MyVideoPlayer.IStatusChange {
override fun status(isPause: Boolean, isFinish: Boolean) {
if (!TextUtils.isEmpty(intent.getStringExtra(ConstantParamKey.COMMON_URL))) {
mViewModel.record(binding.videoPlayer.getProgressTime())
}
}
}
}
override fun initData() {
super.initData()
val url = intent.getStringExtra(ConstantParamKey.COMMON_URL)
courseBean = intent.getParcelableExtra(ConstantParamKey.COURSE_BEAN)
mViewModel.courseParam.value = courseBean
url?.apply {
binding.videoPlayer.initVideoBuilderMode(
"it.data.detail.image",
... ...
package com.br_technology.securitytrain_master.ui.view.home.fragment
import android.content.Intent
import com.br_technology.securitytrain_master.base.common.ConstantParamKey
import com.br_technology.securitytrain_master.base.common.ConstantParamKey.COMMON_URL
import com.br_technology.securitytrain_master.base.common.ConstantParamKey.COURSE_BEAN
import com.br_technology.securitytrain_master.databinding.FragmentCourseListBinding
... ... @@ -70,18 +71,18 @@ class CourseListFragment(var data: TrainCourseData) :
addData(dataList)
setListener(object : IItemClick {
override fun item(item: TrainCourseDetailItemChild) {
val param = (activity as CourseDetailActivity).getCourseBean()
when (item.type) {
TYPE_COURSE_DETAIL_ITEM_VIDEO -> {
param?.mClassId = item.lessonVideoChild?.id.toString()
startActivity(
Intent(activity, VideoDetailActivity::class.java)
.putExtra(COMMON_URL, item.lessonVideoNormalChild?.video_url)
.putExtra(
COURSE_BEAN,
(activity as CourseDetailActivity).getCourseBean()
)
.putExtra(COMMON_URL, item.lessonVideoChild?.video_url)
.putExtra(COURSE_BEAN, param)
)
}
TYPE_COURSE_DETAIL_ITEM_NORMAL -> {
param?.mClassId = item.lessonVideoNormalChild?.id.toString()
startActivity(
Intent(activity, VideoDetailActivity::class.java)
.putExtra(COMMON_URL, item.lessonVideoNormalChild?.video_url)
... ... @@ -92,6 +93,7 @@ class CourseListFragment(var data: TrainCourseData) :
)
}
TYPE_COURSE_DETAIL_ITEM_LIVE -> {
param?.mClassId = item.lessonLiveChild?.id.toString()
startActivity(
Intent(activity, VideoDetailActivity::class.java)
.putExtra(COMMON_URL, item.lessonLiveChild?.webrtc_url)
... ... @@ -102,7 +104,10 @@ class CourseListFragment(var data: TrainCourseData) :
)
}
TYPE_COURSE_DETAIL_ITEM_OFF -> {
startActivity(LocationSignActivity::class.java)
startActivity(
Intent(activity, LocationSignActivity::class.java)
.putExtra(ConstantParamKey.CLASS_ID, item.lessonOffChild?.id.toString())
)
}
}
}
... ...
package com.br_technology.securitytrain_master.ui.view.home.fragment
import android.content.Intent
import android.text.TextUtils
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import com.br_technology.securitytrain_master.R
import com.br_technology.securitytrain_master.base.common.ConstantParamKey
import com.br_technology.securitytrain_master.base.common.ConstantParamKey.COMMON_URL
... ... @@ -52,18 +55,56 @@ class HomeFragment :
})
//获取最新公告
mViewModel.mNoticeBean.observe(this, {
val data = it.data.list
for (news in data) {
val textView = TextView(context)
textView.maxLines = 1
textView.text = news.title
textView.ellipsize = TextUtils.TruncateAt.END
textView.setOnClickListener {
}
binding.flipperScan.addView(
textView, ViewGroup.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT
)
)
}
if (data.size > 1) {
binding.flipperScan.flipInterval = 3000
binding.flipperScan.startFlipping()
}
})
//获取视频列表
mViewModel.mVideoLessonBean.observe(this, {
videoLessonList?.clear()
videoLessonList?.addAll(it.data.list.data)
if (it.data.list.data.isNotEmpty()) {
videoLessonList?.addAll(
it.data.list.data.subList(
0,
(it.data.list.data.size).coerceAtMost(4)
)
)
}
videoLessonList?.let { it1 -> videoCourseAdapter?.setList(it1) }
if (videoLessonList!!.size < 4) {
binding.llVideo.visibility = View.GONE
} else {
binding.llVideo.visibility = View.VISIBLE
}
})
//获取推荐资料
mViewModel.mRecommendBean.observe(this, {
recommendList?.clear()
recommendList?.addAll(it.data.list)
if (it.data.list.isNotEmpty()) {
recommendList?.addAll(
it.data.list.subList(
0,
(it.data.list.size).coerceAtMost(4)
)
)
}
recommendList?.let { it1 -> recommendDataAdapter?.addList(it1) }
if (recommendList!!.size < 4) {
... ... @@ -125,6 +166,9 @@ class HomeFragment :
database.setOnClickListener {
startActivity(DatabaseActivity::class.java)
}
llRecommend.setOnClickListener {
startActivity(DatabaseActivity::class.java)
}
// 文本课程
txtCourse.setOnClickListener {
... ... @@ -134,6 +178,8 @@ class HomeFragment :
onlineCourse.setOnClickListener {
startActivity(OnlineActivity::class.java)
}
llVideo.setOnClickListener { startActivity(OnlineActivity::class.java) }
// 直播课程
liveCourse.setOnClickListener {
... ...
package com.br_technology.securitytrain_master.ui.view.home.viewmodel
import androidx.lifecycle.MutableLiveData
import com.br_technology.securitytrain_master.base.network.response.BaseResponse
import com.br_technology.securitytrain_master.base.network.response.CommonDetailList
import com.br_technology.securitytrain_master.base.network.response.CommonPage
import com.br_technology.securitytrain_master.base.repository.TrainRepository
import com.br_technology.securitytrain_master.base.view.BaseViewModel
import com.br_technology.securitytrain_master.ui.bean.*
import com.br_technology.securitytrain_master.ui.view.bank.bean.SubjectData
/**
* Author by YSir
* Date on 2022/1/24.
* description
* PS: Not easy to write code, please indicate.
*/
class CoursePracticeViewModel : BaseViewModel<TrainRepository>() {
val exam = MutableLiveData<BaseResponse<SubjectData>>()
val courseBean = MutableLiveData<CourseParam>()
var subAnswer: MutableLiveData<BaseResponse<SubResult>> = MutableLiveData()
// 交卷
var subFinish: MutableLiveData<BaseResponse<SubResult>> = MutableLiveData()
// 提交某一题
val subSingleData: MutableLiveData<BaseResponse<SubSingle>> = MutableLiveData()
// 每日一练列表数据
val dayPracticeLiveData: MutableLiveData<BaseResponse<CommonDetailList<CommonPage<PaperDaily>>>> =
MutableLiveData()
// 获取挑战答题弹板信息
val challengeInfoLiveData: MutableLiveData<BaseResponse<ChallengeInfo>> = MutableLiveData()
// 开始练习
fun startPractise(
train_practise_id: Int,
) {
mRepository.startPractise(train_practise_id, exam)
}
// 开始答题
fun startExam(
train_practise_id: Int,
) {
mRepository.startExamExp(train_practise_id, exam)
}
// 提交某一题
fun subSingle(
user_item_id: Int,
item_id: Int,
answer: String,
) {
mRepository.subSingle(user_item_id, item_id, answer, subSingleData)
}
// 提交答卷
fun subFinish(user_item_id: Int) {
mRepository.subPaper(user_item_id, subFinish)
}
}
\ No newline at end of file
... ...
package com.br_technology.securitytrain_master.ui.view.home.viewmodel
import androidx.lifecycle.MutableLiveData
import com.br_technology.securitytrain_master.base.network.response.BaseResponse
import com.br_technology.securitytrain_master.base.repository.LessonRepository
import com.br_technology.securitytrain_master.base.view.BaseViewModel
import com.br_technology.securitytrain_master.ui.view.home.repository.VideoDetailRepository
import com.br_technology.securitytrain_master.ui.bean.CourseParam
/**
* Time: 12/8/2021 15:46
* Author: Captain
* Description: 初见时你很迷人
*/
class VideoDetailViewModel : BaseViewModel<VideoDetailRepository>() {
class VideoDetailViewModel : BaseViewModel<LessonRepository>() {
val courseParam = MutableLiveData<CourseParam>()
val record = MutableLiveData<BaseResponse<Void>>()
fun record(
view_len: String
) {
courseParam.value?.let {
if (it.isTrainClass) {
val map = hashMapOf("class_id" to it.mClassId)
mRepository.recordTrainLesson(
it.type,
it.mLessonId,
it.mTrainClassId,
view_len,
map,
record
)
} else {
val map = hashMapOf("view_len" to view_len, "class_id" to it.mClassId)
mRepository.recordNormalLesson(it.type, it.mLessonId, map, record)
}
}
}
}
\ No newline at end of file
... ...
... ... @@ -63,7 +63,6 @@ class AcademicFeedbackActivity :
recyclerview.adapter = academicFeedbackAdapter
academicFeedbackAdapter?.setOnItemClickListener { _, _, position ->
mViewModel.academicFeedbackDetail(academicFeedbackList!![position].train_class_id)
}
initLoadMore()
... ...
package com.br_technology.securitytrain_master.ui.view.mine.activity
import android.view.View
import androidx.core.content.ContextCompat
import com.br_technology.securitytrain_master.R
import android.annotation.SuppressLint
import com.br_technology.securitytrain_master.databinding.ActivityLearningReportBinding
import com.br_technology.securitytrain_master.ui.view.home.pojo.VideoCourse
import com.br_technology.securitytrain_master.expand.glideRound
import com.br_technology.securitytrain_master.ui.view.mine.adapter.LearningReportAdapter
import com.br_technology.securitytrain_master.ui.view.mine.viewmodel.LearningReportViewModel
import com.br_technology.securitytrain_master.util.TranslateUnit
import com.br_technology.securitytrain_master.view.ClassifyPop
import com.br_technology.securitytrain_master.view.listener.ToolBarClickListener
import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleActivity
/**
... ... @@ -26,39 +24,44 @@ class LearningReportActivity :
ClassifyPop(this)
}
@SuppressLint("SetTextI18n")
override fun initDataObserver() {
// todo 数据设置
mViewModel.data.observe(this, {
val user = it.data.report.user
binding.apply {
tvScore.text = "积分${user.score}"
ivHead.glideRound(
user.avatar,
TranslateUnit.dp2px(this@LearningReportActivity, 64f)
)
}
})
}
override fun initData() {
super.initData()
mViewModel.getReport()
binding.apply {
toolBar.setRightText("全部")
toolBar.setRightTextDrawable(
ContextCompat.getDrawable(
baseContext,
R.mipmap.down_arrow
)
)
toolBar.addRightListener(object : ToolBarClickListener {
override fun onClick(view: View) {
if (!classifyPop.isShowing) {
classifyPop.showAsDropDown(view)
}
}
})
// toolBar.setRightText("全部")
// toolBar.setRightTextDrawable(
// ContextCompat.getDrawable(
// baseContext,
// R.mipmap.down_arrow
// )
// )
//
// toolBar.addRightListener(object : ToolBarClickListener {
// override fun onClick(view: View) {
// if (!classifyPop.isShowing) {
// classifyPop.showAsDropDown(view)
// }
// }
// })
val learningReportAdapter = LearningReportAdapter()
val list = mutableListOf(
VideoCourse(R.mipmap.banner, "01:45:00", "自动化制作课程", "(考试)", "+10"),
VideoCourse(R.mipmap.banner, "01:45:00", "自动化制作课程", "(考试)", "+10"),
VideoCourse(R.mipmap.banner, "01:45:00", "自动化制作课程", "(考试)", "+10"),
VideoCourse(R.mipmap.banner, "01:45:00", "自动化制作课程", "(考试)", "+10"),
)
recyclerview.adapter = learningReportAdapter
learningReportAdapter.addList(list)
// recyclerview.adapter = learningReportAdapter
// learningReportAdapter.addList(list)
tvCreateReport.setOnClickListener {
startActivity(LearningReportDetailActivity::class.java)
... ...
... ... @@ -6,8 +6,13 @@ import android.net.Uri
import com.br_technology.securitytrain_master.databinding.ActivityServiceBinding
import com.br_technology.securitytrain_master.ext.initPermissions
import com.br_technology.securitytrain_master.ui.view.home.viewmodel.ServiceViewModel
import com.br_technology.securitytrain_master.util.TrainFileUtil
import com.br_technology.securitytrain_master.view.DialogTrainLoading
import com.bumptech.glide.Glide
import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleActivity
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import java.io.File
/**
* createTime:2021/8/2 15:29
... ... @@ -36,15 +41,64 @@ class ServiceActivity :
//跳转到设置页面
})
}
// 下载二维码
download.setOnClickListener { }
}
}
override fun initDataObserver() {
mViewModel.mContactServiceBean.observe(this,{
binding.mobile.text = it.data.mobile
Glide.with(this).load(it.data.qrcode).into(binding.code)
mViewModel.mContactServiceBean.observe(this, { contact ->
binding.mobile.text = contact.data.mobile
Glide.with(this).load(contact.data.qrcode).into(binding.code)
// 下载二维码
binding.download.setOnClickListener {
initPermissions(Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.WRITE_EXTERNAL_STORAGE,
onGranted = {
load(contact.data.qrcode)
},
onDenied = {
},
onDeniedNever = {
//跳转到设置页面
})
}
})
}
private val mDialogLoading: DialogTrainLoading by lazy {
return@lazy DialogTrainLoading(this)
}
private fun load(url: String) {
mDialogLoading.show()
GlobalScope.launch {
val fileDataDes = File(TrainFileUtil.getTrainLoad(), TrainFileUtil.getFileName(url))
TrainFileUtil.fileLoad(
fileDataDes,
url,
true,
object : TrainFileUtil.ILoad {
override fun success(file: File) {
mDialogLoading.dismiss()
runOnUiThread{
showError("下载完成")
}
}
override fun fail() {
mDialogLoading.dismiss()
}
override fun progress(f: Float) {
}
})
}
}
override fun onDestroy() {
if (mDialogLoading.isShowing){
mDialogLoading.dismiss()
}
super.onDestroy()
}
}
\ No newline at end of file
... ...
package com.br_technology.securitytrain_master.ui.view.mine.adapter
import android.annotation.SuppressLint
import android.content.Context
import android.view.LayoutInflater
import android.view.ViewGroup
import android.widget.TextView
import com.br_technology.securitytrain_master.R
import com.br_technology.securitytrain_master.base.view.BaseAdapter
import com.br_technology.securitytrain_master.databinding.ItemCourseBinding
import com.br_technology.securitytrain_master.ui.bean.LessonBean
import com.br_technology.securitytrain_master.util.CommonUtil
import com.bumptech.glide.Glide
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.module.LoadMoreModule
import com.chad.library.adapter.base.viewholder.BaseViewHolder
/**
* Time: 8/3/2021 11:29
* Author: Captain
* Description: 初见时你很迷人
*/
class CourseAdapter : BaseAdapter<LessonBean, ItemCourseBinding>() {
class CourseAdapter : BaseQuickAdapter<LessonBean, BaseViewHolder>(R.layout.item_course),
LoadMoreModule {
override fun getViewBinding(
context: Context,
parent: ViewGroup,
viewType: Int,
from: LayoutInflater
): ItemCourseBinding {
return ItemCourseBinding.inflate(from, parent, false)
interface ITrainItemClick {
fun itemClick(item: LessonBean)
}
var mListener: ITrainItemClick? = null
fun setListener(iListener: ITrainItemClick) {
mListener = iListener
}
@SuppressLint("SetTextI18n")
override fun onBind(holder: ItemCourseBinding, position: Int, data: LessonBean) {
override fun convert(holder: BaseViewHolder, data: LessonBean) {
holder.apply {
holder.tvTitle.text = CommonUtil.getTransStr(data.name)
holder.tvStatus.text = if (data.status == "0") {
getView<TextView>(R.id.tv_title).text = CommonUtil.getTransStr(data.name)
getView<TextView>(R.id.tv_status).text = if (data.status == "0") {
"未完成"
} else {
"已完成"
}
holder.tvTime.text = CommonUtil.getTransStr(data.create_time_text)
holder.tvLesson.text = "${data.class_hours}学时"
Glide.with(holder.root).load(data.image).error(R.mipmap.placeholder_head)
.into(holder.ivPic)
getView<TextView>(R.id.tv_time).text = CommonUtil.getTransStr(data.create_time_text)
getView<TextView>(R.id.tv_lesson).text = "${data.class_hours}学时"
Glide.with(holder.itemView).load(data.image).error(R.mipmap.placeholder_head)
.into(getView(R.id.iv_pic))
itemView.setOnClickListener {
mListener?.itemClick(data)
}
}
}
}
\ No newline at end of file
... ...
... ... @@ -4,6 +4,7 @@ import android.widget.ImageView
import com.br_technology.securitytrain_master.R
import com.br_technology.securitytrain_master.ui.bean.TrainTestData
import com.chad.library.adapter.base.BaseMultiItemQuickAdapter
import com.chad.library.adapter.base.module.LoadMoreModule
import com.chad.library.adapter.base.viewholder.BaseViewHolder
/**
... ... @@ -12,7 +13,8 @@ import com.chad.library.adapter.base.viewholder.BaseViewHolder
* description
* PS: Not easy to write code, please indicate.
*/
class TrainTestAdapter : BaseMultiItemQuickAdapter<TrainTestData, BaseViewHolder>() {
class TrainTestAdapter : BaseMultiItemQuickAdapter<TrainTestData, BaseViewHolder>(),
LoadMoreModule {
init {
addItemType(1, R.layout.item_mock_examnation)
... ...
... ... @@ -8,13 +8,13 @@ import com.br_technology.securitytrain_master.base.common.ConstantType
import com.br_technology.securitytrain_master.databinding.FragmentClassDutyCourseBinding
import com.br_technology.securitytrain_master.ui.bean.*
import com.br_technology.securitytrain_master.ui.view.home.activity.course.CourseDetailActivity
import com.br_technology.securitytrain_master.ui.view.home.activity.course.CoursePractiseActivity
import com.br_technology.securitytrain_master.ui.view.home.activity.course.TextDetailActivity
import com.br_technology.securitytrain_master.ui.view.mine.adapter.CourseAdapter
import com.br_technology.securitytrain_master.ui.view.mine.adapter.TrainTestAdapter
import com.br_technology.securitytrain_master.ui.view.mine.viewmodel.ClassDutyCourseViewModel
import com.br_technology.securitytrain_master.util.TranslateUnit
import com.br_technology.securitytrain_master.view.VerticalDecoration
import com.br_technology.securitytrain_master.view.listener.OnItemClickListener
import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleFragment
/**
... ... @@ -25,7 +25,8 @@ import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleFragment
class ClassDutyCourseFragment(val type: Int) :
BaseLifeCycleFragment<ClassDutyCourseViewModel, FragmentClassDutyCourseBinding>(
FragmentClassDutyCourseBinding::inflate
),OnItemClickListener<LessonBean>,TrainTestAdapter.ITrainItemClick {
), TrainTestAdapter.ITrainItemClick,
CourseAdapter.ITrainItemClick {
var page: Int = 1
var courseAdapter: CourseAdapter? = null
... ... @@ -35,6 +36,7 @@ class ClassDutyCourseFragment(val type: Int) :
@SuppressLint("SetTextI18n")
override fun initDataObserver() {
mViewModel.listCourse.observe(this, {
binding.smartRefresh.isRefreshing = false
lessonBean = it.data
if (lessonBean!!.lesson_class_count > 0) {
binding.prUploadValue.progress = 100 *
... ... @@ -46,18 +48,21 @@ class ClassDutyCourseFragment(val type: Int) :
if (list.isNotEmpty()) {
if (page == 1) {
courseAdapter = CourseAdapter()
courseAdapter?.addListener(this)
courseAdapter?.addList(list)
courseAdapter?.setListener(this)
courseAdapter?.setList(list)
binding.recyclerview.adapter = courseAdapter
} else {
courseAdapter?.addList(list)
courseAdapter?.addData(list)
}
}
binding.smartRefresh.setEnableLoadMore(list.size == 10)
binding.smartRefresh.finishLoadMore()
binding.smartRefresh.finishRefresh()
if (list.size < 10) {
courseAdapter?.loadMoreModule?.loadMoreEnd()
} else {
courseAdapter?.loadMoreModule?.loadMoreComplete()
}
})
mViewModel.listPractise.observe(this, {
binding.smartRefresh.isRefreshing = false
val list = it.data.list
if (list.isNotEmpty()) {
if (page == 1) {
... ... @@ -69,11 +74,14 @@ class ClassDutyCourseFragment(val type: Int) :
trainTestAdapter?.addData(transPracticeData(list))
}
}
binding.smartRefresh.setEnableLoadMore(list.size == 10)
binding.smartRefresh.finishLoadMore()
binding.smartRefresh.finishRefresh()
if (list.size < 10) {
trainTestAdapter?.loadMoreModule?.loadMoreEnd()
} else {
trainTestAdapter?.loadMoreModule?.loadMoreComplete()
}
})
mViewModel.listExam.observe(this, {
binding.smartRefresh.isRefreshing = false
val list = it.data.list
if (list.isNotEmpty()) {
if (page == 1) {
... ... @@ -85,9 +93,11 @@ class ClassDutyCourseFragment(val type: Int) :
trainTestAdapter?.addData(transExamData(list))
}
}
binding.smartRefresh.setEnableLoadMore(list.size == 10)
binding.smartRefresh.finishLoadMore()
binding.smartRefresh.finishRefresh()
if (list.size < 10) {
trainTestAdapter?.loadMoreModule?.loadMoreEnd()
} else {
trainTestAdapter?.loadMoreModule?.loadMoreComplete()
}
})
}
... ... @@ -110,15 +120,22 @@ class ClassDutyCourseFragment(val type: Int) :
return course
}
override fun registerListener() {
binding.apply {
smartRefresh.setOnRefreshListener {
refreshData()
fun paramBean(data: TrainTestData): CourseParam {
val course = CourseParam()
course.isTrainClass = true
course.mTrainClassId = "${
if (data.isTest) {
data.practice?.id
} else {
data.exam?.id
}
smartRefresh.setOnLoadMoreListener {
loadMore()
}"
course.type = data.itemType
return course
}
override fun registerListener() {
binding.apply {
val vsi = if (ConstantType.TYPE_CLASS_COURSE == type) {
View.VISIBLE
} else {
... ... @@ -147,17 +164,29 @@ class ClassDutyCourseFragment(val type: Int) :
0
)
)
binding.smartRefresh.setOnRefreshListener {
refreshData()
}
when (type) {
ConstantType.TYPE_CLASS_COURSE -> {
courseAdapter = CourseAdapter()
binding.recyclerview.adapter = courseAdapter
courseAdapter?.loadMoreModule?.isAutoLoadMore = true
courseAdapter?.loadMoreModule?.isEnableLoadMoreIfNotFullPage = false
courseAdapter?.loadMoreModule?.setOnLoadMoreListener {
loadMore()
}
}
else -> {
trainTestAdapter = TrainTestAdapter()
binding.recyclerview.adapter = trainTestAdapter
trainTestAdapter?.loadMoreModule?.isAutoLoadMore = true
trainTestAdapter?.loadMoreModule?.isEnableLoadMoreIfNotFullPage = false
courseAdapter?.loadMoreModule?.setOnLoadMoreListener {
loadMore()
}
}
}
}
private fun transPracticeData(list: List<PractiseBean>): List<TrainTestData> {
... ... @@ -181,10 +210,25 @@ class ClassDutyCourseFragment(val type: Int) :
getData()
}
override fun onClick(position: Int, data: LessonBean) {
// //todo 时间校验限制等
// fun checkTime(exam: ExamBean): Boolean {
//
// }
override fun itemClick(item: TrainTestData) {
this@ClassDutyCourseFragment.startActivity(
Intent(
requireActivity(),
CoursePractiseActivity::class.java
).putExtra(ConstantParamKey.COURSE_BEAN, paramBean(item))
.putExtra("isExam", !item.isTest)
)
}
override fun itemClick(response: LessonBean) {
// 课程分类:1=视频课,2=直播课,3=线下培训,4=文本课
val param = paramLessonBean(data)
when (data.itemType) {
val param = paramLessonBean(response)
when (response.itemType) {
4 -> {
this@ClassDutyCourseFragment.startActivity(
Intent(
... ... @@ -203,7 +247,4 @@ class ClassDutyCourseFragment(val type: Int) :
}
}
}
override fun itemClick(item: TrainTestData) {
}
}
\ No newline at end of file
... ...
... ... @@ -3,6 +3,7 @@ package com.br_technology.securitytrain_master.ui.view.mine.fragment
import android.content.Context
import android.content.Intent
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.LinearLayoutManager
import com.br_technology.securitytrain_master.base.common.ConstantParamKey
... ... @@ -44,7 +45,15 @@ class CourseFragment :
override fun initDataObserver() {
mViewModel.lessonList.observe(this, {
binding.smartRefresh.finishRefresh()
binding.smartRefresh.finishLoadMore()
if (page == 1) {
val data = it.data.list.data
binding.none.visibility = if (!data.isEmpty()) {
View.GONE
} else {
View.VISIBLE
}
docAdapter = TxtAdapter()
binding.result.adapter = docAdapter
docAdapter.addList(it.data.list.data)
... ... @@ -67,6 +76,11 @@ class CourseFragment :
}
}
)
mViewModel.favoriteResponse.observe(this, {
if (it.msg.contains("取消收藏成功")) {
refresh()
}
})
}
private fun refresh() {
... ... @@ -81,7 +95,7 @@ class CourseFragment :
binding.smartRefresh.setEnableRefresh(false)
}
class TxtAdapter : BaseAdapter<FavoriteData, AdapterSideslipBinding>() {
inner class TxtAdapter : BaseAdapter<FavoriteData, AdapterSideslipBinding>() {
override fun getViewBinding(
context: Context,
parent: ViewGroup,
... ... @@ -95,6 +109,9 @@ class CourseFragment :
holder.pic.glideRound(data.image, 16)
holder.name.text = data.title
holder.info.text = data.des
holder.delete.setOnClickListener {
mViewModel.collect("2", data.object_id)
}
}
}
}
\ No newline at end of file
... ...
... ... @@ -3,6 +3,7 @@ package com.br_technology.securitytrain_master.ui.view.mine.fragment
import android.content.Context
import android.content.Intent
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.LinearLayoutManager
import com.br_technology.securitytrain_master.base.common.ConstantParamKey
... ... @@ -44,7 +45,15 @@ class DatabaseFragment :
override fun initDataObserver() {
mViewModel.docList.observe(this, {
binding.smartRefresh.finishRefresh()
binding.smartRefresh.finishLoadMore()
if (page == 1) {
val data = it.data.list.data
binding.none.visibility = if (!data.isEmpty()) {
View.GONE
} else {
View.VISIBLE
}
docAdapter = DocAdapter()
binding.result.adapter = docAdapter
docAdapter.addList(it.data.list.data)
... ... @@ -63,6 +72,11 @@ class DatabaseFragment :
}
}
)
mViewModel.favoriteResponse.observe(this, {
if (it.msg.contains("取消收藏成功")) {
refresh()
}
})
}
private fun refresh() {
... ... @@ -78,7 +92,7 @@ class DatabaseFragment :
}
class DocAdapter : BaseAdapter<FavoriteData, AdapterSideslipBinding>() {
inner class DocAdapter : BaseAdapter<FavoriteData, AdapterSideslipBinding>() {
override fun getViewBinding(
context: Context,
parent: ViewGroup,
... ... @@ -92,6 +106,9 @@ class DatabaseFragment :
holder.pic.glideRound(data.image, 16)
holder.name.text = data.title
holder.info.text = data.des
holder.delete.setOnClickListener {
mViewModel.collect("1", data.object_id)
}
}
}
}
\ No newline at end of file
... ...
... ... @@ -4,7 +4,6 @@ import android.content.Intent
import android.view.View
import com.br_technology.securitytrain_master.R
import com.br_technology.securitytrain_master.databinding.FragmentMineBinding
import com.br_technology.securitytrain_master.ui.view.home.activity.course.LocationSignActivity
import com.br_technology.securitytrain_master.ui.view.home.viewmodel.MineViewModel
import com.br_technology.securitytrain_master.ui.view.login.activity.AccountLoginActivity
import com.br_technology.securitytrain_master.ui.view.mine.activity.*
... ... @@ -93,8 +92,7 @@ class MineFragment
}
R.id.tv_academic_feedback -> {
//学情反馈
// startActivity(AcademicFeedbackActivity::class.java)
startActivity(LocationSignActivity::class.java)
startActivity(AcademicFeedbackActivity::class.java)
}
R.id.tv_offline_exercise -> {
//线下培训
... ...
package com.br_technology.securitytrain_master.ui.view.mine.repository
import androidx.lifecycle.MutableLiveData
import com.br_technology.securitytrain_master.base.common.State
import com.br_technology.securitytrain_master.base.repository.ApiRepository
/**
* Time: 8/2/2021 15:52
* Author: Captain
* Description: 初见时你很迷人
*/
class LearningReportRepository(val loadState: MutableLiveData<State>) : ApiRepository(loadState) {
}
\ No newline at end of file
... ... @@ -19,6 +19,7 @@ import com.br_technology.securitytrain_master.ui.bean.MaterialPage
class DatabaseFViewModel : BaseViewModel<DocRepository>() {
// 资料
val docList = MutableLiveData<BaseResponse<CommonDataList<CommonPage<FavoriteData>>>>()
// 文本课程
val lessonList = MutableLiveData<BaseResponse<CommonDataList<CommonPage<FavoriteData>>>>()
... ... @@ -26,6 +27,15 @@ class DatabaseFViewModel : BaseViewModel<DocRepository>() {
val classifyDataList = MutableLiveData<BaseResponse<MaterialPage>>()
val type = MutableLiveData<Int>()
val sortId = MutableLiveData<Int>()
var favoriteResponse = MutableLiveData<BaseResponse<Void>>()
fun collect(
type: String,
favorite_id: String
) {
mRepository.collect(type, favorite_id, favoriteResponse)
}
fun geClassify() {
type.value?.let { mRepository.getDocClassify(it, classify) }
... ...
package com.br_technology.securitytrain_master.ui.view.mine.viewmodel
import androidx.lifecycle.MutableLiveData
import com.br_technology.securitytrain_master.base.network.response.BaseResponse
import com.br_technology.securitytrain_master.base.network.response.CommonReport
import com.br_technology.securitytrain_master.base.repository.TrainRepository
import com.br_technology.securitytrain_master.base.view.BaseViewModel
import com.br_technology.securitytrain_master.ui.view.mine.repository.LearningReportRepository
import com.br_technology.securitytrain_master.ui.bean.TrainReport
/**
* Time: 8/2/2021 15:52
* Author: Captain
* Description: 初见时你很迷人
*/
class LearningReportViewModel : BaseViewModel<LearningReportRepository>() {
class LearningReportViewModel : BaseViewModel<TrainRepository>() {
val data = MutableLiveData<BaseResponse<CommonReport<TrainReport>>>()
fun getReport(){
mRepository.trainReport(data)
}
}
\ No newline at end of file
... ...
package com.br_technology.securitytrain_master.ui.view.home.viewmodel
import androidx.lifecycle.MutableLiveData
import com.br_technology.securitytrain_master.base.network.response.BaseResponse
import com.br_technology.securitytrain_master.base.view.BaseViewModel
import com.br_technology.securitytrain_master.ui.view.mine.bean.ContactServiceBean
import com.br_technology.securitytrain_master.ui.view.mine.repository.ServiceRepository
import com.br_technology.securitytrain_master.base.network.response.BaseResponse
/**
* createTime:2021/7/27 15:48
* auth:张继
* des:
*/
class ServiceViewModel: BaseViewModel<ServiceRepository>() {
class ServiceViewModel : BaseViewModel<ServiceRepository>() {
var mContactServiceBean: MutableLiveData<BaseResponse<ContactServiceBean>> = MutableLiveData()
fun contactService() {
mRepository.contactService( mContactServiceBean)
mRepository.contactService(mContactServiceBean)
}
}
\ No newline at end of file
... ...
package com.br_technology.securitytrain_master.util
import android.content.ContentValues
import android.content.Context
import android.content.Intent
import android.media.MediaScannerConnection
import android.net.Uri
import android.os.Build
import android.os.Environment
import android.provider.MediaStore
import android.text.TextUtils
import com.br_technology.securitytrain_master.base.view.BaseApplication
import java.io.File
... ... @@ -9,6 +16,7 @@ import java.io.InputStream
import java.io.OutputStream
import java.net.HttpURLConnection
import java.net.URL
import java.net.URLConnection
/**
* Author by YSir
... ... @@ -34,6 +42,10 @@ object TrainFileUtil {
return File(getTrainCacheDir(), "trainLoad")
}
fun getTrainLoad(): File {
return File(getTrainExternalCacheDir(), "trainLoad")
}
fun getTrainExternalCacheDir(): File? {
// 判断sd卡是否存在
val sdCardExist = (Environment.getExternalStorageState() == Environment.MEDIA_MOUNTED)
... ... @@ -72,6 +84,10 @@ object TrainFileUtil {
}
fun fileLoad(file: File, fileUrl: String, iLoad: ILoad) {
fileLoad(file, fileUrl, false, iLoad)
}
fun fileLoad(file: File, fileUrl: String, notice: Boolean, iLoad: ILoad) {
val hasLoad = file.exists() && file.isFile
if (hasLoad) {
iLoad.success(file)
... ... @@ -102,15 +118,64 @@ object TrainFileUtil {
iLoad.progress(percent)
}
outputStream.flush()
iLoad.success(file)
} catch (e: Exception) {
e.printStackTrace()
iLoad.fail()
} finally {
inputStream?.close()
outputStream?.close()
if (notice) {
notice(file)
}
iLoad.success(file)
}
}
fun getFileType(file: File?): String {
if (file != null && file.isFile) {
val fileNameMap = URLConnection.getFileNameMap()
return fileNameMap.getContentTypeFor(file.name)
}
return ""
}
fun scanFile(context: Context?, file: File) {
MediaScannerConnection.scanFile(
context, arrayOf(file.path), arrayOf(getFileType(file))
) { path: String?, uri: Uri? -> }
}
private fun notice(file: File) {
// 其次把文件插入到系统图库
val context = BaseApplication.instance.getApplicationContext()
try {
// 最后通知图库更新
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.Q) {
val values = ContentValues()
values.put(MediaStore.Images.Media.DATA, file.absolutePath)
values.put(MediaStore.Images.Media.MIME_TYPE, getFileType(file))
context.contentResolver.insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values)
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
MediaScannerConnection.scanFile(
context, arrayOf(file.absolutePath), null
) { path: String?, uri: Uri? ->
val mediaScanIntent = Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE)
mediaScanIntent.data = uri
context.sendBroadcast(mediaScanIntent)
}
// MediaStore.Images.Media.insertImage(context.getContentResolver(), file.getAbsolutePath(), file.getName(), null);
} else {
context.sendBroadcast(
Intent(
Intent.ACTION_MEDIA_SCANNER_SCAN_FILE,
Uri.fromFile(File(file.path))
)
)
}
} catch (e: java.lang.Exception) {
e.printStackTrace()
}
}
}
\ No newline at end of file
... ...
... ... @@ -37,8 +37,8 @@ class DialogTitle(context: Context) : Dialog(context, R.style.UserDefaultDialog)
val attributes = window?.attributes
attributes?.width = binding.root.screenWidth() - 80.dp2px()
// 点击区域外取消
setCanceledOnTouchOutside(false)
setCancelable(false)
setCanceledOnTouchOutside(true)
setCancelable(true)
binding.apply {
// 确定
complete.setOnClickListener {
... ...
... ... @@ -5,7 +5,6 @@ import android.content.Context
import android.content.res.Configuration
import android.text.TextUtils
import android.util.AttributeSet
import android.view.View
import android.widget.ImageView
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleObserver
... ... @@ -38,6 +37,12 @@ class MyVideoPlayer : StandardGSYVideoPlayer, LifecycleObserver {
// return R.layout.layout_video_player
// }
interface IStatusChange {
fun status(isPause: Boolean, isFinish: Boolean)
}
var mStatusChange: IStatusChange? = null
override fun updateStartImage() {
super.updateStartImage()
... ... @@ -104,6 +109,11 @@ class MyVideoPlayer : StandardGSYVideoPlayer, LifecycleObserver {
super.onQuitFullscreen(url, *objects)
orientationUtils?.backToProtVideo();
}
override fun onComplete(url: String?, vararg objects: Any?) {
super.onComplete(url, *objects)
mStatusChange?.status(false, true)
}
}).build(this)
currentPlayer.startPlayLogic()
... ... @@ -132,6 +142,12 @@ class MyVideoPlayer : StandardGSYVideoPlayer, LifecycleObserver {
}
override fun onVideoPause() {
super.onVideoPause()
isPause = true
mStatusChange?.status(true, isFinish = false)
}
@OnLifecycleEvent(Lifecycle.Event.ON_RESUME)
private fun onResume() {
this.currentPlayer.onVideoResume(false)
... ... @@ -142,6 +158,21 @@ class MyVideoPlayer : StandardGSYVideoPlayer, LifecycleObserver {
private fun onPause() {
this.currentPlayer.onVideoPause()
isPause = true
mStatusChange?.status(true, isFinish = false)
}
fun getProgressTime(): String {
return when (mCurrentState) {
CURRENT_STATE_PLAYING, CURRENT_STATE_PAUSE -> {
"$currentPositionWhenPlaying"
}
CURRENT_STATE_AUTO_COMPLETE -> {
"$duration"
}
else -> {
"0"
}
}
}
@OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
... ...
... ... @@ -69,6 +69,10 @@ class ViewToolBar(context: Context, attrs: AttributeSet) : RelativeLayout(contex
inflate.title.text = text
}
fun getTitle(): String {
return inflate.title.text.toString()
}
fun setRightText(text: String) {
inflate.rightText.text = text
}
... ...
... ... @@ -28,6 +28,7 @@
android:layout_below="@id/tool_bar"
android:layout_marginStart="16dp"
android:layout_marginTop="24dp"
android:visibility="gone"
android:layout_marginBottom="8dp"
android:text="答题卡"
android:textColor="@color/color_32"
... ...
... ... @@ -170,7 +170,7 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal">
... ... @@ -178,11 +178,10 @@
<TextView
android:id="@+id/tv_upload"
android:layout_width="343dp"
android:layout_width="match_parent"
android:layout_margin="16dp"
android:layout_height="44dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="40dp"
android:layout_marginBottom="42dp"
android:background="@drawable/solid_25_4"
android:gravity="center"
android:text="提交信息"
... ...
... ... @@ -31,13 +31,13 @@
android:src="@mipmap/placeholder_head" />
<TextView
android:id="@+id/tv_score"
android:layout_width="115dp"
android:layout_height="32dp"
android:layout_centerHorizontal="true"
android:layout_marginTop="144dp"
android:background="@drawable/solid_ff_16"
android:gravity="center"
android:text="积分220"
android:textColor="@color/color_25"
android:textSize="14sp" />
... ...
... ... @@ -21,8 +21,7 @@
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_margin="40dp">
android:layout_margin="16dp">
<LinearLayout
android:layout_width="match_parent"
... ... @@ -51,8 +50,8 @@
<ImageView
android:id="@+id/code"
android:layout_width="196dp"
android:layout_height="196dp"
android:layout_width="150dp"
android:layout_height="150dp"
android:scaleType="fitXY"
android:layout_marginTop="43dp"
android:layout_marginBottom="40dp"
... ... @@ -93,7 +92,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="16dp"
android:layout_margin="16dp"
android:drawablePadding="12dp"
android:text="保存在本地"
android:textColor="@color/white"
... ...
... ... @@ -8,31 +8,23 @@
android:foreground="?attr/selectableItemBackground"
android:background="@color/white">
<com.scwang.smart.refresh.layout.SmartRefreshLayout
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/smart_refresh"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<com.scwang.smart.refresh.header.MaterialHeader
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="32dp"
android:overScrollMode="never"
android:scrollbars="none"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
<com.scwang.smart.refresh.footer.ClassicsFooter
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</com.scwang.smart.refresh.layout.SmartRefreshLayout>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
<LinearLayout
android:id="@+id/ll"
... ...
<?xml version="1.0" encoding="utf-8"?>
<com.scwang.smart.refresh.layout.SmartRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/none"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="暂无收藏"
android:visibility="gone"
android:gravity="center"
android:padding="32dp"/>
<com.scwang.smart.refresh.layout.SmartRefreshLayout
android:id="@+id/smart_refresh"
android:layout_width="match_parent"
android:layout_height="match_parent">
... ... @@ -23,5 +35,7 @@
<com.scwang.smart.refresh.footer.ClassicsFooter
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</com.scwang.smart.refresh.layout.SmartRefreshLayout>
</com.scwang.smart.refresh.layout.SmartRefreshLayout>
</FrameLayout>
... ...
<?xml version="1.0" encoding="utf-8"?>
<com.scwang.smart.refresh.layout.SmartRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/none"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="暂无收藏"
android:visibility="gone"
android:gravity="center"
android:padding="32dp"/>
<com.scwang.smart.refresh.layout.SmartRefreshLayout
android:id="@+id/smart_refresh"
android:layout_width="match_parent"
android:layout_height="match_parent">
... ... @@ -23,5 +33,7 @@
<com.scwang.smart.refresh.footer.ClassicsFooter
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</com.scwang.smart.refresh.layout.SmartRefreshLayout>
</com.scwang.smart.refresh.layout.SmartRefreshLayout>
</FrameLayout>
... ...
... ... @@ -7,6 +7,7 @@
android:orientation="vertical">
<include layout="@layout/layout_tool_bar_theme" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="?actionBarSize"
... ... @@ -19,8 +20,8 @@
android:layout_width="87dp"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:src="@mipmap/home_top_bg"
android:contentDescription="@string/logo" />
android:contentDescription="@string/logo"
android:src="@mipmap/home_top_bg" />
<RelativeLayout
android:id="@+id/search"
... ... @@ -106,15 +107,13 @@
android:contentDescription="@string/logo"
android:src="@mipmap/announcement" />
<TextView
<ViewFlipper
android:id="@+id/flipper_scan"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="12dp"
android:layout_weight="1"
android:ellipsize="end"
android:maxLines="1"
android:text="最新课程通知,最新课程通知,最新课程通知,最新课程通知。。。" />
android:layout_weight="1" />
<ImageView
android:layout_width="wrap_content"
... ... @@ -206,7 +205,6 @@
tools:itemCount="4" />
<LinearLayout
android:visibility="gone"
android:id="@+id/ll_video"
android:layout_width="match_parent"
android:layout_height="40dp"
... ... @@ -256,7 +254,6 @@
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
<LinearLayout
android:visibility="gone"
android:id="@+id/ll_recommend"
android:layout_width="match_parent"
android:layout_height="40dp"
... ...