作者 杨谦

1.课程相关完善

2.部分我的部分
3.首页接口等
正在显示 50 个修改的文件 包含 1203 行增加346 行删除
@@ -191,6 +191,9 @@ @@ -191,6 +191,9 @@
191 <activity 191 <activity
192 android:name=".ui.view.home.activity.course.LocationSignActivity" 192 android:name=".ui.view.home.activity.course.LocationSignActivity"
193 android:configChanges="keyboard|keyboardHidden|orientation|screenSize|screenLayout|smallestScreenSize|uiMode" /> 193 android:configChanges="keyboard|keyboardHidden|orientation|screenSize|screenLayout|smallestScreenSize|uiMode" />
  194 + <activity android:name=".ui.view.home.activity.course.CoursePractiseActivity"
  195 + android:configChanges="keyboard|keyboardHidden|orientation|screenSize|screenLayout|smallestScreenSize|uiMode"/>
  196 +
194 </application> 197 </application>
195 198
196 </manifest> 199 </manifest>
@@ -3,9 +3,9 @@ package com.br_technology.securitytrain_master.base.network.api @@ -3,9 +3,9 @@ package com.br_technology.securitytrain_master.base.network.api
3 import com.br_technology.securitytrain_master.base.network.response.* 3 import com.br_technology.securitytrain_master.base.network.response.*
4 import com.br_technology.securitytrain_master.ui.bean.* 4 import com.br_technology.securitytrain_master.ui.bean.*
5 import com.br_technology.securitytrain_master.ui.view.bank.bean.PracticeBean 5 import com.br_technology.securitytrain_master.ui.view.bank.bean.PracticeBean
  6 +import com.br_technology.securitytrain_master.ui.view.bank.bean.StartItemBean
6 import com.br_technology.securitytrain_master.ui.view.bank.bean.SubjectData 7 import com.br_technology.securitytrain_master.ui.view.bank.bean.SubjectData
7 import com.br_technology.securitytrain_master.ui.view.bank.bean.TestSubject 8 import com.br_technology.securitytrain_master.ui.view.bank.bean.TestSubject
8 -import com.br_technology.securitytrain_master.ui.view.bank.bean.StartItemBean  
9 import io.reactivex.rxjava3.core.Observable 9 import io.reactivex.rxjava3.core.Observable
10 import retrofit2.http.Field 10 import retrofit2.http.Field
11 import retrofit2.http.FormUrlEncoded 11 import retrofit2.http.FormUrlEncoded
@@ -124,54 +124,6 @@ interface AllItemApi : ApiService { @@ -124,54 +124,6 @@ interface AllItemApi : ApiService {
124 ): Observable<BaseResponse<ChallengeInfo>> 124 ): Observable<BaseResponse<ChallengeInfo>>
125 125
126 /** 126 /**
127 - * 提交答题(某一题)  
128 - * @param user_item_id 答题记录ID  
129 - * @param item_id 题目id  
130 - * @param answer 答案  
131 - */  
132 - @FormUrlEncoded  
133 - @POST("/api/item/item_sub_single")  
134 - fun subSingle(  
135 - @Field("user_item_id") user_item_id: Int,  
136 - @Field("item_id") item_id: Int,  
137 - @Field("answer") answer: String  
138 - ): Observable<BaseResponse<SubSingle>>  
139 -  
140 - /**  
141 - * 提交答题  
142 - * @param item_id 题目ID  
143 - * @param answer 答题结果[{'id':1,'answer':'A'}]  
144 - */  
145 - @FormUrlEncoded  
146 - @POST("/api/item/item_sub_single")  
147 - fun subSingle(  
148 - @Field("item_id") item_id: Int,  
149 - @Field("answer") answer: String  
150 - ): Observable<BaseResponse<Void>>  
151 -  
152 - /**  
153 - * 提交答题  
154 - * @param item_id 题目ID  
155 - * @param answer 答题结果[{'id':1,'answer':'A'}]  
156 - */  
157 - @FormUrlEncoded  
158 - @POST("/api/item/item_sub")  
159 - fun subAnswer(  
160 - @Field("item_id") item_id: Int,  
161 - @Field("answer") answer: String  
162 - ): Observable<BaseResponse<SubResult>>  
163 -  
164 - /**  
165 - * 交卷  
166 - * @param user_item_id 题目id  
167 - */  
168 - @FormUrlEncoded  
169 - @POST("/api/item/item_sub_paper")  
170 - fun subPaper(  
171 - @Field("user_item_id") user_item_id: Int  
172 - ): Observable<BaseResponse<SubResult>>  
173 -  
174 - /**  
175 * 错题列表 127 * 错题列表
176 * @param type 类型1=单选题2=多选题3=判断题 128 * @param type 类型1=单选题2=多选题3=判断题
177 * @param page 页数 129 * @param page 页数
1 package com.br_technology.securitytrain_master.base.network.api 1 package com.br_technology.securitytrain_master.base.network.api
2 2
3 import com.br_technology.securitytrain_master.base.network.response.* 3 import com.br_technology.securitytrain_master.base.network.response.*
4 -import com.br_technology.securitytrain_master.ui.bean.FavoriteData  
5 -import com.br_technology.securitytrain_master.ui.bean.MaterialDetail  
6 -import com.br_technology.securitytrain_master.ui.bean.UploadFileData 4 +import com.br_technology.securitytrain_master.ui.bean.*
7 import com.br_technology.securitytrain_master.ui.view.bank.bean.PracticeBean 5 import com.br_technology.securitytrain_master.ui.view.bank.bean.PracticeBean
8 import com.br_technology.securitytrain_master.ui.view.bank.bean.RankListBean 6 import com.br_technology.securitytrain_master.ui.view.bank.bean.RankListBean
9 import com.br_technology.securitytrain_master.ui.view.home.bean.* 7 import com.br_technology.securitytrain_master.ui.view.home.bean.*
@@ -266,7 +264,6 @@ interface ApiService { @@ -266,7 +264,6 @@ interface ApiService {
266 @Field("id") id: Int 264 @Field("id") id: Int
267 ): Observable<BaseResponse<CommonDetail<MaterialDetail>>> 265 ): Observable<BaseResponse<CommonDetail<MaterialDetail>>>
268 266
269 -  
270 /** 267 /**
271 * 收藏 268 * 收藏
272 */ 269 */
@@ -296,4 +293,40 @@ interface ApiService { @@ -296,4 +293,40 @@ interface ApiService {
296 @Field("page") page: Int, 293 @Field("page") page: Int,
297 @Field("page_num") page_num: String 294 @Field("page_num") page_num: String
298 ): Observable<BaseResponse<CommonDataList<CommonPage<FavoriteData>>>> 295 ): Observable<BaseResponse<CommonDataList<CommonPage<FavoriteData>>>>
  296 +
  297 + /**
  298 + * 提交答题(某一题)
  299 + * @param user_item_id 答题记录ID
  300 + * @param item_id 题目id
  301 + * @param answer 答案
  302 + */
  303 + @FormUrlEncoded
  304 + @POST("/api/item/item_sub_single")
  305 + fun subSingle(
  306 + @Field("user_item_id") user_item_id: Int,
  307 + @Field("item_id") item_id: Int,
  308 + @Field("answer") answer: String
  309 + ): Observable<BaseResponse<SubSingle>>
  310 +
  311 + /**
  312 + * 提交答题
  313 + * @param item_id 题目ID
  314 + * @param answer 答题结果[{'id':1,'answer':'A'}]
  315 + */
  316 + @FormUrlEncoded
  317 + @POST("/api/item/item_sub")
  318 + fun subAnswer(
  319 + @Field("item_id") item_id: Int,
  320 + @Field("answer") answer: String
  321 + ): Observable<BaseResponse<SubResult>>
  322 +
  323 + /**
  324 + * 交卷
  325 + * @param user_item_id 题目id
  326 + */
  327 + @FormUrlEncoded
  328 + @POST("/api/item/item_sub_paper")
  329 + fun subPaper(
  330 + @Field("user_item_id") user_item_id: Int
  331 + ): Observable<BaseResponse<SubResult>>
299 } 332 }
1 package com.br_technology.securitytrain_master.base.network.api 1 package com.br_technology.securitytrain_master.base.network.api
2 2
  3 +import com.br_technology.securitytrain_master.base.network.response.*
3 import com.br_technology.securitytrain_master.ui.bean.* 4 import com.br_technology.securitytrain_master.ui.bean.*
4 import com.br_technology.securitytrain_master.ui.view.bank.bean.SubjectData 5 import com.br_technology.securitytrain_master.ui.view.bank.bean.SubjectData
5 -import com.br_technology.securitytrain_master.base.network.response.BaseResponse  
6 -import com.br_technology.securitytrain_master.base.network.response.CommonDetail  
7 -import com.br_technology.securitytrain_master.base.network.response.CommonList  
8 -import com.br_technology.securitytrain_master.base.network.response.CommonPage  
9 import io.reactivex.rxjava3.core.Observable 6 import io.reactivex.rxjava3.core.Observable
10 import retrofit2.http.Field 7 import retrofit2.http.Field
11 import retrofit2.http.FormUrlEncoded 8 import retrofit2.http.FormUrlEncoded
@@ -136,14 +133,12 @@ interface TrainApi : ApiService { @@ -136,14 +133,12 @@ interface TrainApi : ApiService {
136 /** 133 /**
137 * 成长报告 134 * 成长报告
138 */ 135 */
139 - @FormUrlEncoded  
140 @POST("/api/train/train_report") 136 @POST("/api/train/train_report")
141 - fun trainReport(): Observable<BaseResponse<TrainReport>> 137 + fun trainReport(): Observable<BaseResponse<CommonReport<TrainReport>>>
142 138
143 /** 139 /**
144 * 课程备份列表 140 * 课程备份列表
145 */ 141 */
146 - @FormUrlEncoded  
147 @GET("/api/train/train_lesson_list_bak") 142 @GET("/api/train/train_lesson_list_bak")
148 fun trainLessonBak(): Observable<BaseResponse<Void>> 143 fun trainLessonBak(): Observable<BaseResponse<Void>>
149 } 144 }
@@ -8,6 +8,7 @@ package com.br_technology.securitytrain_master.base.network.response @@ -8,6 +8,7 @@ package com.br_technology.securitytrain_master.base.network.response
8 8
9 open class BaseResponse<T>(var data: T, var code: Int = -1, var msg: String = "") 9 open class BaseResponse<T>(var data: T, var code: Int = -1, var msg: String = "")
10 open class CommonList<T>(var list: List<T>) 10 open class CommonList<T>(var list: List<T>)
  11 +open class CommonReport<T>(var report: T)
11 open class CommonDataList<T>(var list: T) 12 open class CommonDataList<T>(var list: T)
12 open class CommonDetail<T>(var detail: T) 13 open class CommonDetail<T>(var detail: T)
13 open class CommonDetailList<T>(var list: T) 14 open class CommonDetailList<T>(var list: T)
@@ -57,4 +57,13 @@ class DocRepository(loadState: MutableLiveData<State>) : ApiRepository(loadState @@ -57,4 +57,13 @@ class DocRepository(loadState: MutableLiveData<State>) : ApiRepository(loadState
57 ) { 57 ) {
58 addRequest(docService.getCollectTxtLessonList(page, "10"), liveData) 58 addRequest(docService.getCollectTxtLessonList(page, "10"), liveData)
59 } 59 }
  60 +
  61 + fun collect(
  62 + type: String,
  63 + favorite_id: String,
  64 + liveData: MutableLiveData<BaseResponse<Void>>
  65 + ) {
  66 + addRequest(lessonService.collect(type, favorite_id), liveData)
  67 + }
  68 +
60 } 69 }
@@ -2,13 +2,15 @@ package com.br_technology.securitytrain_master.base.repository @@ -2,13 +2,15 @@ package com.br_technology.securitytrain_master.base.repository
2 2
3 import androidx.lifecycle.MutableLiveData 3 import androidx.lifecycle.MutableLiveData
4 import com.br_technology.securitytrain_master.base.common.State 4 import com.br_technology.securitytrain_master.base.common.State
5 -import com.br_technology.securitytrain_master.base.network.response.*  
6 -import com.br_technology.securitytrain_master.base.repository.ApiRepository 5 +import com.br_technology.securitytrain_master.base.network.response.BaseResponse
  6 +import com.br_technology.securitytrain_master.base.network.response.CommonDetailList
  7 +import com.br_technology.securitytrain_master.base.network.response.CommonList
  8 +import com.br_technology.securitytrain_master.base.network.response.CommonPage
7 import com.br_technology.securitytrain_master.ui.bean.* 9 import com.br_technology.securitytrain_master.ui.bean.*
8 import com.br_technology.securitytrain_master.ui.view.bank.bean.PracticeBean 10 import com.br_technology.securitytrain_master.ui.view.bank.bean.PracticeBean
  11 +import com.br_technology.securitytrain_master.ui.view.bank.bean.StartItemBean
9 import com.br_technology.securitytrain_master.ui.view.bank.bean.SubjectData 12 import com.br_technology.securitytrain_master.ui.view.bank.bean.SubjectData
10 import com.br_technology.securitytrain_master.ui.view.bank.bean.TestSubject 13 import com.br_technology.securitytrain_master.ui.view.bank.bean.TestSubject
11 -import com.br_technology.securitytrain_master.ui.view.bank.bean.StartItemBean  
12 14
13 /** 15 /**
14 * Author by YSir 16 * Author by YSir
@@ -100,15 +102,6 @@ class ItemRepository(loadState: MutableLiveData<State>) : ApiRepository(loadStat @@ -100,15 +102,6 @@ class ItemRepository(loadState: MutableLiveData<State>) : ApiRepository(loadStat
100 addRequest(itemService.subSingle(user_item_id, item_id, answer), liveData) 102 addRequest(itemService.subSingle(user_item_id, item_id, answer), liveData)
101 } 103 }
102 104
103 - //提交答题(某一题)  
104 - fun subSingle(  
105 - item_id: Int,  
106 - answer: String,  
107 - liveData: MutableLiveData<BaseResponse<Void>>  
108 - ) {  
109 - addRequest(itemService.subSingle(item_id, answer), liveData)  
110 - }  
111 -  
112 //subAnswer 105 //subAnswer
113 fun subAnswer( 106 fun subAnswer(
114 item_id: Int, 107 item_id: Int,
@@ -2,13 +2,9 @@ package com.br_technology.securitytrain_master.base.repository @@ -2,13 +2,9 @@ package com.br_technology.securitytrain_master.base.repository
2 2
3 import androidx.lifecycle.MutableLiveData 3 import androidx.lifecycle.MutableLiveData
4 import com.br_technology.securitytrain_master.base.common.State 4 import com.br_technology.securitytrain_master.base.common.State
5 -import com.br_technology.securitytrain_master.base.repository.ApiRepository 5 +import com.br_technology.securitytrain_master.base.network.response.*
6 import com.br_technology.securitytrain_master.ui.bean.* 6 import com.br_technology.securitytrain_master.ui.bean.*
7 import com.br_technology.securitytrain_master.ui.view.bank.bean.SubjectData 7 import com.br_technology.securitytrain_master.ui.view.bank.bean.SubjectData
8 -import com.br_technology.securitytrain_master.base.network.response.BaseResponse  
9 -import com.br_technology.securitytrain_master.base.network.response.CommonDetail  
10 -import com.br_technology.securitytrain_master.base.network.response.CommonList  
11 -import com.br_technology.securitytrain_master.base.network.response.CommonPage  
12 8
13 /** 9 /**
14 * Author by YSir 10 * Author by YSir
@@ -80,11 +76,35 @@ class TrainRepository(loadState: MutableLiveData<State>) : ApiRepository(loadSta @@ -80,11 +76,35 @@ class TrainRepository(loadState: MutableLiveData<State>) : ApiRepository(loadSta
80 addRequest(trainService.trainChatRead(train_class_id), liveData) 76 addRequest(trainService.trainChatRead(train_class_id), liveData)
81 } 77 }
82 78
83 - fun trainReport(liveData: MutableLiveData<BaseResponse<TrainReport>>){ 79 + fun trainReport(liveData: MutableLiveData<BaseResponse<CommonReport<TrainReport>>>){
84 addRequest(trainService.trainReport(), liveData) 80 addRequest(trainService.trainReport(), liveData)
85 } 81 }
86 82
87 fun trainLessonBak(liveData: MutableLiveData<BaseResponse<Void>>){ 83 fun trainLessonBak(liveData: MutableLiveData<BaseResponse<Void>>){
88 addRequest(trainService.trainLessonBak(), liveData) 84 addRequest(trainService.trainLessonBak(), liveData)
89 } 85 }
  86 +
  87 + //提交答题(某一题)
  88 + fun subSingle(
  89 + user_item_id: Int,
  90 + item_id: Int,
  91 + answer: String,
  92 + liveData: MutableLiveData<BaseResponse<SubSingle>>
  93 + ) {
  94 + addRequest(itemService.subSingle(user_item_id, item_id, answer), liveData)
  95 + }
  96 +
  97 + //subAnswer
  98 + fun subAnswer(
  99 + item_id: Int,
  100 + answer: String,
  101 + liveData: MutableLiveData<BaseResponse<SubResult>>
  102 + ) {
  103 + addRequest(itemService.subAnswer(item_id, answer), liveData)
  104 + }
  105 +
  106 + //交卷
  107 + fun subPaper(user_item_id: Int, liveData: MutableLiveData<BaseResponse<SubResult>>) {
  108 + addRequest(itemService.subPaper(user_item_id), liveData)
  109 + }
90 } 110 }
@@ -34,12 +34,6 @@ open class OptionArr( @@ -34,12 +34,6 @@ open class OptionArr(
34 */ 34 */
35 open class SubjectData( 35 open class SubjectData(
36 var user_item_id: Int, // 答题id 36 var user_item_id: Int, // 答题id
37 - var type1: Int, // 单选题索引  
38 - var type2: Int, // 多选题索引  
39 - var type3: Int, // 判断题索引  
40 - var type1_num: Int, // 单选题总数  
41 - var type2_num: Int, // 多选题总数  
42 - var type3_num: Int, // 判断题总数  
43 var over_second: Int, // 答题剩余时间 37 var over_second: Int, // 答题剩余时间
44 var list: List<UserSubject>, 38 var list: List<UserSubject>,
45 var remark: String 39 var remark: String
@@ -48,24 +42,12 @@ open class SubjectData( @@ -48,24 +42,12 @@ open class SubjectData(
48 //专项答题 42 //专项答题
49 open class SubjectSpecial( 43 open class SubjectSpecial(
50 user_item_id: Int, // 答题id 44 user_item_id: Int, // 答题id
51 - type1: Int, // 单选题索引  
52 - type2: Int, // 多选题索引  
53 - type3: Int, // 判断题索引  
54 - type1_num: Int, // 单选题总数  
55 - type2_num: Int, // 多选题总数  
56 - type3_num: Int, // 判断题总数  
57 over_second: Int, // 答题剩余时间 45 over_second: Int, // 答题剩余时间
58 list: List<UserSubject>, 46 list: List<UserSubject>,
59 remark: String, 47 remark: String,
60 var user_answer: String 48 var user_answer: String
61 ) : SubjectData( 49 ) : SubjectData(
62 user_item_id, 50 user_item_id,
63 - type1,  
64 - type2,  
65 - type3,  
66 - type1_num,  
67 - type2_num,  
68 - type3_num,  
69 over_second, 51 over_second,
70 list, 52 list,
71 remark 53 remark
@@ -127,39 +127,38 @@ open class TrainDetail( @@ -127,39 +127,38 @@ open class TrainDetail(
127 */ 127 */
128 open class TrainReport( 128 open class TrainReport(
129 var user: TrainReportUser,//上报人信息 129 var user: TrainReportUser,//上报人信息
130 - var create_time_text: String,//var 2021-10-30 09:35", // 答题开始时间  
131 - var update_time_text: String,//var 2021-10-30 09:35" // 答题结束时间  
132 var study_list: List<TrainReportStudy>, 130 var study_list: List<TrainReportStudy>,
133 - var trainclass: TrainReportClass, 131 +// var trainclass: TrainReportClass,
134 var exam_list: List<TrainReportExam> 132 var exam_list: List<TrainReportExam>
135 ) 133 )
136 134
137 open class TrainReportUser( 135 open class TrainReportUser(
138 - var id: Int,  
139 - var nickname: String, // 姓名  
140 - var mobile: String,//手机号", // 手机号  
141 - var gender: Int, // 性别1=男2=女 136 +// var id: Int,
  137 +// var nickname: String, // 姓名
  138 +// var mobile: String,//手机号", // 手机号
  139 +// var gender: Int, // 性别1=男2=女
142 var avatar: String,//"https://security.brofirst.cn/uploads/20211030/e777a39142bf8ab8dd3e02b6eb9f9d9f.jpg", // 头像 140 var avatar: String,//"https://security.brofirst.cn/uploads/20211030/e777a39142bf8ab8dd3e02b6eb9f9d9f.jpg", // 头像
143 - var score: Int, // 积分  
144 - var identity: String, // 身份证号  
145 - var user_id: Int,  
146 - var createtime: Long, // 建档日期  
147 - var class_hours_count: Int, // 培训总学时  
148 - var item_count: Int, // 练习题量  
149 - var lessons: String, // 结业课程  
150 - var is_end: Int, // 是否结业0=否1=是  
151 - var class_name: String, // 班级名称  
152 - var train_sort_name: String, // 培训类型  
153 - var time: String, // 时间  
154 - var train_name: String, // 培训单位  
155 - var class_hours: Int, // 培训学时 141 + var score: Int
  142 +// , // 积分
  143 +// var identity: String, // 身份证号
  144 +// var user_id: Int,
  145 +// var createtime: Long, // 建档日期
  146 +// var class_hours_count: Int, // 培训总学时
  147 +// var item_count: Int, // 练习题量
  148 +// var lessons: String, // 结业课程
  149 +// var is_end: Int, // 是否结业0=否1=是
  150 +// var class_name: String, // 班级名称
  151 +// var train_sort_name: String, // 培训类型
  152 +// var time: String, // 时间
  153 +// var train_name: String, // 培训单位
  154 +// var class_hours: Int, // 培训学时
156 ) 155 )
157 156
158 open class TrainStudyTrain( 157 open class TrainStudyTrain(
159 var id: Int, 158 var id: Int,
160 var company_id: Int, 159 var company_id: Int,
161 var pid: Int, 160 var pid: Int,
162 - var train_sort_id: Int, 161 + var train_sort_id: String,
163 var name: String, // 培训名称 162 var name: String, // 培训名称
164 var depart_ids: String, 163 var depart_ids: String,
165 var pos_ids: String, 164 var pos_ids: String,
@@ -167,7 +166,10 @@ open class TrainStudyTrain( @@ -167,7 +166,10 @@ open class TrainStudyTrain(
167 var plan_num_complete: Int, 166 var plan_num_complete: Int,
168 var start_time: Long, 167 var start_time: Long,
169 var end_time: Long, 168 var end_time: Long,
170 - var status: String 169 + var status: String,
  170 + var trainsort: TrainStudySort,
  171 + var update_time_text: String,
  172 + var trainclass:TrainClass
171 ) 173 )
172 174
173 open class TrainStudySort( 175 open class TrainStudySort(
@@ -181,12 +183,11 @@ open class TrainReportStudy( @@ -181,12 +183,11 @@ open class TrainReportStudy(
181 var id: Int, 183 var id: Int,
182 var distance: String, 184 var distance: String,
183 var status: String, // 结业状态0=未结业1=已结业 185 var status: String, // 结业状态0=未结业1=已结业
184 - var view_len: Int, 186 + var view_len: String,
185 var class_name: String, // 课程名称 187 var class_name: String, // 课程名称
186 var update_time: String, // 时间 188 var update_time: String, // 时间
187 var class_hours: Int, // 学时 189 var class_hours: Int, // 学时
188 - var train: TrainStudyTrain,  
189 - var trainsort: TrainStudySort 190 + var train: TrainStudyTrain
190 ) 191 )
191 192
192 open class TrainReportClass( 193 open class TrainReportClass(
@@ -21,6 +21,11 @@ class AnswerSheetActivity : BaseLifeCycleActivity<AnswerSheetViewModel, Activity @@ -21,6 +21,11 @@ class AnswerSheetActivity : BaseLifeCycleActivity<AnswerSheetViewModel, Activity
21 ActivityAnswerSheetBinding::inflate 21 ActivityAnswerSheetBinding::inflate
22 ) { 22 ) {
23 23
  24 + override fun initView() {
  25 + super.initView()
  26 + val dataResult = intent.getStringExtra("title")
  27 + binding.toolBar.setTitle(dataResult ?: "")
  28 + }
24 29
25 override fun initData() { 30 override fun initData() {
26 super.initData() 31 super.initData()
@@ -46,7 +51,7 @@ class AnswerSheetActivity : BaseLifeCycleActivity<AnswerSheetViewModel, Activity @@ -46,7 +51,7 @@ class AnswerSheetActivity : BaseLifeCycleActivity<AnswerSheetViewModel, Activity
46 }) 51 })
47 // 答题卡适配器 52 // 答题卡适配器
48 val answerSheetAdapter = AnswerSheetAdapter() 53 val answerSheetAdapter = AnswerSheetAdapter()
49 - answerSheetAdapter.showCorrect=showCorrect 54 + answerSheetAdapter.showCorrect = showCorrect
50 val list = dataResult?.toList() as List<String> 55 val list = dataResult?.toList() as List<String>
51 sheet.adapter = answerSheetAdapter 56 sheet.adapter = answerSheetAdapter
52 answerSheetAdapter.addList(list) 57 answerSheetAdapter.addList(list)
@@ -6,8 +6,8 @@ import android.view.View @@ -6,8 +6,8 @@ import android.view.View
6 import androidx.activity.result.contract.ActivityResultContracts 6 import androidx.activity.result.contract.ActivityResultContracts
7 import androidx.core.content.ContextCompat 7 import androidx.core.content.ContextCompat
8 import com.br_technology.securitytrain_master.R 8 import com.br_technology.securitytrain_master.R
9 -import com.br_technology.securitytrain_master.databinding.ActivityPracticeBinding  
10 import com.br_technology.securitytrain_master.base.common.ConstantType 9 import com.br_technology.securitytrain_master.base.common.ConstantType
  10 +import com.br_technology.securitytrain_master.databinding.ActivityPracticeBinding
11 import com.br_technology.securitytrain_master.ui.view.bank.adapter.PracticePaperAdapter 11 import com.br_technology.securitytrain_master.ui.view.bank.adapter.PracticePaperAdapter
12 import com.br_technology.securitytrain_master.ui.view.bank.viewmodel.PracticeViewModel 12 import com.br_technology.securitytrain_master.ui.view.bank.viewmodel.PracticeViewModel
13 import com.br_technology.securitytrain_master.view.DialogTitle 13 import com.br_technology.securitytrain_master.view.DialogTitle
@@ -58,6 +58,7 @@ class ChallengeActivity : @@ -58,6 +58,7 @@ class ChallengeActivity :
58 val intent = Intent(baseContext, AnswerSheetActivity::class.java) 58 val intent = Intent(baseContext, AnswerSheetActivity::class.java)
59 .putStringArrayListExtra("resultData", mPagerAdapter.getArrayList()) 59 .putStringArrayListExtra("resultData", mPagerAdapter.getArrayList())
60 .putExtra("showCorrect", mPagerAdapter.showCorrect) 60 .putExtra("showCorrect", mPagerAdapter.showCorrect)
  61 + .putExtra("title", binding.toolBar.getTitle())
61 startForResult.launch(intent) 62 startForResult.launch(intent)
62 } 63 }
63 }) 64 })
@@ -84,6 +84,7 @@ class ExamDetailActivity : @@ -84,6 +84,7 @@ class ExamDetailActivity :
84 val intent = Intent(baseContext, AnswerSheetActivity::class.java) 84 val intent = Intent(baseContext, AnswerSheetActivity::class.java)
85 .putStringArrayListExtra("resultData", mPagerAdapter.getArrayList()) 85 .putStringArrayListExtra("resultData", mPagerAdapter.getArrayList())
86 .putExtra("showCorrect", mPagerAdapter.showCorrect) 86 .putExtra("showCorrect", mPagerAdapter.showCorrect)
  87 + .putExtra("title", binding.toolBar.getTitle())
87 startForResult.launch(intent) 88 startForResult.launch(intent)
88 } 89 }
89 }) 90 })
@@ -6,8 +6,8 @@ import android.view.View @@ -6,8 +6,8 @@ import android.view.View
6 import androidx.activity.result.contract.ActivityResultContracts 6 import androidx.activity.result.contract.ActivityResultContracts
7 import androidx.core.content.ContextCompat 7 import androidx.core.content.ContextCompat
8 import com.br_technology.securitytrain_master.R 8 import com.br_technology.securitytrain_master.R
9 -import com.br_technology.securitytrain_master.databinding.ActivityPracticeBinding  
10 import com.br_technology.securitytrain_master.base.common.ConstantType 9 import com.br_technology.securitytrain_master.base.common.ConstantType
  10 +import com.br_technology.securitytrain_master.databinding.ActivityPracticeBinding
11 import com.br_technology.securitytrain_master.ui.view.bank.adapter.PracticePaperAdapter 11 import com.br_technology.securitytrain_master.ui.view.bank.adapter.PracticePaperAdapter
12 import com.br_technology.securitytrain_master.ui.view.bank.viewmodel.PracticeViewModel 12 import com.br_technology.securitytrain_master.ui.view.bank.viewmodel.PracticeViewModel
13 import com.br_technology.securitytrain_master.view.DialogDetermine 13 import com.br_technology.securitytrain_master.view.DialogDetermine
@@ -81,6 +81,8 @@ class PracticeActivity : @@ -81,6 +81,8 @@ class PracticeActivity :
81 val intent = Intent(this@PracticeActivity, AnswerSheetActivity::class.java) 81 val intent = Intent(this@PracticeActivity, AnswerSheetActivity::class.java)
82 .putStringArrayListExtra("resultData", mPagerAdapter.getArrayList()) 82 .putStringArrayListExtra("resultData", mPagerAdapter.getArrayList())
83 .putExtra("showCorrect", mPagerAdapter.showCorrect) 83 .putExtra("showCorrect", mPagerAdapter.showCorrect)
  84 + .putExtra("title", binding.toolBar.getTitle())
  85 +
84 startForResult.launch(intent) 86 startForResult.launch(intent)
85 } 87 }
86 }) 88 })
@@ -6,8 +6,8 @@ import android.view.View @@ -6,8 +6,8 @@ import android.view.View
6 import androidx.activity.result.contract.ActivityResultContracts 6 import androidx.activity.result.contract.ActivityResultContracts
7 import androidx.core.content.ContextCompat 7 import androidx.core.content.ContextCompat
8 import com.br_technology.securitytrain_master.R 8 import com.br_technology.securitytrain_master.R
9 -import com.br_technology.securitytrain_master.databinding.ActivityPracticeBinding  
10 import com.br_technology.securitytrain_master.base.common.ConstantType 9 import com.br_technology.securitytrain_master.base.common.ConstantType
  10 +import com.br_technology.securitytrain_master.databinding.ActivityPracticeBinding
11 import com.br_technology.securitytrain_master.ui.view.bank.adapter.PracticePaperAdapter 11 import com.br_technology.securitytrain_master.ui.view.bank.adapter.PracticePaperAdapter
12 import com.br_technology.securitytrain_master.ui.view.bank.viewmodel.PracticeViewModel 12 import com.br_technology.securitytrain_master.ui.view.bank.viewmodel.PracticeViewModel
13 import com.br_technology.securitytrain_master.view.DialogTitle 13 import com.br_technology.securitytrain_master.view.DialogTitle
@@ -82,6 +82,7 @@ class QuestionsActivity : @@ -82,6 +82,7 @@ class QuestionsActivity :
82 val intent = Intent(this@QuestionsActivity, AnswerSheetActivity::class.java) 82 val intent = Intent(this@QuestionsActivity, AnswerSheetActivity::class.java)
83 .putStringArrayListExtra("resultData", mPagerAdapter.getArrayList()) 83 .putStringArrayListExtra("resultData", mPagerAdapter.getArrayList())
84 .putExtra("showCorrect", mPagerAdapter.showCorrect) 84 .putExtra("showCorrect", mPagerAdapter.showCorrect)
  85 + .putExtra("title", binding.toolBar.getTitle())
85 startForResult.launch(intent) 86 startForResult.launch(intent)
86 } 87 }
87 }) 88 })
@@ -193,4 +194,11 @@ class QuestionsActivity : @@ -193,4 +194,11 @@ class QuestionsActivity :
193 } 194 }
194 } 195 }
195 196
  197 + override fun onDestroy() {
  198 + if (titleDialog.isShowing) {
  199 + titleDialog.dismiss()
  200 + }
  201 + super.onDestroy()
  202 + }
  203 +
196 } 204 }
@@ -8,7 +8,6 @@ import android.text.SpannableString @@ -8,7 +8,6 @@ import android.text.SpannableString
8 import android.text.Spanned 8 import android.text.Spanned
9 import android.text.style.AbsoluteSizeSpan 9 import android.text.style.AbsoluteSizeSpan
10 import android.text.style.ForegroundColorSpan 10 import android.text.style.ForegroundColorSpan
11 -import android.util.Log  
12 import android.view.LayoutInflater 11 import android.view.LayoutInflater
13 import android.view.View 12 import android.view.View
14 import android.view.ViewGroup 13 import android.view.ViewGroup
@@ -16,16 +15,17 @@ import android.view.WindowManager @@ -16,16 +15,17 @@ import android.view.WindowManager
16 import android.widget.TextView 15 import android.widget.TextView
17 import androidx.core.content.ContextCompat 16 import androidx.core.content.ContextCompat
18 import com.br_technology.securitytrain_master.R 17 import com.br_technology.securitytrain_master.R
  18 +import com.br_technology.securitytrain_master.base.common.ConstantType
19 import com.br_technology.securitytrain_master.base.view.BaseAdapter 19 import com.br_technology.securitytrain_master.base.view.BaseAdapter
20 import com.br_technology.securitytrain_master.base.view.BaseViewHolder 20 import com.br_technology.securitytrain_master.base.view.BaseViewHolder
21 import com.br_technology.securitytrain_master.databinding.AdapterContentPracticeItemBinding 21 import com.br_technology.securitytrain_master.databinding.AdapterContentPracticeItemBinding
22 import com.br_technology.securitytrain_master.databinding.AdapterPictureBinding 22 import com.br_technology.securitytrain_master.databinding.AdapterPictureBinding
23 import com.br_technology.securitytrain_master.databinding.AdapterTopicBinding 23 import com.br_technology.securitytrain_master.databinding.AdapterTopicBinding
24 import com.br_technology.securitytrain_master.expand.dp2px 24 import com.br_technology.securitytrain_master.expand.dp2px
25 -import com.br_technology.securitytrain_master.base.common.ConstantType  
26 import com.br_technology.securitytrain_master.ui.bean.Answer 25 import com.br_technology.securitytrain_master.ui.bean.Answer
27 import com.br_technology.securitytrain_master.ui.view.bank.bean.OptionArr 26 import com.br_technology.securitytrain_master.ui.view.bank.bean.OptionArr
28 import com.br_technology.securitytrain_master.ui.view.bank.bean.TestSubject 27 import com.br_technology.securitytrain_master.ui.view.bank.bean.TestSubject
  28 +import com.br_technology.securitytrain_master.ui.view.bank.bean.UserSubject
29 import com.br_technology.securitytrain_master.util.GlideEnginePic 29 import com.br_technology.securitytrain_master.util.GlideEnginePic
30 import com.br_technology.securitytrain_master.view.listener.OnItemClickListener 30 import com.br_technology.securitytrain_master.view.listener.OnItemClickListener
31 import com.br_technology.securitytrain_master.view.listener.OnItemListener 31 import com.br_technology.securitytrain_master.view.listener.OnItemListener
@@ -374,6 +374,192 @@ class PracticePaperAdapter(private val isShowPosition: Boolean = true) : @@ -374,6 +374,192 @@ class PracticePaperAdapter(private val isShowPosition: Boolean = true) :
374 374
375 } 375 }
376 376
  377 +class CourseTestPaperAdapter(private val isShowPosition: Boolean = true):
  378 + BaseAdapter<UserSubject, AdapterContentPracticeItemBinding>() {
  379 + // 是否显示正确答案
  380 + var showCorrect = false
  381 + var selectResultData = HashMap<Int, List<Int>>()
  382 +
  383 + override fun getViewBinding(
  384 + context: Context,
  385 + parent: ViewGroup,
  386 + viewType: Int,
  387 + from: LayoutInflater
  388 + ): AdapterContentPracticeItemBinding {
  389 + return AdapterContentPracticeItemBinding.inflate(from, parent, false)
  390 + }
  391 +
  392 + @SuppressLint("SetTextI18n")
  393 + override fun onBind(
  394 + holder: AdapterContentPracticeItemBinding,
  395 + index: Int,
  396 + data: UserSubject
  397 + ) {
  398 +
  399 + val value = if (isShowPosition) {
  400 + "(${index + 1}/${itemCount})${data.title}${ConstantType.getType(data.type)}"
  401 + } else {
  402 + "${data.title}${ConstantType.getType(data.type)}"
  403 + }
  404 + val span = SpannableString(value)
  405 +
  406 + span.setSpan(
  407 + ForegroundColorSpan(Color.parseColor("#C8C9CC")),
  408 + value.length - 4,
  409 + value.length,
  410 + Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
  411 + )
  412 + span.setSpan(
  413 + AbsoluteSizeSpan(14.dp2px()),
  414 + value.length - 4,
  415 + value.length,
  416 + Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
  417 + )
  418 +
  419 + holder.topic.text = span
  420 + val adapterChild = TopicAdapter()
  421 + adapterChild.addList(data.options_arr)
  422 + holder.topicRecycler.adapter = adapterChild
  423 + holder.txtCorrect.text = "正确答案:${data.correct}"
  424 + holder.txtAnalysis.text = "解析:${data.remark}"
  425 + holder.contentAnalysis.visibility = if (showCorrect) View.VISIBLE else View.GONE
  426 + adapterChild.let {
  427 + val type = data.type.toInt()
  428 + it.type = type
  429 + it.showCorrect = showCorrect
  430 + if (selectResultData.containsKey(index)) {
  431 + selectResultData[index]?.let { data ->
  432 + if (data.isNotEmpty()) {
  433 + it.mSelectIndex = data as MutableList<Int>
  434 + }
  435 + }
  436 + }
  437 + it.setItemClickListener(object : OnItemListener {
  438 + override fun onItemClick(position: Int) {
  439 + if (type == 1 || type == 3) {
  440 + if (it.mSelectIndex.isEmpty()) {
  441 + it.mSelectIndex.add(position)
  442 + } else {
  443 + it.mSelectIndex[0] = position
  444 + }
  445 + it.notifyDataSetChanged()
  446 + } else {
  447 + it.itemClick(position)
  448 + }
  449 + selectResultData[index] = it.mSelectIndex
  450 + }
  451 + })
  452 + }
  453 + }
  454 +
  455 +
  456 + override fun addList(t: List<UserSubject>) {
  457 + super.addList(t)
  458 + for (data in getData()) {
  459 + val position = getData().indexOf(data)
  460 + selectResultData[position] = listOf()
  461 + }
  462 + }
  463 +
  464 + private fun getResultData(): ArrayList<List<Int>> {
  465 + val data = ArrayList<List<Int>>()
  466 + val result = selectResultData.keys
  467 + val dataKey = mutableListOf<Int>()
  468 + for (item in result) {
  469 + dataKey.add(item)
  470 + }
  471 + dataKey.sort()
  472 + for (index in dataKey) {
  473 + selectResultData[index]?.let {
  474 + data.add(it)
  475 + }
  476 + }
  477 + return data
  478 + }
  479 +
  480 + fun getAnswer(): ArrayList<Answer> {
  481 + val data = ArrayList<Answer>()
  482 + val list = getResultData()
  483 + val listSubject = getData()
  484 + for (res in list.indices) {
  485 + val pos = list[res]
  486 + val ppp = listSubject[res]
  487 + data.add(Answer(ppp.id, getAnswer(ppp.options_arr, pos)))
  488 + }
  489 + return data
  490 + }
  491 +
  492 + fun getAnswer(optionArr: List<OptionArr>, data: List<Int>): String {
  493 + var str = ""
  494 + if (data.isNotEmpty()) {
  495 + for (res in data) {
  496 + if (res < optionArr.size) {
  497 + str = str + optionArr[res].option_name + ","
  498 + }
  499 + }
  500 + }
  501 + return str.substringBeforeLast(",");
  502 + }
  503 +
  504 + fun getCount(): Int {
  505 + var count = 0
  506 + for (data in selectResultData) {
  507 + if (data.value.isNotEmpty()) {
  508 + count++
  509 + }
  510 + }
  511 + return count
  512 + }
  513 +
  514 + fun getArrayList(): ArrayList<String> {
  515 + val list = ArrayList<String>()
  516 + val dataList = getResultData()
  517 + for (data in getData()) {
  518 + val position = getData().indexOf(data)
  519 + if (dataList[position].isEmpty()) {
  520 + list.add("")
  521 + } else {
  522 + val element = if (isTrue(data, dataList[position], data.options_arr)
  523 + ) "1" else "0"
  524 + list.add(element)
  525 + }
  526 + }
  527 + return list
  528 + }
  529 +
  530 + private fun isTrue(
  531 + testSubject: UserSubject,
  532 + mSelectIndex: List<Int>,
  533 + optionArr: List<OptionArr>
  534 + ): Boolean {
  535 + var bool = false
  536 + val type = testSubject.type.toInt()
  537 + if (type == 1 || type == 3) {
  538 + bool = if (mSelectIndex.isNotEmpty()) {
  539 + optionArr[mSelectIndex[0]].is_correct == 1
  540 + } else {
  541 + false
  542 + }
  543 + }
  544 + if (type == 2) {
  545 + var count = 0
  546 + var dataCount = 0
  547 + for (item in optionArr) {
  548 + val position = optionArr.indexOf(item)
  549 + if (item.is_correct == 1) {
  550 + if (mSelectIndex.contains(position)) {
  551 + count++
  552 + }
  553 + dataCount++;
  554 + }
  555 + }
  556 + bool = count == dataCount && mSelectIndex.size == count
  557 + }
  558 + return bool
  559 + }
  560 +
  561 +}
  562 +
377 class PictureAdapter(context: Context) : BaseAdapter<String, AdapterPictureBinding>() { 563 class PictureAdapter(context: Context) : BaseAdapter<String, AdapterPictureBinding>() {
378 private val options: RequestOptions 564 private val options: RequestOptions
379 565
@@ -58,14 +58,12 @@ class BankFragment : @@ -58,14 +58,12 @@ class BankFragment :
58 startActivity(LeaderboardActivity::class.java) 58 startActivity(LeaderboardActivity::class.java)
59 } 59 }
60 60
61 -  
62 // 练习题列表 61 // 练习题列表
63 practiceAdapter = PracticeAdapter(R.layout.adapter_practice, practiceList) 62 practiceAdapter = PracticeAdapter(R.layout.adapter_practice, practiceList)
64 practice.adapter = practiceAdapter 63 practice.adapter = practiceAdapter
65 practice.layoutManager = LinearLayoutManager(activity) 64 practice.layoutManager = LinearLayoutManager(activity)
66 65
67 practiceAdapter?.setOnItemClickListener { _, _, position -> 66 practiceAdapter?.setOnItemClickListener { _, _, position ->
68 -  
69 activity?.startActivity( 67 activity?.startActivity(
70 Intent( 68 Intent(
71 activity, 69 activity,
  1 +package com.br_technology.securitytrain_master.ui.view.home.activity.course
  2 +
  3 +import com.br_technology.securitytrain_master.base.common.ConstantParamKey
  4 +import com.br_technology.securitytrain_master.databinding.ActivityPracticeBinding
  5 +import com.br_technology.securitytrain_master.ui.bean.CourseParam
  6 +import com.br_technology.securitytrain_master.ui.view.home.viewmodel.CoursePracticeViewModel
  7 +import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleActivity
  8 +
  9 +/**
  10 + * Author by YSir
  11 + * Date on 2022/1/23.
  12 + * description
  13 + * PS: Not easy to write code, please indicate.
  14 + */
  15 +/**
  16 + * 课程练习详情
  17 + */
  18 +class CourseExamActivity :
  19 + BaseLifeCycleActivity<CoursePracticeViewModel, ActivityPracticeBinding>(ActivityPracticeBinding::inflate) {
  20 + override fun initDataObserver() {
  21 + }
  22 +
  23 + private var courseBean: CourseParam? = null
  24 +
  25 + override fun initData() {
  26 + super.initData()
  27 + courseBean = intent.getParcelableExtra(ConstantParamKey.COURSE_BEAN)
  28 + courseBean?.let {
  29 + mViewModel.startExam(it.mTrainClassId.toInt())
  30 + }
  31 + }
  32 +}
  1 +package com.br_technology.securitytrain_master.ui.view.home.activity.course
  2 +
  3 +import android.app.Activity
  4 +import android.content.Intent
  5 +import android.view.View
  6 +import androidx.activity.result.contract.ActivityResultContracts
  7 +import androidx.core.content.ContextCompat
  8 +import com.br_technology.securitytrain_master.R
  9 +import com.br_technology.securitytrain_master.base.common.ConstantParamKey
  10 +import com.br_technology.securitytrain_master.databinding.ActivityPracticeBinding
  11 +import com.br_technology.securitytrain_master.ui.bean.CourseParam
  12 +import com.br_technology.securitytrain_master.ui.view.bank.activity.AnswerSheetActivity
  13 +import com.br_technology.securitytrain_master.ui.view.bank.adapter.CourseTestPaperAdapter
  14 +import com.br_technology.securitytrain_master.ui.view.home.viewmodel.CoursePracticeViewModel
  15 +import com.br_technology.securitytrain_master.view.DialogTitle
  16 +import com.br_technology.securitytrain_master.view.listener.DialogListener
  17 +import com.br_technology.securitytrain_master.view.listener.ToolBarClickListener
  18 +import com.luck.picture.lib.tools.ToastUtils
  19 +import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleActivity
  20 +
  21 +/**
  22 + * Author by YSir
  23 + * Date on 2022/1/23.
  24 + * description
  25 + * PS: Not easy to write code, please indicate.
  26 + */
  27 +/**
  28 + * 课程练习详情
  29 + */
  30 +class CoursePractiseActivity :
  31 + BaseLifeCycleActivity<CoursePracticeViewModel, ActivityPracticeBinding>(ActivityPracticeBinding::inflate) {
  32 +
  33 + private var courseBean: CourseParam? = null
  34 +
  35 + private val mPagerAdapter = CourseTestPaperAdapter()
  36 + private var userItemId = 0
  37 + private var isFinish = false
  38 + private val titleDialog by lazy {
  39 + DialogTitle(this)
  40 + }
  41 +
  42 + private val startForResult =
  43 + registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
  44 + if (result.resultCode == Activity.RESULT_OK) {
  45 + //页面返回值
  46 + val data = result.data?.getIntExtra("position", 0)
  47 + if (data != null) {
  48 + binding.previous.visibility = View.VISIBLE
  49 + binding.finishJob.visibility = View.GONE
  50 + binding.next.visibility = View.VISIBLE
  51 + if (data == 0) {
  52 + binding.previous.visibility = View.GONE
  53 + binding.finishJob.visibility = View.GONE
  54 + binding.next.visibility = View.VISIBLE
  55 + }
  56 + if (data == mPagerAdapter.itemCount - 1) {
  57 + binding.previous.visibility = View.VISIBLE
  58 + binding.finishJob.visibility = View.VISIBLE
  59 + binding.next.visibility = View.GONE
  60 + }
  61 + if (data in 0 until mPagerAdapter.itemCount) {
  62 + binding.practicePager.currentItem = data
  63 + }
  64 + }
  65 + }
  66 + }
  67 +
  68 + override fun initData() {
  69 + super.initData()
  70 + courseBean = intent.getParcelableExtra(ConstantParamKey.COURSE_BEAN)
  71 + val isExam = intent.getBooleanExtra("isExam", false)
  72 + courseBean?.let {
  73 + if (isExam) {
  74 + mViewModel.startExam(it.mTrainClassId.toInt())
  75 + } else {
  76 + mViewModel.startPractise(it.mTrainClassId.toInt())
  77 + }
  78 + binding.toolBar.setTitle(
  79 + if (it.isTrainClass) {
  80 + "班级练习"
  81 + } else {
  82 + "班级考试"
  83 + }
  84 + )
  85 + }
  86 + binding.apply {
  87 + // 禁止滑动
  88 + practicePager.isUserInputEnabled = false
  89 +
  90 + toolBar.setRightText("答题卡")
  91 + toolBar.setRightTextDrawable(
  92 + ContextCompat.getDrawable(
  93 + baseContext,
  94 + R.mipmap.answer_sheet
  95 + )
  96 + )
  97 + // 答题卡点击事件
  98 + toolBar.addRightListener(object : ToolBarClickListener {
  99 + override fun onClick(view: View) {
  100 + val intent =
  101 + Intent(this@CoursePractiseActivity, AnswerSheetActivity::class.java)
  102 + .putStringArrayListExtra("resultData", mPagerAdapter.getArrayList())
  103 + .putExtra("showCorrect", mPagerAdapter.showCorrect)
  104 + .putExtra("title", binding.toolBar.getTitle())
  105 + startForResult.launch(intent)
  106 + }
  107 + })
  108 +
  109 +
  110 + // 上一题
  111 + previous.setOnClickListener {
  112 + val index = practicePager.currentItem
  113 + if (index >= 1) {
  114 + practicePager.currentItem = index - 1
  115 + }
  116 + next.visibility = View.VISIBLE
  117 + finishJob.visibility = View.GONE
  118 + if (index == 1) {
  119 + previous.visibility = View.GONE
  120 + }
  121 +
  122 + }
  123 + // 下一题
  124 + next.setOnClickListener {
  125 + if (mPagerAdapter.showCorrect) {
  126 + modifyStatus()
  127 + } else {
  128 + next.isClickable = false
  129 + val answer = mPagerAdapter.getAnswer()[practicePager.currentItem]
  130 + if (answer.answer.isEmpty()) {
  131 + next.isClickable = true
  132 + ToastUtils.s(baseContext, "请选择题目选项")
  133 + return@setOnClickListener
  134 + }
  135 + mViewModel.subSingle(userItemId, answer.id, answer.answer)
  136 + }
  137 + }
  138 + // 完成
  139 + finishJob.setOnClickListener {
  140 + // 完成
  141 + finishJob.isClickable = false
  142 + val answer = mPagerAdapter.getAnswer()[practicePager.currentItem]
  143 + if (answer.answer.isEmpty()) {
  144 + finishJob.isClickable = true
  145 + ToastUtils.s(baseContext, "请选择题目选项")
  146 + return@setOnClickListener
  147 + }
  148 + isFinish = true
  149 + mViewModel.subSingle(userItemId, answer.id, answer.answer)
  150 + }
  151 +
  152 + }
  153 + // 标题弹窗
  154 + titleDialog.setListener(object : DialogListener {
  155 + override fun determine() {
  156 + finish()
  157 + }
  158 + })
  159 + // 查看答题卡
  160 + titleDialog.viewAnswerSheetListener {
  161 + binding.finishJob.visibility = View.INVISIBLE
  162 + mPagerAdapter.showCorrect = true
  163 + mPagerAdapter.notifyDataSetChanged()
  164 + binding.practicePager.currentItem = 0
  165 + binding.previous.visibility = View.GONE
  166 + binding.next.visibility = View.VISIBLE
  167 + isFinish = false
  168 + titleDialog.dismiss()
  169 + }
  170 + }
  171 +
  172 +
  173 + override fun initDataObserver() {
  174 + mViewModel.exam.observe(this) {
  175 + if (it.code == 1) {
  176 + userItemId = it.data.user_item_id
  177 + mPagerAdapter.addList(it.data.list)
  178 + binding.practicePager.adapter = mPagerAdapter
  179 + } else {
  180 + ToastUtils.s(baseContext, it.msg)
  181 + }
  182 + }
  183 +
  184 + mViewModel.subSingleData.observe(this) {
  185 + binding.next.isClickable = true
  186 + modifyStatus()
  187 + // 胶卷时调用此接口
  188 + if (isFinish) {
  189 + mPagerAdapter.notifyDataSetChanged()
  190 + mViewModel.subFinish(userItemId)
  191 + }
  192 + }
  193 + mViewModel.subFinish.observe(this) {
  194 + if (!titleDialog.isShowing) {
  195 + // 点击外部不取消
  196 + titleDialog.setInfo("共${mPagerAdapter.itemCount}道题")
  197 + titleDialog.setTitleSpan("答对${it.data.correct_count}道题").show()
  198 + }
  199 + }
  200 + }
  201 +
  202 + private fun modifyStatus() {
  203 + val index = binding.practicePager.currentItem
  204 + if (index < mPagerAdapter.itemCount - 1) {
  205 + binding.practicePager.currentItem = index + 1
  206 + }
  207 + binding.previous.visibility = View.VISIBLE
  208 + if (index == mPagerAdapter.itemCount - 2) {
  209 + binding.next.visibility = View.GONE
  210 + if (!mPagerAdapter.showCorrect) {
  211 + binding.finishJob.visibility = View.VISIBLE
  212 + }
  213 + }
  214 + }
  215 +
  216 + override fun onDestroy() {
  217 + if (titleDialog.isShowing) {
  218 + titleDialog.dismiss()
  219 + }
  220 + super.onDestroy()
  221 + }
  222 +}
1 package com.br_technology.securitytrain_master.ui.view.home.activity.course 1 package com.br_technology.securitytrain_master.ui.view.home.activity.course
2 2
3 import android.Manifest 3 import android.Manifest
  4 +import android.location.LocationManager
4 import android.util.Log 5 import android.util.Log
5 import com.br_technology.securitytrain_master.base.common.ConstantParamKey.CLASS_ID 6 import com.br_technology.securitytrain_master.base.common.ConstantParamKey.CLASS_ID
6 import com.br_technology.securitytrain_master.base.view.BaseApplication 7 import com.br_technology.securitytrain_master.base.view.BaseApplication
@@ -27,8 +28,8 @@ class LocationSignActivity : @@ -27,8 +28,8 @@ class LocationSignActivity :
27 ActivityLocationSignBinding::inflate 28 ActivityLocationSignBinding::inflate
28 ), TencentLocationListener { 29 ), TencentLocationListener {
29 30
30 - val mClassId: String? = null  
31 - var mLocation: TencentLocation? = null 31 + var mClassId: String? = null
  32 + private var mLocation: TencentLocation? = null
32 33
33 override fun initView() { 34 override fun initView() {
34 super.initView() 35 super.initView()
@@ -39,7 +40,7 @@ class LocationSignActivity : @@ -39,7 +40,7 @@ class LocationSignActivity :
39 TencentLocationManager.COORDINATE_TYPE_GCJ02; 40 TencentLocationManager.COORDINATE_TYPE_GCJ02;
40 rvSign.setOnClickListener { 41 rvSign.setOnClickListener {
41 if (mLocation != null && mClassId != null) { 42 if (mLocation != null && mClassId != null) {
42 - mViewModel.sign(mClassId, "${mLocation?.latitude}", "${mLocation?.longitude}") 43 + mViewModel.sign(mClassId?:"", "${mLocation?.latitude}", "${mLocation?.longitude}")
43 } 44 }
44 } 45 }
45 } 46 }
@@ -47,7 +48,7 @@ class LocationSignActivity : @@ -47,7 +48,7 @@ class LocationSignActivity :
47 48
48 override fun initData() { 49 override fun initData() {
49 super.initData() 50 super.initData()
50 - intent.getStringExtra(CLASS_ID) 51 + mClassId = intent.getStringExtra(CLASS_ID)
51 } 52 }
52 53
53 override fun onStart() { 54 override fun onStart() {
@@ -64,17 +65,22 @@ class LocationSignActivity : @@ -64,17 +65,22 @@ class LocationSignActivity :
64 override fun onResume() { 65 override fun onResume() {
65 binding.mapView.onResume() 66 binding.mapView.onResume()
66 super.onResume() 67 super.onResume()
67 - initPermissions(  
68 - Manifest.permission.ACCESS_FINE_LOCATION,  
69 - Manifest.permission.ACCESS_COARSE_LOCATION,  
70 - onGranted = {  
71 - startLocation()  
72 - },  
73 - onDenied = {  
74 - showError("未授权定位,无法打卡.")  
75 - }, onDeniedNever = {  
76 - })  
77 - 68 + val lm = getSystemService(LOCATION_SERVICE) as LocationManager
  69 + val enable = lm.isProviderEnabled(LocationManager.GPS_PROVIDER)
  70 + if (enable) {
  71 + initPermissions(
  72 + Manifest.permission.ACCESS_FINE_LOCATION,
  73 + Manifest.permission.ACCESS_COARSE_LOCATION,
  74 + onGranted = {
  75 + startLocation()
  76 + },
  77 + onDenied = {
  78 + showError("未授权定位,无法打卡.")
  79 + }, onDeniedNever = {
  80 + })
  81 + } else {
  82 + showError("GPS定位未开启,无法打卡.")
  83 + }
78 } 84 }
79 85
80 override fun onDestroy() { 86 override fun onDestroy() {
1 package com.br_technology.securitytrain_master.ui.view.home.activity.course 1 package com.br_technology.securitytrain_master.ui.view.home.activity.course
2 2
  3 +import android.text.TextUtils
3 import com.br_technology.securitytrain_master.base.common.ConstantParamKey 4 import com.br_technology.securitytrain_master.base.common.ConstantParamKey
4 import com.br_technology.securitytrain_master.databinding.ActivityVideoDetailBinding 5 import com.br_technology.securitytrain_master.databinding.ActivityVideoDetailBinding
5 import com.br_technology.securitytrain_master.ui.bean.CourseParam 6 import com.br_technology.securitytrain_master.ui.bean.CourseParam
6 import com.br_technology.securitytrain_master.ui.view.home.viewmodel.VideoDetailViewModel 7 import com.br_technology.securitytrain_master.ui.view.home.viewmodel.VideoDetailViewModel
  8 +import com.br_technology.securitytrain_master.view.MyVideoPlayer
7 import com.shuyu.gsyvideoplayer.GSYVideoManager 9 import com.shuyu.gsyvideoplayer.GSYVideoManager
8 import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleActivity 10 import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleActivity
9 11
@@ -23,12 +25,20 @@ class VideoDetailActivity : BaseLifeCycleActivity<VideoDetailViewModel, Activity @@ -23,12 +25,20 @@ class VideoDetailActivity : BaseLifeCycleActivity<VideoDetailViewModel, Activity
23 25
24 override fun initView() { 26 override fun initView() {
25 super.initView() 27 super.initView()
  28 + binding.videoPlayer.mStatusChange = object : MyVideoPlayer.IStatusChange {
  29 + override fun status(isPause: Boolean, isFinish: Boolean) {
  30 + if (!TextUtils.isEmpty(intent.getStringExtra(ConstantParamKey.COMMON_URL))) {
  31 + mViewModel.record(binding.videoPlayer.getProgressTime())
  32 + }
  33 + }
  34 + }
26 } 35 }
27 36
28 override fun initData() { 37 override fun initData() {
29 super.initData() 38 super.initData()
30 val url = intent.getStringExtra(ConstantParamKey.COMMON_URL) 39 val url = intent.getStringExtra(ConstantParamKey.COMMON_URL)
31 courseBean = intent.getParcelableExtra(ConstantParamKey.COURSE_BEAN) 40 courseBean = intent.getParcelableExtra(ConstantParamKey.COURSE_BEAN)
  41 + mViewModel.courseParam.value = courseBean
32 url?.apply { 42 url?.apply {
33 binding.videoPlayer.initVideoBuilderMode( 43 binding.videoPlayer.initVideoBuilderMode(
34 "it.data.detail.image", 44 "it.data.detail.image",
1 package com.br_technology.securitytrain_master.ui.view.home.fragment 1 package com.br_technology.securitytrain_master.ui.view.home.fragment
2 2
3 import android.content.Intent 3 import android.content.Intent
  4 +import com.br_technology.securitytrain_master.base.common.ConstantParamKey
4 import com.br_technology.securitytrain_master.base.common.ConstantParamKey.COMMON_URL 5 import com.br_technology.securitytrain_master.base.common.ConstantParamKey.COMMON_URL
5 import com.br_technology.securitytrain_master.base.common.ConstantParamKey.COURSE_BEAN 6 import com.br_technology.securitytrain_master.base.common.ConstantParamKey.COURSE_BEAN
6 import com.br_technology.securitytrain_master.databinding.FragmentCourseListBinding 7 import com.br_technology.securitytrain_master.databinding.FragmentCourseListBinding
@@ -70,18 +71,18 @@ class CourseListFragment(var data: TrainCourseData) : @@ -70,18 +71,18 @@ class CourseListFragment(var data: TrainCourseData) :
70 addData(dataList) 71 addData(dataList)
71 setListener(object : IItemClick { 72 setListener(object : IItemClick {
72 override fun item(item: TrainCourseDetailItemChild) { 73 override fun item(item: TrainCourseDetailItemChild) {
  74 + val param = (activity as CourseDetailActivity).getCourseBean()
73 when (item.type) { 75 when (item.type) {
74 TYPE_COURSE_DETAIL_ITEM_VIDEO -> { 76 TYPE_COURSE_DETAIL_ITEM_VIDEO -> {
  77 + param?.mClassId = item.lessonVideoChild?.id.toString()
75 startActivity( 78 startActivity(
76 Intent(activity, VideoDetailActivity::class.java) 79 Intent(activity, VideoDetailActivity::class.java)
77 - .putExtra(COMMON_URL, item.lessonVideoNormalChild?.video_url)  
78 - .putExtra(  
79 - COURSE_BEAN,  
80 - (activity as CourseDetailActivity).getCourseBean()  
81 - ) 80 + .putExtra(COMMON_URL, item.lessonVideoChild?.video_url)
  81 + .putExtra(COURSE_BEAN, param)
82 ) 82 )
83 } 83 }
84 TYPE_COURSE_DETAIL_ITEM_NORMAL -> { 84 TYPE_COURSE_DETAIL_ITEM_NORMAL -> {
  85 + param?.mClassId = item.lessonVideoNormalChild?.id.toString()
85 startActivity( 86 startActivity(
86 Intent(activity, VideoDetailActivity::class.java) 87 Intent(activity, VideoDetailActivity::class.java)
87 .putExtra(COMMON_URL, item.lessonVideoNormalChild?.video_url) 88 .putExtra(COMMON_URL, item.lessonVideoNormalChild?.video_url)
@@ -92,6 +93,7 @@ class CourseListFragment(var data: TrainCourseData) : @@ -92,6 +93,7 @@ class CourseListFragment(var data: TrainCourseData) :
92 ) 93 )
93 } 94 }
94 TYPE_COURSE_DETAIL_ITEM_LIVE -> { 95 TYPE_COURSE_DETAIL_ITEM_LIVE -> {
  96 + param?.mClassId = item.lessonLiveChild?.id.toString()
95 startActivity( 97 startActivity(
96 Intent(activity, VideoDetailActivity::class.java) 98 Intent(activity, VideoDetailActivity::class.java)
97 .putExtra(COMMON_URL, item.lessonLiveChild?.webrtc_url) 99 .putExtra(COMMON_URL, item.lessonLiveChild?.webrtc_url)
@@ -102,7 +104,10 @@ class CourseListFragment(var data: TrainCourseData) : @@ -102,7 +104,10 @@ class CourseListFragment(var data: TrainCourseData) :
102 ) 104 )
103 } 105 }
104 TYPE_COURSE_DETAIL_ITEM_OFF -> { 106 TYPE_COURSE_DETAIL_ITEM_OFF -> {
105 - startActivity(LocationSignActivity::class.java) 107 + startActivity(
  108 + Intent(activity, LocationSignActivity::class.java)
  109 + .putExtra(ConstantParamKey.CLASS_ID, item.lessonOffChild?.id.toString())
  110 + )
106 } 111 }
107 } 112 }
108 } 113 }
1 package com.br_technology.securitytrain_master.ui.view.home.fragment 1 package com.br_technology.securitytrain_master.ui.view.home.fragment
2 2
3 import android.content.Intent 3 import android.content.Intent
  4 +import android.text.TextUtils
4 import android.view.View 5 import android.view.View
  6 +import android.view.ViewGroup
  7 +import android.widget.TextView
5 import com.br_technology.securitytrain_master.R 8 import com.br_technology.securitytrain_master.R
6 import com.br_technology.securitytrain_master.base.common.ConstantParamKey 9 import com.br_technology.securitytrain_master.base.common.ConstantParamKey
7 import com.br_technology.securitytrain_master.base.common.ConstantParamKey.COMMON_URL 10 import com.br_technology.securitytrain_master.base.common.ConstantParamKey.COMMON_URL
@@ -52,18 +55,56 @@ class HomeFragment : @@ -52,18 +55,56 @@ class HomeFragment :
52 }) 55 })
53 //获取最新公告 56 //获取最新公告
54 mViewModel.mNoticeBean.observe(this, { 57 mViewModel.mNoticeBean.observe(this, {
55 - 58 + val data = it.data.list
  59 + for (news in data) {
  60 + val textView = TextView(context)
  61 + textView.maxLines = 1
  62 + textView.text = news.title
  63 + textView.ellipsize = TextUtils.TruncateAt.END
  64 + textView.setOnClickListener {
  65 + }
  66 + binding.flipperScan.addView(
  67 + textView, ViewGroup.LayoutParams(
  68 + ViewGroup.LayoutParams.MATCH_PARENT,
  69 + ViewGroup.LayoutParams.WRAP_CONTENT
  70 + )
  71 + )
  72 + }
  73 + if (data.size > 1) {
  74 + binding.flipperScan.flipInterval = 3000
  75 + binding.flipperScan.startFlipping()
  76 + }
56 }) 77 })
57 //获取视频列表 78 //获取视频列表
58 mViewModel.mVideoLessonBean.observe(this, { 79 mViewModel.mVideoLessonBean.observe(this, {
59 videoLessonList?.clear() 80 videoLessonList?.clear()
60 - videoLessonList?.addAll(it.data.list.data) 81 + if (it.data.list.data.isNotEmpty()) {
  82 + videoLessonList?.addAll(
  83 + it.data.list.data.subList(
  84 + 0,
  85 + (it.data.list.data.size).coerceAtMost(4)
  86 + )
  87 + )
  88 + }
61 videoLessonList?.let { it1 -> videoCourseAdapter?.setList(it1) } 89 videoLessonList?.let { it1 -> videoCourseAdapter?.setList(it1) }
  90 + if (videoLessonList!!.size < 4) {
  91 + binding.llVideo.visibility = View.GONE
  92 + } else {
  93 + binding.llVideo.visibility = View.VISIBLE
  94 + }
62 }) 95 })
63 //获取推荐资料 96 //获取推荐资料
64 mViewModel.mRecommendBean.observe(this, { 97 mViewModel.mRecommendBean.observe(this, {
65 recommendList?.clear() 98 recommendList?.clear()
66 - recommendList?.addAll(it.data.list) 99 + if (it.data.list.isNotEmpty()) {
  100 + recommendList?.addAll(
  101 + it.data.list.subList(
  102 + 0,
  103 + (it.data.list.size).coerceAtMost(4)
  104 + )
  105 + )
  106 +
  107 + }
67 recommendList?.let { it1 -> recommendDataAdapter?.addList(it1) } 108 recommendList?.let { it1 -> recommendDataAdapter?.addList(it1) }
68 109
69 if (recommendList!!.size < 4) { 110 if (recommendList!!.size < 4) {
@@ -125,6 +166,9 @@ class HomeFragment : @@ -125,6 +166,9 @@ class HomeFragment :
125 database.setOnClickListener { 166 database.setOnClickListener {
126 startActivity(DatabaseActivity::class.java) 167 startActivity(DatabaseActivity::class.java)
127 } 168 }
  169 + llRecommend.setOnClickListener {
  170 + startActivity(DatabaseActivity::class.java)
  171 + }
128 172
129 // 文本课程 173 // 文本课程
130 txtCourse.setOnClickListener { 174 txtCourse.setOnClickListener {
@@ -134,6 +178,8 @@ class HomeFragment : @@ -134,6 +178,8 @@ class HomeFragment :
134 onlineCourse.setOnClickListener { 178 onlineCourse.setOnClickListener {
135 startActivity(OnlineActivity::class.java) 179 startActivity(OnlineActivity::class.java)
136 } 180 }
  181 + llVideo.setOnClickListener { startActivity(OnlineActivity::class.java) }
  182 +
137 183
138 // 直播课程 184 // 直播课程
139 liveCourse.setOnClickListener { 185 liveCourse.setOnClickListener {
  1 +package com.br_technology.securitytrain_master.ui.view.home.viewmodel
  2 +
  3 +import androidx.lifecycle.MutableLiveData
  4 +import com.br_technology.securitytrain_master.base.network.response.BaseResponse
  5 +import com.br_technology.securitytrain_master.base.network.response.CommonDetailList
  6 +import com.br_technology.securitytrain_master.base.network.response.CommonPage
  7 +import com.br_technology.securitytrain_master.base.repository.TrainRepository
  8 +import com.br_technology.securitytrain_master.base.view.BaseViewModel
  9 +import com.br_technology.securitytrain_master.ui.bean.*
  10 +import com.br_technology.securitytrain_master.ui.view.bank.bean.SubjectData
  11 +
  12 +/**
  13 + * Author by YSir
  14 + * Date on 2022/1/24.
  15 + * description
  16 + * PS: Not easy to write code, please indicate.
  17 + */
  18 +class CoursePracticeViewModel : BaseViewModel<TrainRepository>() {
  19 +
  20 + val exam = MutableLiveData<BaseResponse<SubjectData>>()
  21 + val courseBean = MutableLiveData<CourseParam>()
  22 +
  23 + var subAnswer: MutableLiveData<BaseResponse<SubResult>> = MutableLiveData()
  24 + // 交卷
  25 + var subFinish: MutableLiveData<BaseResponse<SubResult>> = MutableLiveData()
  26 +
  27 + // 提交某一题
  28 + val subSingleData: MutableLiveData<BaseResponse<SubSingle>> = MutableLiveData()
  29 +
  30 + // 每日一练列表数据
  31 + val dayPracticeLiveData: MutableLiveData<BaseResponse<CommonDetailList<CommonPage<PaperDaily>>>> =
  32 + MutableLiveData()
  33 + // 获取挑战答题弹板信息
  34 + val challengeInfoLiveData: MutableLiveData<BaseResponse<ChallengeInfo>> = MutableLiveData()
  35 +
  36 + // 开始练习
  37 + fun startPractise(
  38 + train_practise_id: Int,
  39 + ) {
  40 + mRepository.startPractise(train_practise_id, exam)
  41 + }
  42 +
  43 + // 开始答题
  44 + fun startExam(
  45 + train_practise_id: Int,
  46 + ) {
  47 + mRepository.startExamExp(train_practise_id, exam)
  48 + }
  49 +
  50 + // 提交某一题
  51 + fun subSingle(
  52 + user_item_id: Int,
  53 + item_id: Int,
  54 + answer: String,
  55 + ) {
  56 + mRepository.subSingle(user_item_id, item_id, answer, subSingleData)
  57 + }
  58 +
  59 + // 提交答卷
  60 + fun subFinish(user_item_id: Int) {
  61 + mRepository.subPaper(user_item_id, subFinish)
  62 + }
  63 +}
1 package com.br_technology.securitytrain_master.ui.view.home.viewmodel 1 package com.br_technology.securitytrain_master.ui.view.home.viewmodel
2 2
  3 +import androidx.lifecycle.MutableLiveData
  4 +import com.br_technology.securitytrain_master.base.network.response.BaseResponse
  5 +import com.br_technology.securitytrain_master.base.repository.LessonRepository
3 import com.br_technology.securitytrain_master.base.view.BaseViewModel 6 import com.br_technology.securitytrain_master.base.view.BaseViewModel
4 -import com.br_technology.securitytrain_master.ui.view.home.repository.VideoDetailRepository 7 +import com.br_technology.securitytrain_master.ui.bean.CourseParam
5 8
6 /** 9 /**
7 * Time: 12/8/2021 15:46 10 * Time: 12/8/2021 15:46
8 * Author: Captain 11 * Author: Captain
9 * Description: 初见时你很迷人 12 * Description: 初见时你很迷人
10 */ 13 */
11 -class VideoDetailViewModel : BaseViewModel<VideoDetailRepository>() { 14 +class VideoDetailViewModel : BaseViewModel<LessonRepository>() {
  15 +
  16 + val courseParam = MutableLiveData<CourseParam>()
  17 +
  18 + val record = MutableLiveData<BaseResponse<Void>>()
  19 +
  20 + fun record(
  21 + view_len: String
  22 + ) {
  23 + courseParam.value?.let {
  24 + if (it.isTrainClass) {
  25 + val map = hashMapOf("class_id" to it.mClassId)
  26 + mRepository.recordTrainLesson(
  27 + it.type,
  28 + it.mLessonId,
  29 + it.mTrainClassId,
  30 + view_len,
  31 + map,
  32 + record
  33 + )
  34 + } else {
  35 + val map = hashMapOf("view_len" to view_len, "class_id" to it.mClassId)
  36 + mRepository.recordNormalLesson(it.type, it.mLessonId, map, record)
  37 + }
  38 + }
  39 + }
12 } 40 }
@@ -63,7 +63,6 @@ class AcademicFeedbackActivity : @@ -63,7 +63,6 @@ class AcademicFeedbackActivity :
63 recyclerview.adapter = academicFeedbackAdapter 63 recyclerview.adapter = academicFeedbackAdapter
64 academicFeedbackAdapter?.setOnItemClickListener { _, _, position -> 64 academicFeedbackAdapter?.setOnItemClickListener { _, _, position ->
65 mViewModel.academicFeedbackDetail(academicFeedbackList!![position].train_class_id) 65 mViewModel.academicFeedbackDetail(academicFeedbackList!![position].train_class_id)
66 -  
67 } 66 }
68 67
69 initLoadMore() 68 initLoadMore()
1 package com.br_technology.securitytrain_master.ui.view.mine.activity 1 package com.br_technology.securitytrain_master.ui.view.mine.activity
2 2
3 -import android.view.View  
4 -import androidx.core.content.ContextCompat  
5 -import com.br_technology.securitytrain_master.R 3 +import android.annotation.SuppressLint
6 import com.br_technology.securitytrain_master.databinding.ActivityLearningReportBinding 4 import com.br_technology.securitytrain_master.databinding.ActivityLearningReportBinding
7 -import com.br_technology.securitytrain_master.ui.view.home.pojo.VideoCourse 5 +import com.br_technology.securitytrain_master.expand.glideRound
8 import com.br_technology.securitytrain_master.ui.view.mine.adapter.LearningReportAdapter 6 import com.br_technology.securitytrain_master.ui.view.mine.adapter.LearningReportAdapter
9 import com.br_technology.securitytrain_master.ui.view.mine.viewmodel.LearningReportViewModel 7 import com.br_technology.securitytrain_master.ui.view.mine.viewmodel.LearningReportViewModel
  8 +import com.br_technology.securitytrain_master.util.TranslateUnit
10 import com.br_technology.securitytrain_master.view.ClassifyPop 9 import com.br_technology.securitytrain_master.view.ClassifyPop
11 -import com.br_technology.securitytrain_master.view.listener.ToolBarClickListener  
12 import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleActivity 10 import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleActivity
13 11
14 /** 12 /**
@@ -26,39 +24,44 @@ class LearningReportActivity : @@ -26,39 +24,44 @@ class LearningReportActivity :
26 ClassifyPop(this) 24 ClassifyPop(this)
27 } 25 }
28 26
  27 + @SuppressLint("SetTextI18n")
29 override fun initDataObserver() { 28 override fun initDataObserver() {
30 - 29 + // todo 数据设置
  30 + mViewModel.data.observe(this, {
  31 + val user = it.data.report.user
  32 + binding.apply {
  33 + tvScore.text = "积分${user.score}"
  34 + ivHead.glideRound(
  35 + user.avatar,
  36 + TranslateUnit.dp2px(this@LearningReportActivity, 64f)
  37 + )
  38 + }
  39 + })
31 } 40 }
32 41
33 override fun initData() { 42 override fun initData() {
34 super.initData() 43 super.initData()
  44 + mViewModel.getReport()
35 binding.apply { 45 binding.apply {
36 - toolBar.setRightText("全部")  
37 - toolBar.setRightTextDrawable(  
38 - ContextCompat.getDrawable(  
39 - baseContext,  
40 - R.mipmap.down_arrow  
41 - )  
42 - )  
43 -  
44 - toolBar.addRightListener(object : ToolBarClickListener {  
45 - override fun onClick(view: View) {  
46 - if (!classifyPop.isShowing) {  
47 - classifyPop.showAsDropDown(view)  
48 - }  
49 -  
50 - }  
51 - }) 46 +// toolBar.setRightText("全部")
  47 +// toolBar.setRightTextDrawable(
  48 +// ContextCompat.getDrawable(
  49 +// baseContext,
  50 +// R.mipmap.down_arrow
  51 +// )
  52 +// )
  53 +//
  54 +// toolBar.addRightListener(object : ToolBarClickListener {
  55 +// override fun onClick(view: View) {
  56 +// if (!classifyPop.isShowing) {
  57 +// classifyPop.showAsDropDown(view)
  58 +// }
  59 +// }
  60 +// })
52 61
53 val learningReportAdapter = LearningReportAdapter() 62 val learningReportAdapter = LearningReportAdapter()
54 - val list = mutableListOf(  
55 - VideoCourse(R.mipmap.banner, "01:45:00", "自动化制作课程", "(考试)", "+10"),  
56 - VideoCourse(R.mipmap.banner, "01:45:00", "自动化制作课程", "(考试)", "+10"),  
57 - VideoCourse(R.mipmap.banner, "01:45:00", "自动化制作课程", "(考试)", "+10"),  
58 - VideoCourse(R.mipmap.banner, "01:45:00", "自动化制作课程", "(考试)", "+10"),  
59 - )  
60 - recyclerview.adapter = learningReportAdapter  
61 - learningReportAdapter.addList(list) 63 +// recyclerview.adapter = learningReportAdapter
  64 +// learningReportAdapter.addList(list)
62 65
63 tvCreateReport.setOnClickListener { 66 tvCreateReport.setOnClickListener {
64 startActivity(LearningReportDetailActivity::class.java) 67 startActivity(LearningReportDetailActivity::class.java)
@@ -6,8 +6,13 @@ import android.net.Uri @@ -6,8 +6,13 @@ import android.net.Uri
6 import com.br_technology.securitytrain_master.databinding.ActivityServiceBinding 6 import com.br_technology.securitytrain_master.databinding.ActivityServiceBinding
7 import com.br_technology.securitytrain_master.ext.initPermissions 7 import com.br_technology.securitytrain_master.ext.initPermissions
8 import com.br_technology.securitytrain_master.ui.view.home.viewmodel.ServiceViewModel 8 import com.br_technology.securitytrain_master.ui.view.home.viewmodel.ServiceViewModel
  9 +import com.br_technology.securitytrain_master.util.TrainFileUtil
  10 +import com.br_technology.securitytrain_master.view.DialogTrainLoading
9 import com.bumptech.glide.Glide 11 import com.bumptech.glide.Glide
10 import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleActivity 12 import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleActivity
  13 +import kotlinx.coroutines.GlobalScope
  14 +import kotlinx.coroutines.launch
  15 +import java.io.File
11 16
12 /** 17 /**
13 * createTime:2021/8/2 15:29 18 * createTime:2021/8/2 15:29
@@ -23,28 +28,77 @@ class ServiceActivity : @@ -23,28 +28,77 @@ class ServiceActivity :
23 // 拨打电话 28 // 拨打电话
24 call.setOnClickListener { 29 call.setOnClickListener {
25 initPermissions(Manifest.permission.CALL_PHONE, 30 initPermissions(Manifest.permission.CALL_PHONE,
26 - onGranted = {  
27 - val intent = Intent()  
28 - intent.action = Intent.ACTION_CALL  
29 - intent.data = Uri.parse("tel:" + mobile.text.toString().trim())  
30 - startActivity(intent)  
31 - },  
32 - onDenied = {  
33 -  
34 - },  
35 - onDeniedNever = {  
36 - //跳转到设置页面  
37 - }) 31 + onGranted = {
  32 + val intent = Intent()
  33 + intent.action = Intent.ACTION_CALL
  34 + intent.data = Uri.parse("tel:" + mobile.text.toString().trim())
  35 + startActivity(intent)
  36 + },
  37 + onDenied = {
  38 +
  39 + },
  40 + onDeniedNever = {
  41 + //跳转到设置页面
  42 + })
38 } 43 }
39 - // 下载二维码  
40 - download.setOnClickListener { }  
41 } 44 }
42 } 45 }
43 46
44 override fun initDataObserver() { 47 override fun initDataObserver() {
45 - mViewModel.mContactServiceBean.observe(this,{  
46 - binding.mobile.text = it.data.mobile  
47 - Glide.with(this).load(it.data.qrcode).into(binding.code) 48 + mViewModel.mContactServiceBean.observe(this, { contact ->
  49 + binding.mobile.text = contact.data.mobile
  50 + Glide.with(this).load(contact.data.qrcode).into(binding.code)
  51 + // 下载二维码
  52 + binding.download.setOnClickListener {
  53 + initPermissions(Manifest.permission.READ_EXTERNAL_STORAGE,
  54 + Manifest.permission.WRITE_EXTERNAL_STORAGE,
  55 + onGranted = {
  56 + load(contact.data.qrcode)
  57 + },
  58 + onDenied = {
  59 +
  60 + },
  61 + onDeniedNever = {
  62 + //跳转到设置页面
  63 + })
  64 + }
48 }) 65 })
49 } 66 }
  67 +
  68 + private val mDialogLoading: DialogTrainLoading by lazy {
  69 + return@lazy DialogTrainLoading(this)
  70 + }
  71 +
  72 + private fun load(url: String) {
  73 + mDialogLoading.show()
  74 + GlobalScope.launch {
  75 + val fileDataDes = File(TrainFileUtil.getTrainLoad(), TrainFileUtil.getFileName(url))
  76 + TrainFileUtil.fileLoad(
  77 + fileDataDes,
  78 + url,
  79 + true,
  80 + object : TrainFileUtil.ILoad {
  81 + override fun success(file: File) {
  82 + mDialogLoading.dismiss()
  83 + runOnUiThread{
  84 + showError("下载完成")
  85 + }
  86 + }
  87 +
  88 + override fun fail() {
  89 + mDialogLoading.dismiss()
  90 + }
  91 +
  92 + override fun progress(f: Float) {
  93 + }
  94 + })
  95 + }
  96 + }
  97 +
  98 + override fun onDestroy() {
  99 + if (mDialogLoading.isShowing){
  100 + mDialogLoading.dismiss()
  101 + }
  102 + super.onDestroy()
  103 + }
50 } 104 }
1 package com.br_technology.securitytrain_master.ui.view.mine.adapter 1 package com.br_technology.securitytrain_master.ui.view.mine.adapter
2 2
3 import android.annotation.SuppressLint 3 import android.annotation.SuppressLint
4 -import android.content.Context  
5 -import android.view.LayoutInflater  
6 -import android.view.ViewGroup 4 +import android.widget.TextView
7 import com.br_technology.securitytrain_master.R 5 import com.br_technology.securitytrain_master.R
8 -import com.br_technology.securitytrain_master.base.view.BaseAdapter  
9 -import com.br_technology.securitytrain_master.databinding.ItemCourseBinding  
10 import com.br_technology.securitytrain_master.ui.bean.LessonBean 6 import com.br_technology.securitytrain_master.ui.bean.LessonBean
11 import com.br_technology.securitytrain_master.util.CommonUtil 7 import com.br_technology.securitytrain_master.util.CommonUtil
12 import com.bumptech.glide.Glide 8 import com.bumptech.glide.Glide
  9 +import com.chad.library.adapter.base.BaseQuickAdapter
  10 +import com.chad.library.adapter.base.module.LoadMoreModule
  11 +import com.chad.library.adapter.base.viewholder.BaseViewHolder
13 12
14 /** 13 /**
15 * Time: 8/3/2021 11:29 14 * Time: 8/3/2021 11:29
16 * Author: Captain 15 * Author: Captain
17 * Description: 初见时你很迷人 16 * Description: 初见时你很迷人
18 */ 17 */
19 -class CourseAdapter : BaseAdapter<LessonBean, ItemCourseBinding>() { 18 +class CourseAdapter : BaseQuickAdapter<LessonBean, BaseViewHolder>(R.layout.item_course),
  19 + LoadMoreModule {
20 20
21 - override fun getViewBinding(  
22 - context: Context,  
23 - parent: ViewGroup,  
24 - viewType: Int,  
25 - from: LayoutInflater  
26 - ): ItemCourseBinding {  
27 - return ItemCourseBinding.inflate(from, parent, false) 21 + interface ITrainItemClick {
  22 + fun itemClick(item: LessonBean)
  23 + }
  24 +
  25 + var mListener: ITrainItemClick? = null
  26 +
  27 + fun setListener(iListener: ITrainItemClick) {
  28 + mListener = iListener
28 } 29 }
29 30
30 @SuppressLint("SetTextI18n") 31 @SuppressLint("SetTextI18n")
31 - override fun onBind(holder: ItemCourseBinding, position: Int, data: LessonBean) { 32 + override fun convert(holder: BaseViewHolder, data: LessonBean) {
32 holder.apply { 33 holder.apply {
33 - holder.tvTitle.text = CommonUtil.getTransStr(data.name)  
34 - holder.tvStatus.text = if (data.status == "0") { 34 + getView<TextView>(R.id.tv_title).text = CommonUtil.getTransStr(data.name)
  35 + getView<TextView>(R.id.tv_status).text = if (data.status == "0") {
35 "未完成" 36 "未完成"
36 } else { 37 } else {
37 "已完成" 38 "已完成"
38 } 39 }
39 - holder.tvTime.text = CommonUtil.getTransStr(data.create_time_text)  
40 - holder.tvLesson.text = "${data.class_hours}学时"  
41 - Glide.with(holder.root).load(data.image).error(R.mipmap.placeholder_head)  
42 - .into(holder.ivPic) 40 + getView<TextView>(R.id.tv_time).text = CommonUtil.getTransStr(data.create_time_text)
  41 + getView<TextView>(R.id.tv_lesson).text = "${data.class_hours}学时"
  42 + Glide.with(holder.itemView).load(data.image).error(R.mipmap.placeholder_head)
  43 + .into(getView(R.id.iv_pic))
  44 + itemView.setOnClickListener {
  45 + mListener?.itemClick(data)
  46 + }
43 } 47 }
44 } 48 }
45 } 49 }
@@ -4,6 +4,7 @@ import android.widget.ImageView @@ -4,6 +4,7 @@ import android.widget.ImageView
4 import com.br_technology.securitytrain_master.R 4 import com.br_technology.securitytrain_master.R
5 import com.br_technology.securitytrain_master.ui.bean.TrainTestData 5 import com.br_technology.securitytrain_master.ui.bean.TrainTestData
6 import com.chad.library.adapter.base.BaseMultiItemQuickAdapter 6 import com.chad.library.adapter.base.BaseMultiItemQuickAdapter
  7 +import com.chad.library.adapter.base.module.LoadMoreModule
7 import com.chad.library.adapter.base.viewholder.BaseViewHolder 8 import com.chad.library.adapter.base.viewholder.BaseViewHolder
8 9
9 /** 10 /**
@@ -12,7 +13,8 @@ import com.chad.library.adapter.base.viewholder.BaseViewHolder @@ -12,7 +13,8 @@ import com.chad.library.adapter.base.viewholder.BaseViewHolder
12 * description 13 * description
13 * PS: Not easy to write code, please indicate. 14 * PS: Not easy to write code, please indicate.
14 */ 15 */
15 -class TrainTestAdapter : BaseMultiItemQuickAdapter<TrainTestData, BaseViewHolder>() { 16 +class TrainTestAdapter : BaseMultiItemQuickAdapter<TrainTestData, BaseViewHolder>(),
  17 + LoadMoreModule {
16 18
17 init { 19 init {
18 addItemType(1, R.layout.item_mock_examnation) 20 addItemType(1, R.layout.item_mock_examnation)
@@ -8,13 +8,13 @@ import com.br_technology.securitytrain_master.base.common.ConstantType @@ -8,13 +8,13 @@ import com.br_technology.securitytrain_master.base.common.ConstantType
8 import com.br_technology.securitytrain_master.databinding.FragmentClassDutyCourseBinding 8 import com.br_technology.securitytrain_master.databinding.FragmentClassDutyCourseBinding
9 import com.br_technology.securitytrain_master.ui.bean.* 9 import com.br_technology.securitytrain_master.ui.bean.*
10 import com.br_technology.securitytrain_master.ui.view.home.activity.course.CourseDetailActivity 10 import com.br_technology.securitytrain_master.ui.view.home.activity.course.CourseDetailActivity
  11 +import com.br_technology.securitytrain_master.ui.view.home.activity.course.CoursePractiseActivity
11 import com.br_technology.securitytrain_master.ui.view.home.activity.course.TextDetailActivity 12 import com.br_technology.securitytrain_master.ui.view.home.activity.course.TextDetailActivity
12 import com.br_technology.securitytrain_master.ui.view.mine.adapter.CourseAdapter 13 import com.br_technology.securitytrain_master.ui.view.mine.adapter.CourseAdapter
13 import com.br_technology.securitytrain_master.ui.view.mine.adapter.TrainTestAdapter 14 import com.br_technology.securitytrain_master.ui.view.mine.adapter.TrainTestAdapter
14 import com.br_technology.securitytrain_master.ui.view.mine.viewmodel.ClassDutyCourseViewModel 15 import com.br_technology.securitytrain_master.ui.view.mine.viewmodel.ClassDutyCourseViewModel
15 import com.br_technology.securitytrain_master.util.TranslateUnit 16 import com.br_technology.securitytrain_master.util.TranslateUnit
16 import com.br_technology.securitytrain_master.view.VerticalDecoration 17 import com.br_technology.securitytrain_master.view.VerticalDecoration
17 -import com.br_technology.securitytrain_master.view.listener.OnItemClickListener  
18 import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleFragment 18 import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleFragment
19 19
20 /** 20 /**
@@ -25,7 +25,8 @@ import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleFragment @@ -25,7 +25,8 @@ import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleFragment
25 class ClassDutyCourseFragment(val type: Int) : 25 class ClassDutyCourseFragment(val type: Int) :
26 BaseLifeCycleFragment<ClassDutyCourseViewModel, FragmentClassDutyCourseBinding>( 26 BaseLifeCycleFragment<ClassDutyCourseViewModel, FragmentClassDutyCourseBinding>(
27 FragmentClassDutyCourseBinding::inflate 27 FragmentClassDutyCourseBinding::inflate
28 - ),OnItemClickListener<LessonBean>,TrainTestAdapter.ITrainItemClick { 28 + ), TrainTestAdapter.ITrainItemClick,
  29 + CourseAdapter.ITrainItemClick {
29 30
30 var page: Int = 1 31 var page: Int = 1
31 var courseAdapter: CourseAdapter? = null 32 var courseAdapter: CourseAdapter? = null
@@ -35,6 +36,7 @@ class ClassDutyCourseFragment(val type: Int) : @@ -35,6 +36,7 @@ class ClassDutyCourseFragment(val type: Int) :
35 @SuppressLint("SetTextI18n") 36 @SuppressLint("SetTextI18n")
36 override fun initDataObserver() { 37 override fun initDataObserver() {
37 mViewModel.listCourse.observe(this, { 38 mViewModel.listCourse.observe(this, {
  39 + binding.smartRefresh.isRefreshing = false
38 lessonBean = it.data 40 lessonBean = it.data
39 if (lessonBean!!.lesson_class_count > 0) { 41 if (lessonBean!!.lesson_class_count > 0) {
40 binding.prUploadValue.progress = 100 * 42 binding.prUploadValue.progress = 100 *
@@ -46,18 +48,21 @@ class ClassDutyCourseFragment(val type: Int) : @@ -46,18 +48,21 @@ class ClassDutyCourseFragment(val type: Int) :
46 if (list.isNotEmpty()) { 48 if (list.isNotEmpty()) {
47 if (page == 1) { 49 if (page == 1) {
48 courseAdapter = CourseAdapter() 50 courseAdapter = CourseAdapter()
49 - courseAdapter?.addListener(this)  
50 - courseAdapter?.addList(list) 51 + courseAdapter?.setListener(this)
  52 + courseAdapter?.setList(list)
51 binding.recyclerview.adapter = courseAdapter 53 binding.recyclerview.adapter = courseAdapter
52 } else { 54 } else {
53 - courseAdapter?.addList(list) 55 + courseAdapter?.addData(list)
54 } 56 }
55 } 57 }
56 - binding.smartRefresh.setEnableLoadMore(list.size == 10)  
57 - binding.smartRefresh.finishLoadMore()  
58 - binding.smartRefresh.finishRefresh() 58 + if (list.size < 10) {
  59 + courseAdapter?.loadMoreModule?.loadMoreEnd()
  60 + } else {
  61 + courseAdapter?.loadMoreModule?.loadMoreComplete()
  62 + }
59 }) 63 })
60 mViewModel.listPractise.observe(this, { 64 mViewModel.listPractise.observe(this, {
  65 + binding.smartRefresh.isRefreshing = false
61 val list = it.data.list 66 val list = it.data.list
62 if (list.isNotEmpty()) { 67 if (list.isNotEmpty()) {
63 if (page == 1) { 68 if (page == 1) {
@@ -69,11 +74,14 @@ class ClassDutyCourseFragment(val type: Int) : @@ -69,11 +74,14 @@ class ClassDutyCourseFragment(val type: Int) :
69 trainTestAdapter?.addData(transPracticeData(list)) 74 trainTestAdapter?.addData(transPracticeData(list))
70 } 75 }
71 } 76 }
72 - binding.smartRefresh.setEnableLoadMore(list.size == 10)  
73 - binding.smartRefresh.finishLoadMore()  
74 - binding.smartRefresh.finishRefresh() 77 + if (list.size < 10) {
  78 + trainTestAdapter?.loadMoreModule?.loadMoreEnd()
  79 + } else {
  80 + trainTestAdapter?.loadMoreModule?.loadMoreComplete()
  81 + }
75 }) 82 })
76 mViewModel.listExam.observe(this, { 83 mViewModel.listExam.observe(this, {
  84 + binding.smartRefresh.isRefreshing = false
77 val list = it.data.list 85 val list = it.data.list
78 if (list.isNotEmpty()) { 86 if (list.isNotEmpty()) {
79 if (page == 1) { 87 if (page == 1) {
@@ -85,9 +93,11 @@ class ClassDutyCourseFragment(val type: Int) : @@ -85,9 +93,11 @@ class ClassDutyCourseFragment(val type: Int) :
85 trainTestAdapter?.addData(transExamData(list)) 93 trainTestAdapter?.addData(transExamData(list))
86 } 94 }
87 } 95 }
88 - binding.smartRefresh.setEnableLoadMore(list.size == 10)  
89 - binding.smartRefresh.finishLoadMore()  
90 - binding.smartRefresh.finishRefresh() 96 + if (list.size < 10) {
  97 + trainTestAdapter?.loadMoreModule?.loadMoreEnd()
  98 + } else {
  99 + trainTestAdapter?.loadMoreModule?.loadMoreComplete()
  100 + }
91 }) 101 })
92 } 102 }
93 103
@@ -110,15 +120,22 @@ class ClassDutyCourseFragment(val type: Int) : @@ -110,15 +120,22 @@ class ClassDutyCourseFragment(val type: Int) :
110 return course 120 return course
111 } 121 }
112 122
113 - override fun registerListener() {  
114 - binding.apply {  
115 - smartRefresh.setOnRefreshListener {  
116 - refreshData()  
117 - }  
118 - smartRefresh.setOnLoadMoreListener {  
119 - loadMore() 123 + fun paramBean(data: TrainTestData): CourseParam {
  124 + val course = CourseParam()
  125 + course.isTrainClass = true
  126 + course.mTrainClassId = "${
  127 + if (data.isTest) {
  128 + data.practice?.id
  129 + } else {
  130 + data.exam?.id
120 } 131 }
  132 + }"
  133 + course.type = data.itemType
  134 + return course
  135 + }
121 136
  137 + override fun registerListener() {
  138 + binding.apply {
122 val vsi = if (ConstantType.TYPE_CLASS_COURSE == type) { 139 val vsi = if (ConstantType.TYPE_CLASS_COURSE == type) {
123 View.VISIBLE 140 View.VISIBLE
124 } else { 141 } else {
@@ -147,17 +164,29 @@ class ClassDutyCourseFragment(val type: Int) : @@ -147,17 +164,29 @@ class ClassDutyCourseFragment(val type: Int) :
147 0 164 0
148 ) 165 )
149 ) 166 )
  167 + binding.smartRefresh.setOnRefreshListener {
  168 + refreshData()
  169 + }
150 when (type) { 170 when (type) {
151 ConstantType.TYPE_CLASS_COURSE -> { 171 ConstantType.TYPE_CLASS_COURSE -> {
152 courseAdapter = CourseAdapter() 172 courseAdapter = CourseAdapter()
153 binding.recyclerview.adapter = courseAdapter 173 binding.recyclerview.adapter = courseAdapter
  174 + courseAdapter?.loadMoreModule?.isAutoLoadMore = true
  175 + courseAdapter?.loadMoreModule?.isEnableLoadMoreIfNotFullPage = false
  176 + courseAdapter?.loadMoreModule?.setOnLoadMoreListener {
  177 + loadMore()
  178 + }
154 } 179 }
155 else -> { 180 else -> {
156 trainTestAdapter = TrainTestAdapter() 181 trainTestAdapter = TrainTestAdapter()
157 binding.recyclerview.adapter = trainTestAdapter 182 binding.recyclerview.adapter = trainTestAdapter
  183 + trainTestAdapter?.loadMoreModule?.isAutoLoadMore = true
  184 + trainTestAdapter?.loadMoreModule?.isEnableLoadMoreIfNotFullPage = false
  185 + courseAdapter?.loadMoreModule?.setOnLoadMoreListener {
  186 + loadMore()
  187 + }
158 } 188 }
159 } 189 }
160 -  
161 } 190 }
162 191
163 private fun transPracticeData(list: List<PractiseBean>): List<TrainTestData> { 192 private fun transPracticeData(list: List<PractiseBean>): List<TrainTestData> {
@@ -181,10 +210,25 @@ class ClassDutyCourseFragment(val type: Int) : @@ -181,10 +210,25 @@ class ClassDutyCourseFragment(val type: Int) :
181 getData() 210 getData()
182 } 211 }
183 212
184 - override fun onClick(position: Int, data: LessonBean) { 213 +// //todo 时间校验限制等
  214 +// fun checkTime(exam: ExamBean): Boolean {
  215 +//
  216 +// }
  217 +
  218 + override fun itemClick(item: TrainTestData) {
  219 + this@ClassDutyCourseFragment.startActivity(
  220 + Intent(
  221 + requireActivity(),
  222 + CoursePractiseActivity::class.java
  223 + ).putExtra(ConstantParamKey.COURSE_BEAN, paramBean(item))
  224 + .putExtra("isExam", !item.isTest)
  225 + )
  226 + }
  227 +
  228 + override fun itemClick(response: LessonBean) {
185 // 课程分类:1=视频课,2=直播课,3=线下培训,4=文本课 229 // 课程分类:1=视频课,2=直播课,3=线下培训,4=文本课
186 - val param = paramLessonBean(data)  
187 - when (data.itemType) { 230 + val param = paramLessonBean(response)
  231 + when (response.itemType) {
188 4 -> { 232 4 -> {
189 this@ClassDutyCourseFragment.startActivity( 233 this@ClassDutyCourseFragment.startActivity(
190 Intent( 234 Intent(
@@ -203,7 +247,4 @@ class ClassDutyCourseFragment(val type: Int) : @@ -203,7 +247,4 @@ class ClassDutyCourseFragment(val type: Int) :
203 } 247 }
204 } 248 }
205 } 249 }
206 -  
207 - override fun itemClick(item: TrainTestData) {  
208 - }  
209 } 250 }
@@ -3,6 +3,7 @@ package com.br_technology.securitytrain_master.ui.view.mine.fragment @@ -3,6 +3,7 @@ package com.br_technology.securitytrain_master.ui.view.mine.fragment
3 import android.content.Context 3 import android.content.Context
4 import android.content.Intent 4 import android.content.Intent
5 import android.view.LayoutInflater 5 import android.view.LayoutInflater
  6 +import android.view.View
6 import android.view.ViewGroup 7 import android.view.ViewGroup
7 import androidx.recyclerview.widget.LinearLayoutManager 8 import androidx.recyclerview.widget.LinearLayoutManager
8 import com.br_technology.securitytrain_master.base.common.ConstantParamKey 9 import com.br_technology.securitytrain_master.base.common.ConstantParamKey
@@ -44,7 +45,15 @@ class CourseFragment : @@ -44,7 +45,15 @@ class CourseFragment :
44 45
45 override fun initDataObserver() { 46 override fun initDataObserver() {
46 mViewModel.lessonList.observe(this, { 47 mViewModel.lessonList.observe(this, {
  48 + binding.smartRefresh.finishRefresh()
  49 + binding.smartRefresh.finishLoadMore()
47 if (page == 1) { 50 if (page == 1) {
  51 + val data = it.data.list.data
  52 + binding.none.visibility = if (!data.isEmpty()) {
  53 + View.GONE
  54 + } else {
  55 + View.VISIBLE
  56 + }
48 docAdapter = TxtAdapter() 57 docAdapter = TxtAdapter()
49 binding.result.adapter = docAdapter 58 binding.result.adapter = docAdapter
50 docAdapter.addList(it.data.list.data) 59 docAdapter.addList(it.data.list.data)
@@ -67,6 +76,11 @@ class CourseFragment : @@ -67,6 +76,11 @@ class CourseFragment :
67 } 76 }
68 } 77 }
69 ) 78 )
  79 + mViewModel.favoriteResponse.observe(this, {
  80 + if (it.msg.contains("取消收藏成功")) {
  81 + refresh()
  82 + }
  83 + })
70 } 84 }
71 85
72 private fun refresh() { 86 private fun refresh() {
@@ -81,7 +95,7 @@ class CourseFragment : @@ -81,7 +95,7 @@ class CourseFragment :
81 binding.smartRefresh.setEnableRefresh(false) 95 binding.smartRefresh.setEnableRefresh(false)
82 } 96 }
83 97
84 - class TxtAdapter : BaseAdapter<FavoriteData, AdapterSideslipBinding>() { 98 + inner class TxtAdapter : BaseAdapter<FavoriteData, AdapterSideslipBinding>() {
85 override fun getViewBinding( 99 override fun getViewBinding(
86 context: Context, 100 context: Context,
87 parent: ViewGroup, 101 parent: ViewGroup,
@@ -95,6 +109,9 @@ class CourseFragment : @@ -95,6 +109,9 @@ class CourseFragment :
95 holder.pic.glideRound(data.image, 16) 109 holder.pic.glideRound(data.image, 16)
96 holder.name.text = data.title 110 holder.name.text = data.title
97 holder.info.text = data.des 111 holder.info.text = data.des
  112 + holder.delete.setOnClickListener {
  113 + mViewModel.collect("2", data.object_id)
  114 + }
98 } 115 }
99 } 116 }
100 } 117 }
@@ -3,6 +3,7 @@ package com.br_technology.securitytrain_master.ui.view.mine.fragment @@ -3,6 +3,7 @@ package com.br_technology.securitytrain_master.ui.view.mine.fragment
3 import android.content.Context 3 import android.content.Context
4 import android.content.Intent 4 import android.content.Intent
5 import android.view.LayoutInflater 5 import android.view.LayoutInflater
  6 +import android.view.View
6 import android.view.ViewGroup 7 import android.view.ViewGroup
7 import androidx.recyclerview.widget.LinearLayoutManager 8 import androidx.recyclerview.widget.LinearLayoutManager
8 import com.br_technology.securitytrain_master.base.common.ConstantParamKey 9 import com.br_technology.securitytrain_master.base.common.ConstantParamKey
@@ -44,7 +45,15 @@ class DatabaseFragment : @@ -44,7 +45,15 @@ class DatabaseFragment :
44 45
45 override fun initDataObserver() { 46 override fun initDataObserver() {
46 mViewModel.docList.observe(this, { 47 mViewModel.docList.observe(this, {
  48 + binding.smartRefresh.finishRefresh()
  49 + binding.smartRefresh.finishLoadMore()
47 if (page == 1) { 50 if (page == 1) {
  51 + val data = it.data.list.data
  52 + binding.none.visibility = if (!data.isEmpty()) {
  53 + View.GONE
  54 + } else {
  55 + View.VISIBLE
  56 + }
48 docAdapter = DocAdapter() 57 docAdapter = DocAdapter()
49 binding.result.adapter = docAdapter 58 binding.result.adapter = docAdapter
50 docAdapter.addList(it.data.list.data) 59 docAdapter.addList(it.data.list.data)
@@ -63,6 +72,11 @@ class DatabaseFragment : @@ -63,6 +72,11 @@ class DatabaseFragment :
63 } 72 }
64 } 73 }
65 ) 74 )
  75 + mViewModel.favoriteResponse.observe(this, {
  76 + if (it.msg.contains("取消收藏成功")) {
  77 + refresh()
  78 + }
  79 + })
66 } 80 }
67 81
68 private fun refresh() { 82 private fun refresh() {
@@ -78,7 +92,7 @@ class DatabaseFragment : @@ -78,7 +92,7 @@ class DatabaseFragment :
78 } 92 }
79 93
80 94
81 - class DocAdapter : BaseAdapter<FavoriteData, AdapterSideslipBinding>() { 95 + inner class DocAdapter : BaseAdapter<FavoriteData, AdapterSideslipBinding>() {
82 override fun getViewBinding( 96 override fun getViewBinding(
83 context: Context, 97 context: Context,
84 parent: ViewGroup, 98 parent: ViewGroup,
@@ -92,6 +106,9 @@ class DatabaseFragment : @@ -92,6 +106,9 @@ class DatabaseFragment :
92 holder.pic.glideRound(data.image, 16) 106 holder.pic.glideRound(data.image, 16)
93 holder.name.text = data.title 107 holder.name.text = data.title
94 holder.info.text = data.des 108 holder.info.text = data.des
  109 + holder.delete.setOnClickListener {
  110 + mViewModel.collect("1", data.object_id)
  111 + }
95 } 112 }
96 } 113 }
97 } 114 }
@@ -4,7 +4,6 @@ import android.content.Intent @@ -4,7 +4,6 @@ import android.content.Intent
4 import android.view.View 4 import android.view.View
5 import com.br_technology.securitytrain_master.R 5 import com.br_technology.securitytrain_master.R
6 import com.br_technology.securitytrain_master.databinding.FragmentMineBinding 6 import com.br_technology.securitytrain_master.databinding.FragmentMineBinding
7 -import com.br_technology.securitytrain_master.ui.view.home.activity.course.LocationSignActivity  
8 import com.br_technology.securitytrain_master.ui.view.home.viewmodel.MineViewModel 7 import com.br_technology.securitytrain_master.ui.view.home.viewmodel.MineViewModel
9 import com.br_technology.securitytrain_master.ui.view.login.activity.AccountLoginActivity 8 import com.br_technology.securitytrain_master.ui.view.login.activity.AccountLoginActivity
10 import com.br_technology.securitytrain_master.ui.view.mine.activity.* 9 import com.br_technology.securitytrain_master.ui.view.mine.activity.*
@@ -93,8 +92,7 @@ class MineFragment @@ -93,8 +92,7 @@ class MineFragment
93 } 92 }
94 R.id.tv_academic_feedback -> { 93 R.id.tv_academic_feedback -> {
95 //学情反馈 94 //学情反馈
96 -// startActivity(AcademicFeedbackActivity::class.java)  
97 - startActivity(LocationSignActivity::class.java) 95 + startActivity(AcademicFeedbackActivity::class.java)
98 } 96 }
99 R.id.tv_offline_exercise -> { 97 R.id.tv_offline_exercise -> {
100 //线下培训 98 //线下培训
1 -package com.br_technology.securitytrain_master.ui.view.mine.repository  
2 -  
3 -import androidx.lifecycle.MutableLiveData  
4 -import com.br_technology.securitytrain_master.base.common.State  
5 -import com.br_technology.securitytrain_master.base.repository.ApiRepository  
6 -  
7 -/**  
8 - * Time: 8/2/2021 15:52  
9 - * Author: Captain  
10 - * Description: 初见时你很迷人  
11 - */  
12 -class LearningReportRepository(val loadState: MutableLiveData<State>) : ApiRepository(loadState) {  
13 -}  
@@ -19,6 +19,7 @@ import com.br_technology.securitytrain_master.ui.bean.MaterialPage @@ -19,6 +19,7 @@ import com.br_technology.securitytrain_master.ui.bean.MaterialPage
19 class DatabaseFViewModel : BaseViewModel<DocRepository>() { 19 class DatabaseFViewModel : BaseViewModel<DocRepository>() {
20 // 资料 20 // 资料
21 val docList = MutableLiveData<BaseResponse<CommonDataList<CommonPage<FavoriteData>>>>() 21 val docList = MutableLiveData<BaseResponse<CommonDataList<CommonPage<FavoriteData>>>>()
  22 +
22 // 文本课程 23 // 文本课程
23 val lessonList = MutableLiveData<BaseResponse<CommonDataList<CommonPage<FavoriteData>>>>() 24 val lessonList = MutableLiveData<BaseResponse<CommonDataList<CommonPage<FavoriteData>>>>()
24 25
@@ -26,6 +27,15 @@ class DatabaseFViewModel : BaseViewModel<DocRepository>() { @@ -26,6 +27,15 @@ class DatabaseFViewModel : BaseViewModel<DocRepository>() {
26 val classifyDataList = MutableLiveData<BaseResponse<MaterialPage>>() 27 val classifyDataList = MutableLiveData<BaseResponse<MaterialPage>>()
27 val type = MutableLiveData<Int>() 28 val type = MutableLiveData<Int>()
28 val sortId = MutableLiveData<Int>() 29 val sortId = MutableLiveData<Int>()
  30 + var favoriteResponse = MutableLiveData<BaseResponse<Void>>()
  31 +
  32 + fun collect(
  33 + type: String,
  34 + favorite_id: String
  35 + ) {
  36 + mRepository.collect(type, favorite_id, favoriteResponse)
  37 + }
  38 +
29 39
30 fun geClassify() { 40 fun geClassify() {
31 type.value?.let { mRepository.getDocClassify(it, classify) } 41 type.value?.let { mRepository.getDocClassify(it, classify) }
1 package com.br_technology.securitytrain_master.ui.view.mine.viewmodel 1 package com.br_technology.securitytrain_master.ui.view.mine.viewmodel
2 2
  3 +import androidx.lifecycle.MutableLiveData
  4 +import com.br_technology.securitytrain_master.base.network.response.BaseResponse
  5 +import com.br_technology.securitytrain_master.base.network.response.CommonReport
  6 +import com.br_technology.securitytrain_master.base.repository.TrainRepository
3 import com.br_technology.securitytrain_master.base.view.BaseViewModel 7 import com.br_technology.securitytrain_master.base.view.BaseViewModel
4 -import com.br_technology.securitytrain_master.ui.view.mine.repository.LearningReportRepository 8 +import com.br_technology.securitytrain_master.ui.bean.TrainReport
5 9
6 /** 10 /**
7 * Time: 8/2/2021 15:52 11 * Time: 8/2/2021 15:52
8 * Author: Captain 12 * Author: Captain
9 * Description: 初见时你很迷人 13 * Description: 初见时你很迷人
10 */ 14 */
11 -class LearningReportViewModel : BaseViewModel<LearningReportRepository>() { 15 +class LearningReportViewModel : BaseViewModel<TrainRepository>() {
  16 + val data = MutableLiveData<BaseResponse<CommonReport<TrainReport>>>()
  17 +
  18 + fun getReport(){
  19 + mRepository.trainReport(data)
  20 + }
12 } 21 }
1 package com.br_technology.securitytrain_master.ui.view.home.viewmodel 1 package com.br_technology.securitytrain_master.ui.view.home.viewmodel
2 2
3 import androidx.lifecycle.MutableLiveData 3 import androidx.lifecycle.MutableLiveData
  4 +import com.br_technology.securitytrain_master.base.network.response.BaseResponse
4 import com.br_technology.securitytrain_master.base.view.BaseViewModel 5 import com.br_technology.securitytrain_master.base.view.BaseViewModel
5 import com.br_technology.securitytrain_master.ui.view.mine.bean.ContactServiceBean 6 import com.br_technology.securitytrain_master.ui.view.mine.bean.ContactServiceBean
6 import com.br_technology.securitytrain_master.ui.view.mine.repository.ServiceRepository 7 import com.br_technology.securitytrain_master.ui.view.mine.repository.ServiceRepository
7 -import com.br_technology.securitytrain_master.base.network.response.BaseResponse  
8 8
9 /** 9 /**
10 * createTime:2021/7/27 15:48 10 * createTime:2021/7/27 15:48
11 * auth:张继 11 * auth:张继
12 * des: 12 * des:
13 */ 13 */
14 -class ServiceViewModel: BaseViewModel<ServiceRepository>() { 14 +class ServiceViewModel : BaseViewModel<ServiceRepository>() {
15 var mContactServiceBean: MutableLiveData<BaseResponse<ContactServiceBean>> = MutableLiveData() 15 var mContactServiceBean: MutableLiveData<BaseResponse<ContactServiceBean>> = MutableLiveData()
16 16
17 fun contactService() { 17 fun contactService() {
18 - mRepository.contactService( mContactServiceBean) 18 + mRepository.contactService(mContactServiceBean)
19 } 19 }
20 } 20 }
1 package com.br_technology.securitytrain_master.util 1 package com.br_technology.securitytrain_master.util
2 2
  3 +import android.content.ContentValues
  4 +import android.content.Context
  5 +import android.content.Intent
  6 +import android.media.MediaScannerConnection
  7 +import android.net.Uri
  8 +import android.os.Build
3 import android.os.Environment 9 import android.os.Environment
  10 +import android.provider.MediaStore
4 import android.text.TextUtils 11 import android.text.TextUtils
5 import com.br_technology.securitytrain_master.base.view.BaseApplication 12 import com.br_technology.securitytrain_master.base.view.BaseApplication
6 import java.io.File 13 import java.io.File
@@ -9,6 +16,7 @@ import java.io.InputStream @@ -9,6 +16,7 @@ import java.io.InputStream
9 import java.io.OutputStream 16 import java.io.OutputStream
10 import java.net.HttpURLConnection 17 import java.net.HttpURLConnection
11 import java.net.URL 18 import java.net.URL
  19 +import java.net.URLConnection
12 20
13 /** 21 /**
14 * Author by YSir 22 * Author by YSir
@@ -34,6 +42,10 @@ object TrainFileUtil { @@ -34,6 +42,10 @@ object TrainFileUtil {
34 return File(getTrainCacheDir(), "trainLoad") 42 return File(getTrainCacheDir(), "trainLoad")
35 } 43 }
36 44
  45 + fun getTrainLoad(): File {
  46 + return File(getTrainExternalCacheDir(), "trainLoad")
  47 + }
  48 +
37 fun getTrainExternalCacheDir(): File? { 49 fun getTrainExternalCacheDir(): File? {
38 // 判断sd卡是否存在 50 // 判断sd卡是否存在
39 val sdCardExist = (Environment.getExternalStorageState() == Environment.MEDIA_MOUNTED) 51 val sdCardExist = (Environment.getExternalStorageState() == Environment.MEDIA_MOUNTED)
@@ -72,6 +84,10 @@ object TrainFileUtil { @@ -72,6 +84,10 @@ object TrainFileUtil {
72 } 84 }
73 85
74 fun fileLoad(file: File, fileUrl: String, iLoad: ILoad) { 86 fun fileLoad(file: File, fileUrl: String, iLoad: ILoad) {
  87 + fileLoad(file, fileUrl, false, iLoad)
  88 + }
  89 +
  90 + fun fileLoad(file: File, fileUrl: String, notice: Boolean, iLoad: ILoad) {
75 val hasLoad = file.exists() && file.isFile 91 val hasLoad = file.exists() && file.isFile
76 if (hasLoad) { 92 if (hasLoad) {
77 iLoad.success(file) 93 iLoad.success(file)
@@ -102,15 +118,64 @@ object TrainFileUtil { @@ -102,15 +118,64 @@ object TrainFileUtil {
102 iLoad.progress(percent) 118 iLoad.progress(percent)
103 } 119 }
104 outputStream.flush() 120 outputStream.flush()
105 - iLoad.success(file)  
106 } catch (e: Exception) { 121 } catch (e: Exception) {
107 e.printStackTrace() 122 e.printStackTrace()
108 iLoad.fail() 123 iLoad.fail()
109 } finally { 124 } finally {
110 inputStream?.close() 125 inputStream?.close()
111 outputStream?.close() 126 outputStream?.close()
  127 + if (notice) {
  128 + notice(file)
  129 + }
112 iLoad.success(file) 130 iLoad.success(file)
113 } 131 }
114 } 132 }
115 133
  134 + fun getFileType(file: File?): String {
  135 + if (file != null && file.isFile) {
  136 + val fileNameMap = URLConnection.getFileNameMap()
  137 + return fileNameMap.getContentTypeFor(file.name)
  138 + }
  139 + return ""
  140 + }
  141 +
  142 + fun scanFile(context: Context?, file: File) {
  143 + MediaScannerConnection.scanFile(
  144 + context, arrayOf(file.path), arrayOf(getFileType(file))
  145 + ) { path: String?, uri: Uri? -> }
  146 + }
  147 +
  148 + private fun notice(file: File) {
  149 + // 其次把文件插入到系统图库
  150 + val context = BaseApplication.instance.getApplicationContext()
  151 + try {
  152 + // 最后通知图库更新
  153 + if (Build.VERSION.SDK_INT > Build.VERSION_CODES.Q) {
  154 + val values = ContentValues()
  155 + values.put(MediaStore.Images.Media.DATA, file.absolutePath)
  156 + values.put(MediaStore.Images.Media.MIME_TYPE, getFileType(file))
  157 + context.contentResolver.insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values)
  158 + } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
  159 + MediaScannerConnection.scanFile(
  160 + context, arrayOf(file.absolutePath), null
  161 + ) { path: String?, uri: Uri? ->
  162 + val mediaScanIntent = Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE)
  163 + mediaScanIntent.data = uri
  164 + context.sendBroadcast(mediaScanIntent)
  165 + }
  166 + // MediaStore.Images.Media.insertImage(context.getContentResolver(), file.getAbsolutePath(), file.getName(), null);
  167 + } else {
  168 + context.sendBroadcast(
  169 + Intent(
  170 + Intent.ACTION_MEDIA_SCANNER_SCAN_FILE,
  171 + Uri.fromFile(File(file.path))
  172 + )
  173 + )
  174 + }
  175 + } catch (e: java.lang.Exception) {
  176 + e.printStackTrace()
  177 + }
  178 + }
  179 +
  180 +
116 } 181 }
@@ -37,8 +37,8 @@ class DialogTitle(context: Context) : Dialog(context, R.style.UserDefaultDialog) @@ -37,8 +37,8 @@ class DialogTitle(context: Context) : Dialog(context, R.style.UserDefaultDialog)
37 val attributes = window?.attributes 37 val attributes = window?.attributes
38 attributes?.width = binding.root.screenWidth() - 80.dp2px() 38 attributes?.width = binding.root.screenWidth() - 80.dp2px()
39 // 点击区域外取消 39 // 点击区域外取消
40 - setCanceledOnTouchOutside(false)  
41 - setCancelable(false) 40 + setCanceledOnTouchOutside(true)
  41 + setCancelable(true)
42 binding.apply { 42 binding.apply {
43 // 确定 43 // 确定
44 complete.setOnClickListener { 44 complete.setOnClickListener {
@@ -5,7 +5,6 @@ import android.content.Context @@ -5,7 +5,6 @@ import android.content.Context
5 import android.content.res.Configuration 5 import android.content.res.Configuration
6 import android.text.TextUtils 6 import android.text.TextUtils
7 import android.util.AttributeSet 7 import android.util.AttributeSet
8 -import android.view.View  
9 import android.widget.ImageView 8 import android.widget.ImageView
10 import androidx.lifecycle.Lifecycle 9 import androidx.lifecycle.Lifecycle
11 import androidx.lifecycle.LifecycleObserver 10 import androidx.lifecycle.LifecycleObserver
@@ -38,6 +37,12 @@ class MyVideoPlayer : StandardGSYVideoPlayer, LifecycleObserver { @@ -38,6 +37,12 @@ class MyVideoPlayer : StandardGSYVideoPlayer, LifecycleObserver {
38 // return R.layout.layout_video_player 37 // return R.layout.layout_video_player
39 // } 38 // }
40 39
  40 + interface IStatusChange {
  41 + fun status(isPause: Boolean, isFinish: Boolean)
  42 + }
  43 +
  44 + var mStatusChange: IStatusChange? = null
  45 +
41 46
42 override fun updateStartImage() { 47 override fun updateStartImage() {
43 super.updateStartImage() 48 super.updateStartImage()
@@ -102,7 +107,12 @@ class MyVideoPlayer : StandardGSYVideoPlayer, LifecycleObserver { @@ -102,7 +107,12 @@ class MyVideoPlayer : StandardGSYVideoPlayer, LifecycleObserver {
102 107
103 override fun onQuitFullscreen(url: String?, vararg objects: Any?) { 108 override fun onQuitFullscreen(url: String?, vararg objects: Any?) {
104 super.onQuitFullscreen(url, *objects) 109 super.onQuitFullscreen(url, *objects)
105 - orientationUtils?.backToProtVideo(); 110 + orientationUtils?.backToProtVideo();
  111 + }
  112 +
  113 + override fun onComplete(url: String?, vararg objects: Any?) {
  114 + super.onComplete(url, *objects)
  115 + mStatusChange?.status(false, true)
106 } 116 }
107 }).build(this) 117 }).build(this)
108 118
@@ -132,6 +142,12 @@ class MyVideoPlayer : StandardGSYVideoPlayer, LifecycleObserver { @@ -132,6 +142,12 @@ class MyVideoPlayer : StandardGSYVideoPlayer, LifecycleObserver {
132 142
133 } 143 }
134 144
  145 + override fun onVideoPause() {
  146 + super.onVideoPause()
  147 + isPause = true
  148 + mStatusChange?.status(true, isFinish = false)
  149 + }
  150 +
135 @OnLifecycleEvent(Lifecycle.Event.ON_RESUME) 151 @OnLifecycleEvent(Lifecycle.Event.ON_RESUME)
136 private fun onResume() { 152 private fun onResume() {
137 this.currentPlayer.onVideoResume(false) 153 this.currentPlayer.onVideoResume(false)
@@ -142,6 +158,21 @@ class MyVideoPlayer : StandardGSYVideoPlayer, LifecycleObserver { @@ -142,6 +158,21 @@ class MyVideoPlayer : StandardGSYVideoPlayer, LifecycleObserver {
142 private fun onPause() { 158 private fun onPause() {
143 this.currentPlayer.onVideoPause() 159 this.currentPlayer.onVideoPause()
144 isPause = true 160 isPause = true
  161 + mStatusChange?.status(true, isFinish = false)
  162 + }
  163 +
  164 + fun getProgressTime(): String {
  165 + return when (mCurrentState) {
  166 + CURRENT_STATE_PLAYING, CURRENT_STATE_PAUSE -> {
  167 + "$currentPositionWhenPlaying"
  168 + }
  169 + CURRENT_STATE_AUTO_COMPLETE -> {
  170 + "$duration"
  171 + }
  172 + else -> {
  173 + "0"
  174 + }
  175 + }
145 } 176 }
146 177
147 @OnLifecycleEvent(Lifecycle.Event.ON_DESTROY) 178 @OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
@@ -69,6 +69,10 @@ class ViewToolBar(context: Context, attrs: AttributeSet) : RelativeLayout(contex @@ -69,6 +69,10 @@ class ViewToolBar(context: Context, attrs: AttributeSet) : RelativeLayout(contex
69 inflate.title.text = text 69 inflate.title.text = text
70 } 70 }
71 71
  72 + fun getTitle(): String {
  73 + return inflate.title.text.toString()
  74 + }
  75 +
72 fun setRightText(text: String) { 76 fun setRightText(text: String) {
73 inflate.rightText.text = text 77 inflate.rightText.text = text
74 } 78 }
@@ -28,6 +28,7 @@ @@ -28,6 +28,7 @@
28 android:layout_below="@id/tool_bar" 28 android:layout_below="@id/tool_bar"
29 android:layout_marginStart="16dp" 29 android:layout_marginStart="16dp"
30 android:layout_marginTop="24dp" 30 android:layout_marginTop="24dp"
  31 + android:visibility="gone"
31 android:layout_marginBottom="8dp" 32 android:layout_marginBottom="8dp"
32 android:text="答题卡" 33 android:text="答题卡"
33 android:textColor="@color/color_32" 34 android:textColor="@color/color_32"
@@ -170,7 +170,7 @@ @@ -170,7 +170,7 @@
170 170
171 <LinearLayout 171 <LinearLayout
172 android:layout_width="match_parent" 172 android:layout_width="match_parent"
173 - android:layout_height="wrap_content" 173 + android:layout_height="0dp"
174 android:layout_weight="1" 174 android:layout_weight="1"
175 android:orientation="horizontal"> 175 android:orientation="horizontal">
176 176
@@ -178,11 +178,10 @@ @@ -178,11 +178,10 @@
178 178
179 <TextView 179 <TextView
180 android:id="@+id/tv_upload" 180 android:id="@+id/tv_upload"
181 - android:layout_width="343dp" 181 + android:layout_width="match_parent"
  182 + android:layout_margin="16dp"
182 android:layout_height="44dp" 183 android:layout_height="44dp"
183 android:layout_gravity="center_horizontal" 184 android:layout_gravity="center_horizontal"
184 - android:layout_marginTop="40dp"  
185 - android:layout_marginBottom="42dp"  
186 android:background="@drawable/solid_25_4" 185 android:background="@drawable/solid_25_4"
187 android:gravity="center" 186 android:gravity="center"
188 android:text="提交信息" 187 android:text="提交信息"
@@ -31,13 +31,13 @@ @@ -31,13 +31,13 @@
31 android:src="@mipmap/placeholder_head" /> 31 android:src="@mipmap/placeholder_head" />
32 32
33 <TextView 33 <TextView
  34 + android:id="@+id/tv_score"
34 android:layout_width="115dp" 35 android:layout_width="115dp"
35 android:layout_height="32dp" 36 android:layout_height="32dp"
36 android:layout_centerHorizontal="true" 37 android:layout_centerHorizontal="true"
37 android:layout_marginTop="144dp" 38 android:layout_marginTop="144dp"
38 android:background="@drawable/solid_ff_16" 39 android:background="@drawable/solid_ff_16"
39 android:gravity="center" 40 android:gravity="center"
40 - android:text="积分220"  
41 android:textColor="@color/color_25" 41 android:textColor="@color/color_25"
42 android:textSize="14sp" /> 42 android:textSize="14sp" />
43 43
@@ -21,8 +21,7 @@ @@ -21,8 +21,7 @@
21 android:layout_width="match_parent" 21 android:layout_width="match_parent"
22 android:layout_height="0dp" 22 android:layout_height="0dp"
23 android:layout_weight="1" 23 android:layout_weight="1"
24 - android:layout_margin="40dp">  
25 - 24 + android:layout_margin="16dp">
26 25
27 <LinearLayout 26 <LinearLayout
28 android:layout_width="match_parent" 27 android:layout_width="match_parent"
@@ -51,8 +50,8 @@ @@ -51,8 +50,8 @@
51 50
52 <ImageView 51 <ImageView
53 android:id="@+id/code" 52 android:id="@+id/code"
54 - android:layout_width="196dp"  
55 - android:layout_height="196dp" 53 + android:layout_width="150dp"
  54 + android:layout_height="150dp"
56 android:scaleType="fitXY" 55 android:scaleType="fitXY"
57 android:layout_marginTop="43dp" 56 android:layout_marginTop="43dp"
58 android:layout_marginBottom="40dp" 57 android:layout_marginBottom="40dp"
@@ -93,7 +92,7 @@ @@ -93,7 +92,7 @@
93 android:layout_width="wrap_content" 92 android:layout_width="wrap_content"
94 android:layout_height="wrap_content" 93 android:layout_height="wrap_content"
95 android:layout_gravity="center_horizontal" 94 android:layout_gravity="center_horizontal"
96 - android:layout_marginTop="16dp" 95 + android:layout_margin="16dp"
97 android:drawablePadding="12dp" 96 android:drawablePadding="12dp"
98 android:text="保存在本地" 97 android:text="保存在本地"
99 android:textColor="@color/white" 98 android:textColor="@color/white"
@@ -8,31 +8,23 @@ @@ -8,31 +8,23 @@
8 android:foreground="?attr/selectableItemBackground" 8 android:foreground="?attr/selectableItemBackground"
9 android:background="@color/white"> 9 android:background="@color/white">
10 10
11 - <com.scwang.smart.refresh.layout.SmartRefreshLayout 11 + <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
12 android:id="@+id/smart_refresh" 12 android:id="@+id/smart_refresh"
13 android:layout_width="match_parent" 13 android:layout_width="match_parent"
14 android:layout_height="0dp" 14 android:layout_height="0dp"
15 android:layout_weight="1"> 15 android:layout_weight="1">
16 16
17 - <com.scwang.smart.refresh.header.MaterialHeader  
18 - android:layout_width="wrap_content"  
19 - android:layout_height="wrap_content" />  
20 -  
21 <androidx.recyclerview.widget.RecyclerView 17 <androidx.recyclerview.widget.RecyclerView
22 android:id="@+id/recyclerview" 18 android:id="@+id/recyclerview"
23 android:layout_width="match_parent" 19 android:layout_width="match_parent"
24 - android:layout_height="match_parent" 20 + android:layout_height="wrap_content"
25 android:layout_marginStart="16dp" 21 android:layout_marginStart="16dp"
26 android:layout_marginEnd="16dp" 22 android:layout_marginEnd="16dp"
27 android:layout_marginBottom="32dp" 23 android:layout_marginBottom="32dp"
28 android:overScrollMode="never" 24 android:overScrollMode="never"
29 android:scrollbars="none" 25 android:scrollbars="none"
30 app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" /> 26 app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
31 -  
32 - <com.scwang.smart.refresh.footer.ClassicsFooter  
33 - android:layout_width="wrap_content"  
34 - android:layout_height="wrap_content" />  
35 - </com.scwang.smart.refresh.layout.SmartRefreshLayout> 27 + </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
36 28
37 <LinearLayout 29 <LinearLayout
38 android:id="@+id/ll" 30 android:id="@+id/ll"
1 <?xml version="1.0" encoding="utf-8"?> 1 <?xml version="1.0" encoding="utf-8"?>
2 -  
3 -<com.scwang.smart.refresh.layout.SmartRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android" 2 +<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
4 xmlns:app="http://schemas.android.com/apk/res-auto" 3 xmlns:app="http://schemas.android.com/apk/res-auto"
5 - android:id="@+id/smart_refresh"  
6 android:layout_width="match_parent" 4 android:layout_width="match_parent"
7 android:layout_height="match_parent"> 5 android:layout_height="match_parent">
8 6
9 - <com.scwang.smart.refresh.header.ClassicsHeader 7 + <TextView
  8 + android:id="@+id/none"
10 android:layout_width="match_parent" 9 android:layout_width="match_parent"
11 - android:layout_height="wrap_content" /> 10 + android:layout_height="wrap_content"
  11 + android:text="暂无收藏"
  12 + android:visibility="gone"
  13 + android:gravity="center"
  14 + android:padding="32dp"/>
12 15
13 - <com.br_technology.securitytrain_master.view.SlideRecyclerView  
14 - android:id="@+id/result" 16 + <com.scwang.smart.refresh.layout.SmartRefreshLayout
  17 + android:id="@+id/smart_refresh"
15 android:layout_width="match_parent" 18 android:layout_width="match_parent"
16 - android:layout_height="match_parent"  
17 - android:overScrollMode="never"  
18 - android:paddingStart="16dp"  
19 - android:paddingEnd="16dp"  
20 - android:scrollbars="none"  
21 - app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" /> 19 + android:layout_height="match_parent">
  20 +
  21 + <com.scwang.smart.refresh.header.ClassicsHeader
  22 + android:layout_width="match_parent"
  23 + android:layout_height="wrap_content" />
  24 +
  25 + <com.br_technology.securitytrain_master.view.SlideRecyclerView
  26 + android:id="@+id/result"
  27 + android:layout_width="match_parent"
  28 + android:layout_height="match_parent"
  29 + android:overScrollMode="never"
  30 + android:paddingStart="16dp"
  31 + android:paddingEnd="16dp"
  32 + android:scrollbars="none"
  33 + app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
  34 +
  35 + <com.scwang.smart.refresh.footer.ClassicsFooter
  36 + android:layout_width="match_parent"
  37 + android:layout_height="wrap_content" />
  38 + </com.scwang.smart.refresh.layout.SmartRefreshLayout>
  39 +</FrameLayout>
22 40
23 - <com.scwang.smart.refresh.footer.ClassicsFooter  
24 - android:layout_width="match_parent"  
25 - android:layout_height="wrap_content" />  
26 -</com.scwang.smart.refresh.layout.SmartRefreshLayout>  
27 41
1 <?xml version="1.0" encoding="utf-8"?> 1 <?xml version="1.0" encoding="utf-8"?>
2 -  
3 -<com.scwang.smart.refresh.layout.SmartRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android" 2 +<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
4 xmlns:app="http://schemas.android.com/apk/res-auto" 3 xmlns:app="http://schemas.android.com/apk/res-auto"
5 - android:id="@+id/smart_refresh"  
6 android:layout_width="match_parent" 4 android:layout_width="match_parent"
7 android:layout_height="match_parent"> 5 android:layout_height="match_parent">
8 -  
9 - <com.scwang.smart.refresh.header.ClassicsHeader 6 + <TextView
  7 + android:id="@+id/none"
10 android:layout_width="match_parent" 8 android:layout_width="match_parent"
11 - android:layout_height="wrap_content" />  
12 -  
13 - <com.br_technology.securitytrain_master.view.SlideRecyclerView  
14 - android:id="@+id/result" 9 + android:layout_height="wrap_content"
  10 + android:text="暂无收藏"
  11 + android:visibility="gone"
  12 + android:gravity="center"
  13 + android:padding="32dp"/>
  14 + <com.scwang.smart.refresh.layout.SmartRefreshLayout
  15 + android:id="@+id/smart_refresh"
15 android:layout_width="match_parent" 16 android:layout_width="match_parent"
16 - android:layout_height="match_parent"  
17 - android:overScrollMode="never"  
18 - android:paddingStart="16dp"  
19 - android:paddingEnd="16dp"  
20 - android:scrollbars="none"  
21 - app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" /> 17 + android:layout_height="match_parent">
  18 +
  19 + <com.scwang.smart.refresh.header.ClassicsHeader
  20 + android:layout_width="match_parent"
  21 + android:layout_height="wrap_content" />
  22 +
  23 + <com.br_technology.securitytrain_master.view.SlideRecyclerView
  24 + android:id="@+id/result"
  25 + android:layout_width="match_parent"
  26 + android:layout_height="match_parent"
  27 + android:overScrollMode="never"
  28 + android:paddingStart="16dp"
  29 + android:paddingEnd="16dp"
  30 + android:scrollbars="none"
  31 + app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
  32 +
  33 + <com.scwang.smart.refresh.footer.ClassicsFooter
  34 + android:layout_width="match_parent"
  35 + android:layout_height="wrap_content" />
  36 + </com.scwang.smart.refresh.layout.SmartRefreshLayout>
  37 +</FrameLayout>
22 38
23 - <com.scwang.smart.refresh.footer.ClassicsFooter  
24 - android:layout_width="match_parent"  
25 - android:layout_height="wrap_content" />  
26 -</com.scwang.smart.refresh.layout.SmartRefreshLayout>  
27 39
@@ -7,6 +7,7 @@ @@ -7,6 +7,7 @@
7 android:orientation="vertical"> 7 android:orientation="vertical">
8 8
9 <include layout="@layout/layout_tool_bar_theme" /> 9 <include layout="@layout/layout_tool_bar_theme" />
  10 +
10 <LinearLayout 11 <LinearLayout
11 android:layout_width="match_parent" 12 android:layout_width="match_parent"
12 android:layout_height="?actionBarSize" 13 android:layout_height="?actionBarSize"
@@ -19,8 +20,8 @@ @@ -19,8 +20,8 @@
19 android:layout_width="87dp" 20 android:layout_width="87dp"
20 android:layout_height="match_parent" 21 android:layout_height="match_parent"
21 android:layout_gravity="center_vertical" 22 android:layout_gravity="center_vertical"
22 - android:src="@mipmap/home_top_bg"  
23 - android:contentDescription="@string/logo" /> 23 + android:contentDescription="@string/logo"
  24 + android:src="@mipmap/home_top_bg" />
24 25
25 <RelativeLayout 26 <RelativeLayout
26 android:id="@+id/search" 27 android:id="@+id/search"
@@ -106,15 +107,13 @@ @@ -106,15 +107,13 @@
106 android:contentDescription="@string/logo" 107 android:contentDescription="@string/logo"
107 android:src="@mipmap/announcement" /> 108 android:src="@mipmap/announcement" />
108 109
109 - <TextView 110 + <ViewFlipper
  111 + android:id="@+id/flipper_scan"
110 android:layout_width="0dp" 112 android:layout_width="0dp"
111 android:layout_height="wrap_content" 113 android:layout_height="wrap_content"
112 android:layout_gravity="center_vertical" 114 android:layout_gravity="center_vertical"
113 android:layout_marginStart="12dp" 115 android:layout_marginStart="12dp"
114 - android:layout_weight="1"  
115 - android:ellipsize="end"  
116 - android:maxLines="1"  
117 - android:text="最新课程通知,最新课程通知,最新课程通知,最新课程通知。。。" /> 116 + android:layout_weight="1" />
118 117
119 <ImageView 118 <ImageView
120 android:layout_width="wrap_content" 119 android:layout_width="wrap_content"
@@ -206,7 +205,6 @@ @@ -206,7 +205,6 @@
206 tools:itemCount="4" /> 205 tools:itemCount="4" />
207 206
208 <LinearLayout 207 <LinearLayout
209 - android:visibility="gone"  
210 android:id="@+id/ll_video" 208 android:id="@+id/ll_video"
211 android:layout_width="match_parent" 209 android:layout_width="match_parent"
212 android:layout_height="40dp" 210 android:layout_height="40dp"
@@ -256,7 +254,6 @@ @@ -256,7 +254,6 @@
256 app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" /> 254 app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
257 255
258 <LinearLayout 256 <LinearLayout
259 - android:visibility="gone"  
260 android:id="@+id/ll_recommend" 257 android:id="@+id/ll_recommend"
261 android:layout_width="match_parent" 258 android:layout_width="match_parent"
262 android:layout_height="40dp" 259 android:layout_height="40dp"