1、我的模块-我的错题列表
2、我的模块-我的答题记录 3、错题列表之重新答题 4、答题记录之答题详情 以上全写完
正在显示
35 个修改的文件
包含
1138 行增加
和
149 行删除
@@ -69,10 +69,12 @@ | @@ -69,10 +69,12 @@ | ||
69 | android:screenOrientation="portrait" | 69 | android:screenOrientation="portrait" |
70 | android:theme="@style/Theme.SecurityTrainMaster.Launcher"> | 70 | android:theme="@style/Theme.SecurityTrainMaster.Launcher"> |
71 | <intent-filter> | 71 | <intent-filter> |
72 | + | ||
72 | <action android:name="android.intent.action.MAIN" /> | 73 | <action android:name="android.intent.action.MAIN" /> |
73 | 74 | ||
74 | <category android:name="android.intent.category.LAUNCHER" /> | 75 | <category android:name="android.intent.category.LAUNCHER" /> |
75 | </intent-filter> | 76 | </intent-filter> |
77 | + | ||
76 | </activity> | 78 | </activity> |
77 | 79 | ||
78 | <activity | 80 | <activity |
@@ -193,6 +195,8 @@ | @@ -193,6 +195,8 @@ | ||
193 | android:configChanges="keyboard|keyboardHidden|orientation|screenSize|screenLayout|smallestScreenSize|uiMode" /> | 195 | android:configChanges="keyboard|keyboardHidden|orientation|screenSize|screenLayout|smallestScreenSize|uiMode" /> |
194 | <activity android:name=".ui.view.home.activity.course.CoursePractiseActivity" | 196 | <activity android:name=".ui.view.home.activity.course.CoursePractiseActivity" |
195 | android:configChanges="keyboard|keyboardHidden|orientation|screenSize|screenLayout|smallestScreenSize|uiMode"/> | 197 | android:configChanges="keyboard|keyboardHidden|orientation|screenSize|screenLayout|smallestScreenSize|uiMode"/> |
198 | + <activity android:name=".ui.view.bank.activity.AnswerRecordDetailsActivity" /> | ||
199 | + <activity android:name=".ui.view.bank.activity.WrongQuestionsActivity" /> | ||
196 | 200 | ||
197 | </application> | 201 | </application> |
198 | 202 |
@@ -63,7 +63,7 @@ interface AllItemApi : ApiService { | @@ -63,7 +63,7 @@ interface AllItemApi : ApiService { | ||
63 | @POST("/api/item/paper_list_detail") | 63 | @POST("/api/item/paper_list_detail") |
64 | fun specialPracticeDetail( | 64 | fun specialPracticeDetail( |
65 | @Field("paper_id") paper_id: String | 65 | @Field("paper_id") paper_id: String |
66 | - ): Observable<BaseResponse<CommonDetailList<PaperListDetail>>> | 66 | + ): Observable<BaseResponse<CommonDataList<PaperListDetail>>> |
67 | 67 | ||
68 | /** | 68 | /** |
69 | * 专项练习题目列表 | 69 | * 专项练习题目列表 |
@@ -87,7 +87,7 @@ interface AllItemApi : ApiService { | @@ -87,7 +87,7 @@ interface AllItemApi : ApiService { | ||
87 | @Field("pos_id") pos_ia: Int, // 工种id | 87 | @Field("pos_id") pos_ia: Int, // 工种id |
88 | @Field("page") page: Int, // 页数 | 88 | @Field("page") page: Int, // 页数 |
89 | @Field("pageNum") pageNum: Int // 每页条数 | 89 | @Field("pageNum") pageNum: Int // 每页条数 |
90 | - ): Observable<BaseResponse<CommonDetailList<CommonPage<PaperDaily>>>> | 90 | + ): Observable<BaseResponse<CommonDataList<CommonPage<PaperDaily>>>> |
91 | 91 | ||
92 | /** | 92 | /** |
93 | * 开始答题 | 93 | * 开始答题 |
@@ -135,7 +135,7 @@ interface AllItemApi : ApiService { | @@ -135,7 +135,7 @@ interface AllItemApi : ApiService { | ||
135 | @Field("type") type: Int, | 135 | @Field("type") type: Int, |
136 | @Field("page") page: Int, | 136 | @Field("page") page: Int, |
137 | @Field("page_num") page_num: Int | 137 | @Field("page_num") page_num: Int |
138 | - ): Observable<BaseResponse<CommonList<ErrorListItem>>> | 138 | + ): Observable<BaseResponse<CommonDataList<CommonPage<ErrorListItem>>>> |
139 | 139 | ||
140 | /** | 140 | /** |
141 | * 错题列表 | 141 | * 错题列表 |
@@ -153,7 +153,7 @@ interface AllItemApi : ApiService { | @@ -153,7 +153,7 @@ interface AllItemApi : ApiService { | ||
153 | * @param answer 答案都好分开 | 153 | * @param answer 答案都好分开 |
154 | */ | 154 | */ |
155 | @FormUrlEncoded | 155 | @FormUrlEncoded |
156 | - @POST("/api/item/user_sub_error") | 156 | + @POST("/api/item/item_sub_error") |
157 | fun subError( | 157 | fun subError( |
158 | @Field("error_id") error_id: Int, | 158 | @Field("error_id") error_id: Int, |
159 | @Field("answer") answer: String | 159 | @Field("answer") answer: String |
@@ -166,7 +166,7 @@ interface AllItemApi : ApiService { | @@ -166,7 +166,7 @@ interface AllItemApi : ApiService { | ||
166 | * @param item_type 答题类型1=每日一练2=挑战答题3=专项练习4=模拟考试 | 166 | * @param item_type 答题类型1=每日一练2=挑战答题3=专项练习4=模拟考试 |
167 | */ | 167 | */ |
168 | @FormUrlEncoded | 168 | @FormUrlEncoded |
169 | - @POST("/api/item/user_del_error") | 169 | + @POST("/api/item/item_del_error") |
170 | fun delError( | 170 | fun delError( |
171 | @Field("item_id") item_id: Int, | 171 | @Field("item_id") item_id: Int, |
172 | @Field("type") type: Int, | 172 | @Field("type") type: Int, |
@@ -185,7 +185,7 @@ interface AllItemApi : ApiService { | @@ -185,7 +185,7 @@ interface AllItemApi : ApiService { | ||
185 | @Field("type") type: Int, | 185 | @Field("type") type: Int, |
186 | @Field("page") page: Int, | 186 | @Field("page") page: Int, |
187 | @Field("page_num") page_num: Int | 187 | @Field("page_num") page_num: Int |
188 | - ): Observable<BaseResponse<CommonList<AnswerRecord>>> | 188 | + ): Observable<BaseResponse<CommonDataList<CommonPage<AnswerRecord>>>> |
189 | 189 | ||
190 | /** | 190 | /** |
191 | * 答题记录详情 | 191 | * 答题记录详情 |
@@ -196,9 +196,7 @@ interface AllItemApi : ApiService { | @@ -196,9 +196,7 @@ interface AllItemApi : ApiService { | ||
196 | @FormUrlEncoded | 196 | @FormUrlEncoded |
197 | @POST("/api/item/user_item_list_detail") | 197 | @POST("/api/item/user_item_list_detail") |
198 | fun errorSubDetail( | 198 | fun errorSubDetail( |
199 | - @Field("id") id: Int, | ||
200 | - @Field("page") page: Int, | ||
201 | - @Field("page_num") page_num: Int | 199 | + @Field("id") id: Int |
202 | ): Observable<BaseResponse<CommonList<AnswerDetail>>> | 200 | ): Observable<BaseResponse<CommonList<AnswerDetail>>> |
203 | 201 | ||
204 | } | 202 | } |
@@ -172,6 +172,8 @@ interface ApiService { | @@ -172,6 +172,8 @@ interface ApiService { | ||
172 | fun getMineInfo( | 172 | fun getMineInfo( |
173 | ): Observable<BaseResponse<MineInfoBean>> | 173 | ): Observable<BaseResponse<MineInfoBean>> |
174 | 174 | ||
175 | + | ||
176 | + | ||
175 | //退出登录 | 177 | //退出登录 |
176 | @POST("/api/user/logout") | 178 | @POST("/api/user/logout") |
177 | fun logout( | 179 | fun logout( |
@@ -11,7 +11,6 @@ open class CommonList<T>(var list: List<T>) | @@ -11,7 +11,6 @@ open class CommonList<T>(var list: List<T>) | ||
11 | open class CommonReport<T>(var report: T) | 11 | open class CommonReport<T>(var report: T) |
12 | open class CommonDataList<T>(var list: T) | 12 | open class CommonDataList<T>(var list: T) |
13 | open class CommonDetail<T>(var detail: T) | 13 | open class CommonDetail<T>(var detail: T) |
14 | -open class CommonDetailList<T>(var list: T) | ||
15 | open class CommonInfo<T>(var info: T) | 14 | open class CommonInfo<T>(var info: T) |
16 | open class CommonPage<T>( | 15 | open class CommonPage<T>( |
17 | var total: Int, // 总数 | 16 | var total: Int, // 总数 |
@@ -3,14 +3,11 @@ package com.br_technology.securitytrain_master.base.repository | @@ -3,14 +3,11 @@ package com.br_technology.securitytrain_master.base.repository | ||
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.BaseResponse | 5 | import com.br_technology.securitytrain_master.base.network.response.BaseResponse |
6 | -import com.br_technology.securitytrain_master.base.network.response.CommonDetailList | 6 | +import com.br_technology.securitytrain_master.base.network.response.CommonDataList |
7 | import com.br_technology.securitytrain_master.base.network.response.CommonList | 7 | import com.br_technology.securitytrain_master.base.network.response.CommonList |
8 | import com.br_technology.securitytrain_master.base.network.response.CommonPage | 8 | import com.br_technology.securitytrain_master.base.network.response.CommonPage |
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.bank.bean.PracticeBean | ||
11 | -import com.br_technology.securitytrain_master.ui.view.bank.bean.StartItemBean | ||
12 | -import com.br_technology.securitytrain_master.ui.view.bank.bean.SubjectData | ||
13 | -import com.br_technology.securitytrain_master.ui.view.bank.bean.TestSubject | 10 | +import com.br_technology.securitytrain_master.ui.view.bank.bean.* |
14 | 11 | ||
15 | /** | 12 | /** |
16 | * Author by YSir | 13 | * Author by YSir |
@@ -49,7 +46,7 @@ class ItemRepository(loadState: MutableLiveData<State>) : ApiRepository(loadStat | @@ -49,7 +46,7 @@ class ItemRepository(loadState: MutableLiveData<State>) : ApiRepository(loadStat | ||
49 | //专项练习详情 | 46 | //专项练习详情 |
50 | fun specialPracticeDetail( | 47 | fun specialPracticeDetail( |
51 | paper_id: String, | 48 | paper_id: String, |
52 | - liveData: MutableLiveData<BaseResponse<CommonDetailList<PaperListDetail>>> | 49 | + liveData: MutableLiveData<BaseResponse<CommonDataList<PaperListDetail>>> |
53 | ) { | 50 | ) { |
54 | addRequest(itemService.specialPracticeDetail(paper_id), liveData) | 51 | addRequest(itemService.specialPracticeDetail(paper_id), liveData) |
55 | } | 52 | } |
@@ -67,7 +64,7 @@ class ItemRepository(loadState: MutableLiveData<State>) : ApiRepository(loadStat | @@ -67,7 +64,7 @@ class ItemRepository(loadState: MutableLiveData<State>) : ApiRepository(loadStat | ||
67 | pos_id: Int, | 64 | pos_id: Int, |
68 | page: Int, | 65 | page: Int, |
69 | pageNum: Int, | 66 | pageNum: Int, |
70 | - liveData: MutableLiveData<BaseResponse<CommonDetailList<CommonPage<PaperDaily>>>> | 67 | + liveData: MutableLiveData<BaseResponse<CommonDataList<CommonPage<PaperDaily>>>> |
71 | ) { | 68 | ) { |
72 | addRequest(itemService.dayPracticeList(pos_id, page, pageNum), liveData) | 69 | addRequest(itemService.dayPracticeList(pos_id, page, pageNum), liveData) |
73 | } | 70 | } |
@@ -116,15 +113,6 @@ class ItemRepository(loadState: MutableLiveData<State>) : ApiRepository(loadStat | @@ -116,15 +113,6 @@ class ItemRepository(loadState: MutableLiveData<State>) : ApiRepository(loadStat | ||
116 | addRequest(itemService.subPaper(user_item_id), liveData) | 113 | addRequest(itemService.subPaper(user_item_id), liveData) |
117 | } | 114 | } |
118 | 115 | ||
119 | - //错题列表 | ||
120 | - fun errorList( | ||
121 | - type: Int, | ||
122 | - page: Int, | ||
123 | - page_num: Int, | ||
124 | - liveData: MutableLiveData<BaseResponse<CommonList<ErrorListItem>>> | ||
125 | - ) { | ||
126 | - addRequest(itemService.errorList(type, page, page_num), liveData) | ||
127 | - } | ||
128 | 116 | ||
129 | //错题详情 | 117 | //错题详情 |
130 | fun errorDetail(id: Int, liveData: MutableLiveData<BaseResponse<ErrorDetail>>) { | 118 | fun errorDetail(id: Int, liveData: MutableLiveData<BaseResponse<ErrorDetail>>) { |
@@ -140,34 +128,22 @@ class ItemRepository(loadState: MutableLiveData<State>) : ApiRepository(loadStat | @@ -140,34 +128,22 @@ class ItemRepository(loadState: MutableLiveData<State>) : ApiRepository(loadStat | ||
140 | addRequest(itemService.subError(error_id, answer), liveData) | 128 | addRequest(itemService.subError(error_id, answer), liveData) |
141 | } | 129 | } |
142 | 130 | ||
143 | - //删除错题 | ||
144 | - fun delError( | ||
145 | - item_id: Int, | ||
146 | - type: Int, | ||
147 | - item_type: Int, | ||
148 | - liveData: MutableLiveData<BaseResponse<Void>> | ||
149 | - ) { | ||
150 | - addRequest(itemService.delError(item_id, type, item_type), liveData) | ||
151 | - } | ||
152 | - | ||
153 | - //答题记录 | ||
154 | - fun errorSubList( | ||
155 | - type: Int, | ||
156 | - page: Int, | ||
157 | - page_num: Int, | ||
158 | - liveData: MutableLiveData<BaseResponse<CommonList<AnswerRecord>>> | ||
159 | - ) { | ||
160 | - addRequest(itemService.errorSubList(type, page, page_num), liveData) | ||
161 | - } | 131 | +// //答题记录 |
132 | +// fun errorSubList( | ||
133 | +// type: Int, | ||
134 | +// page: Int, | ||
135 | +// page_num: Int, | ||
136 | +// liveData: MutableLiveData<BaseResponse<CommonList<AnswerRecord>>> | ||
137 | +// ) { | ||
138 | +// addRequest(itemService.errorSubList(type, page, page_num), liveData) | ||
139 | +// } | ||
162 | 140 | ||
163 | //答题记录详情 | 141 | //答题记录详情 |
164 | fun errorSubDetail( | 142 | fun errorSubDetail( |
165 | id: Int, | 143 | id: Int, |
166 | - page: Int, | ||
167 | - page_num: Int, | ||
168 | liveData: MutableLiveData<BaseResponse<CommonList<AnswerDetail>>> | 144 | liveData: MutableLiveData<BaseResponse<CommonList<AnswerDetail>>> |
169 | ) { | 145 | ) { |
170 | - addRequest(itemService.errorSubDetail(id, page, page_num), liveData) | 146 | + addRequest(itemService.errorSubDetail(id), liveData) |
171 | } | 147 | } |
172 | 148 | ||
173 | /** | 149 | /** |
@@ -84,6 +84,7 @@ abstract class BaseAdapter<T, VB : ViewBinding> : | @@ -84,6 +84,7 @@ abstract class BaseAdapter<T, VB : ViewBinding> : | ||
84 | notifyItemChanged(oldPosition, list.size) | 84 | notifyItemChanged(oldPosition, list.size) |
85 | } | 85 | } |
86 | 86 | ||
87 | + | ||
87 | fun addListAndPosition(t: List<T>, position: Int) { | 88 | fun addListAndPosition(t: List<T>, position: Int) { |
88 | list.addAll(position, t) | 89 | list.addAll(position, t) |
89 | notifyItemChanged(position, list.size) | 90 | notifyItemChanged(position, list.size) |
@@ -3,6 +3,7 @@ package com.br_technology.securitytrain_master.ui.bean | @@ -3,6 +3,7 @@ package com.br_technology.securitytrain_master.ui.bean | ||
3 | import com.br_technology.securitytrain_master.ui.view.bank.bean.OptionArr | 3 | import com.br_technology.securitytrain_master.ui.view.bank.bean.OptionArr |
4 | import com.br_technology.securitytrain_master.ui.view.bank.bean.PracticeBean | 4 | import com.br_technology.securitytrain_master.ui.view.bank.bean.PracticeBean |
5 | import com.br_technology.securitytrain_master.base.network.response.CommonDetail | 5 | import com.br_technology.securitytrain_master.base.network.response.CommonDetail |
6 | +import com.br_technology.securitytrain_master.ui.view.bank.bean.TestSubject | ||
6 | 7 | ||
7 | /** | 8 | /** |
8 | * Author by YSir | 9 | * Author by YSir |
@@ -94,7 +95,7 @@ open class ErrorListItem( | @@ -94,7 +95,7 @@ open class ErrorListItem( | ||
94 | //错题详情 | 95 | //错题详情 |
95 | open class ErrorDetail( | 96 | open class ErrorDetail( |
96 | var error_id: String, | 97 | var error_id: String, |
97 | - var detail: CommonDetail<ErrorDetailData> | 98 | + var detail: TestSubject |
98 | ) | 99 | ) |
99 | 100 | ||
100 | open class ErrorDetailData( | 101 | open class ErrorDetailData( |
@@ -129,14 +130,11 @@ open class AnswerRecord( | @@ -129,14 +130,11 @@ open class AnswerRecord( | ||
129 | 130 | ||
130 | //答题记录详情 | 131 | //答题记录详情 |
131 | open class AnswerDetail( | 132 | open class AnswerDetail( |
132 | - var type: String, | ||
133 | - var item_id: Int, | ||
134 | - var answer: String, | ||
135 | - var is_correct: String, | ||
136 | - var item: AnswerDetailItem | 133 | + val type: String, |
134 | + val item_id: Int, | ||
135 | + val answer: String, | ||
136 | + val is_correct: String, | ||
137 | + val item: TestSubject, | ||
138 | + val paperitem: TestSubject, | ||
137 | ) | 139 | ) |
138 | 140 | ||
139 | -open class AnswerDetailItem( | ||
140 | - var title: String, | ||
141 | - var options: String | ||
142 | -) |
@@ -12,6 +12,7 @@ open class TestSubject( | @@ -12,6 +12,7 @@ open class TestSubject( | ||
12 | var paper_id: Int, | 12 | var paper_id: Int, |
13 | var item_id: Int, | 13 | var item_id: Int, |
14 | var title: String, | 14 | var title: String, |
15 | + var options: String, | ||
15 | var type: String, | 16 | var type: String, |
16 | var difficulty: String, | 17 | var difficulty: String, |
17 | var correct: String, | 18 | var correct: String, |
@@ -75,3 +76,4 @@ data class StartItemBean( | @@ -75,3 +76,4 @@ data class StartItemBean( | ||
75 | val user_item_id: String, | 76 | val user_item_id: String, |
76 | var list: List<TestSubject> | 77 | var list: List<TestSubject> |
77 | ) | 78 | ) |
79 | + |
1 | +package com.br_technology.securitytrain_master.ui.view.bank.activity | ||
2 | + | ||
3 | +import android.app.Activity | ||
4 | +import android.content.ClipData | ||
5 | +import android.content.Intent | ||
6 | +import android.view.View | ||
7 | +import androidx.activity.result.contract.ActivityResultContracts | ||
8 | +import androidx.core.content.ContextCompat | ||
9 | +import com.br_technology.securitytrain_master.R | ||
10 | +import com.br_technology.securitytrain_master.databinding.ActivityAnswerRecordDetailsBinding | ||
11 | +import com.br_technology.securitytrain_master.ui.view.bank.adapter.AnswerRecordDetailsAdapter | ||
12 | +import com.br_technology.securitytrain_master.ui.view.bank.bean.OptionArr | ||
13 | +import com.br_technology.securitytrain_master.ui.view.bank.bean.TestSubject | ||
14 | +import com.br_technology.securitytrain_master.ui.view.bank.viewmodel.PracticeViewModel | ||
15 | +import com.br_technology.securitytrain_master.view.listener.ToolBarClickListener | ||
16 | +import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleActivity | ||
17 | + | ||
18 | +/** | ||
19 | + * auth: 张继 | ||
20 | + * date: 2022/1/24 13:54 | ||
21 | + * dsc:答题记录详情 | ||
22 | + * updateInfo: | ||
23 | + */ | ||
24 | +class AnswerRecordDetailsActivity : | ||
25 | + BaseLifeCycleActivity<PracticeViewModel, ActivityAnswerRecordDetailsBinding>( | ||
26 | + ActivityAnswerRecordDetailsBinding::inflate | ||
27 | + ) { | ||
28 | + | ||
29 | + private val mPagerAdapter = AnswerRecordDetailsAdapter() | ||
30 | + | ||
31 | + private val startForResult = | ||
32 | + registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result -> | ||
33 | + if (result.resultCode == Activity.RESULT_OK) { | ||
34 | + //页面返回值 | ||
35 | + val data = result.data?.getIntExtra("position", 0) | ||
36 | + if (data != null) { | ||
37 | + binding.previous.visibility = View.VISIBLE | ||
38 | + binding.next.visibility = View.VISIBLE | ||
39 | + if (data == 0) { | ||
40 | + binding.previous.visibility = View.GONE | ||
41 | + binding.next.visibility = View.VISIBLE | ||
42 | + } | ||
43 | + if (data == mPagerAdapter.itemCount - 1) { | ||
44 | + binding.previous.visibility = View.VISIBLE | ||
45 | + binding.next.visibility = View.GONE | ||
46 | + } | ||
47 | + if (data in 0 until mPagerAdapter.itemCount) { | ||
48 | + binding.practicePager.currentItem = data | ||
49 | + } | ||
50 | + } | ||
51 | + } | ||
52 | + } | ||
53 | + | ||
54 | + override fun initDataObserver() { | ||
55 | + mViewModel.errorSubDetailLiveData.observe(this) { | ||
56 | + mPagerAdapter.showCorrect = true | ||
57 | + mPagerAdapter.addList(it.data.list) | ||
58 | + } | ||
59 | + } | ||
60 | + | ||
61 | + override fun initData() { | ||
62 | + super.initData() | ||
63 | + val id = intent.getIntExtra("id", 0) | ||
64 | + mViewModel.errorSubDetail(id) | ||
65 | + binding.apply { | ||
66 | + toolBar.setRightText("答题卡") | ||
67 | + toolBar.setRightTextDrawable( | ||
68 | + ContextCompat.getDrawable( | ||
69 | + baseContext, | ||
70 | + R.mipmap.answer_sheet | ||
71 | + ) | ||
72 | + ) | ||
73 | + // 答题卡点击事件 | ||
74 | + toolBar.addRightListener(object : ToolBarClickListener { | ||
75 | + override fun onClick(view: View) { | ||
76 | + val intent = Intent(baseContext, AnswerSheetActivity::class.java) | ||
77 | + .putStringArrayListExtra("resultData", mPagerAdapter.getArrayList()) | ||
78 | + startForResult.launch(intent) | ||
79 | + } | ||
80 | + }) | ||
81 | + // 隐藏交卷 | ||
82 | + finishJob.visibility = View.GONE | ||
83 | + practicePager.isUserInputEnabled = false | ||
84 | + // 设置适配器 | ||
85 | + practicePager.adapter = mPagerAdapter | ||
86 | + // 上一题 | ||
87 | + previous.setOnClickListener { | ||
88 | + val index = practicePager.currentItem | ||
89 | + if (index >= 1) { | ||
90 | + practicePager.currentItem = index - 1 | ||
91 | + } | ||
92 | + next.visibility = View.VISIBLE | ||
93 | + if (index == 1) { | ||
94 | + previous.visibility = View.GONE | ||
95 | + } | ||
96 | + } | ||
97 | + // 下一题 | ||
98 | + next.setOnClickListener { | ||
99 | + val index = binding.practicePager.currentItem | ||
100 | + if (index < mPagerAdapter.itemCount - 1) { | ||
101 | + binding.practicePager.currentItem = index + 1 | ||
102 | + } | ||
103 | + binding.previous.visibility = View.VISIBLE | ||
104 | + if (index == mPagerAdapter.itemCount - 2) { | ||
105 | + binding.next.visibility = View.GONE | ||
106 | + | ||
107 | + } | ||
108 | + } | ||
109 | + } | ||
110 | + } | ||
111 | +} |
1 | +package com.br_technology.securitytrain_master.ui.view.bank.activity | ||
2 | + | ||
3 | +import com.br_technology.securitytrain_master.databinding.ActivityWrongQuestionsBinding | ||
4 | +import com.br_technology.securitytrain_master.ui.view.bank.adapter.PracticePaperAdapter | ||
5 | +import com.br_technology.securitytrain_master.ui.view.bank.viewmodel.PracticeViewModel | ||
6 | +import com.br_technology.securitytrain_master.ui.view.mine.fragment.MyErrorQuestionFragment | ||
7 | +import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleActivity | ||
8 | +import kotlin.properties.Delegates | ||
9 | + | ||
10 | +/** | ||
11 | + * auth: 张继 | ||
12 | + * date: 2022/1/24 18:29 | ||
13 | + * dsc:错题列表继续答题 | ||
14 | + * updateInfo: | ||
15 | + */ | ||
16 | +class WrongQuestionsActivity : | ||
17 | + BaseLifeCycleActivity<PracticeViewModel, ActivityWrongQuestionsBinding>( | ||
18 | + ActivityWrongQuestionsBinding::inflate | ||
19 | + ) { | ||
20 | + private var itemId: Int = 0 | ||
21 | + private var type by Delegates.notNull<Int>() | ||
22 | + private val adapter by lazy { | ||
23 | + PracticePaperAdapter() | ||
24 | + } | ||
25 | + | ||
26 | + override fun initDataObserver() { | ||
27 | + mViewModel.errorDetail.observe(this) { | ||
28 | + itemId = it.data.error_id.toInt() | ||
29 | + adapter.addData(it.data.detail) | ||
30 | + } | ||
31 | + mViewModel.subErrorLiveData.observe(this) { | ||
32 | + showTip("提交成功") | ||
33 | + adapter.showCorrect = true | ||
34 | + adapter.notifyDataSetChanged() | ||
35 | + } | ||
36 | + } | ||
37 | + | ||
38 | + override fun initData() { | ||
39 | + super.initData() | ||
40 | + val id = intent.getIntExtra("id", 0) | ||
41 | + type = intent.getIntExtra("type", 1) | ||
42 | + MyErrorQuestionFragment.map[type] = true | ||
43 | + mViewModel.errorDetail(id) | ||
44 | + binding.apply { | ||
45 | + errorPager.isUserInputEnabled = false | ||
46 | + errorPager.adapter = adapter | ||
47 | + // 交卷 | ||
48 | + finishJob.setOnClickListener { | ||
49 | + finishJob.isClickable = false | ||
50 | + mViewModel.subError(itemId, adapter.getAnswer()[0].answer) | ||
51 | + } | ||
52 | + } | ||
53 | + } | ||
54 | +} |
1 | +package com.br_technology.securitytrain_master.ui.view.bank.adapter | ||
2 | + | ||
3 | +import android.annotation.SuppressLint | ||
4 | +import android.app.Activity | ||
5 | +import android.content.Context | ||
6 | +import android.graphics.Color | ||
7 | +import android.text.SpannableString | ||
8 | +import android.text.Spanned | ||
9 | +import android.text.style.AbsoluteSizeSpan | ||
10 | +import android.text.style.ForegroundColorSpan | ||
11 | +import android.view.LayoutInflater | ||
12 | +import android.view.View | ||
13 | +import android.view.ViewGroup | ||
14 | +import android.widget.TextView | ||
15 | +import androidx.core.content.ContextCompat | ||
16 | +import com.br_technology.securitytrain_master.R | ||
17 | +import com.br_technology.securitytrain_master.base.common.ConstantType | ||
18 | +import com.br_technology.securitytrain_master.base.view.BaseAdapter | ||
19 | +import com.br_technology.securitytrain_master.base.view.BaseViewHolder | ||
20 | +import com.br_technology.securitytrain_master.databinding.AdapterContentPracticeItemBinding | ||
21 | +import com.br_technology.securitytrain_master.databinding.AdapterTopicBinding | ||
22 | +import com.br_technology.securitytrain_master.expand.dp2px | ||
23 | +import com.br_technology.securitytrain_master.ui.bean.Answer | ||
24 | +import com.br_technology.securitytrain_master.ui.bean.AnswerDetail | ||
25 | +import com.br_technology.securitytrain_master.ui.bean.AnswerRecord | ||
26 | +import com.br_technology.securitytrain_master.ui.view.bank.bean.OptionArr | ||
27 | +import com.br_technology.securitytrain_master.ui.view.bank.bean.TestSubject | ||
28 | +import com.br_technology.securitytrain_master.util.GlideEnginePic | ||
29 | +import com.br_technology.securitytrain_master.view.listener.OnItemClickListener | ||
30 | +import com.br_technology.securitytrain_master.view.listener.OnItemListener | ||
31 | +import com.luck.picture.lib.PictureSelector | ||
32 | +import com.luck.picture.lib.entity.LocalMedia | ||
33 | + | ||
34 | +/** | ||
35 | + * auth: 张继 | ||
36 | + * date: 2022/1/24 16:21 | ||
37 | + * dsc: | ||
38 | + * updateInfo: | ||
39 | + */ | ||
40 | + | ||
41 | + | ||
42 | +class AnswerRecordDetailsItemAdapter : BaseAdapter<OptionArr, AdapterTopicBinding>() { | ||
43 | + // 题目类型 1:单选 2:多选 3:判断 | ||
44 | + var type = 1 | ||
45 | + | ||
46 | + // 是否显示正确答案 | ||
47 | + var showCorrect = false | ||
48 | + | ||
49 | + // 选中选项 | ||
50 | + var mSelectIndex = mutableListOf<Int>() | ||
51 | + | ||
52 | + var mListener: OnItemListener? = null | ||
53 | + | ||
54 | + override fun getViewBinding( | ||
55 | + context: Context, | ||
56 | + parent: ViewGroup, | ||
57 | + viewType: Int, | ||
58 | + from: LayoutInflater | ||
59 | + ): AdapterTopicBinding { | ||
60 | + return AdapterTopicBinding.inflate(from, parent, false) | ||
61 | + } | ||
62 | + | ||
63 | + /** | ||
64 | + * 选中处理 | ||
65 | + */ | ||
66 | + fun itemClick(position: Int) { | ||
67 | + if (!mSelectIndex.contains(position)) { | ||
68 | + mSelectIndex.add(position) | ||
69 | + } else { | ||
70 | + mSelectIndex.remove(position) | ||
71 | + } | ||
72 | + notifyDataSetChanged() | ||
73 | + } | ||
74 | + | ||
75 | + fun setItemClickListener(listener: OnItemListener) { | ||
76 | + this.mListener = listener | ||
77 | + } | ||
78 | + | ||
79 | + /** | ||
80 | + * 是否为选中 | ||
81 | + */ | ||
82 | + fun isSelected(position: Int): Boolean { | ||
83 | + return mSelectIndex.contains(position) | ||
84 | + } | ||
85 | + | ||
86 | + override fun onBindViewHolder(holder: BaseViewHolder<AdapterTopicBinding>, position: Int) { | ||
87 | + super.onBindViewHolder(holder, position) | ||
88 | + holder.itemView.isEnabled = !showCorrect | ||
89 | + holder.itemView.setOnClickListener { | ||
90 | + mListener?.onItemClick(position) | ||
91 | + } | ||
92 | + } | ||
93 | + | ||
94 | + @SuppressLint("SetTextI18n") | ||
95 | + override fun onBind(holder: AdapterTopicBinding, position: Int, data: OptionArr) { | ||
96 | + holder.tvName.text = "${data.option_name}.${data.value}" | ||
97 | + | ||
98 | + if (data.pic_arr.isNotEmpty()) { | ||
99 | + val pictureAdapter = PictureAdapter(holder.root.context) | ||
100 | + pictureAdapter.addList(data.pic_arr.toMutableList()) | ||
101 | + holder.ivPic.adapter = pictureAdapter | ||
102 | + holder.ivPic.setOnTouchListener { v, event -> | ||
103 | + holder.contentTopic.onTouchEvent(event) | ||
104 | + false | ||
105 | + } | ||
106 | + pictureAdapter.addListener(object : OnItemClickListener<String> { | ||
107 | + override fun onClick(position: Int, pic: String) { | ||
108 | + previewPhoto(data.pic_arr, holder.root.context, position) | ||
109 | + } | ||
110 | + }) | ||
111 | + } | ||
112 | + | ||
113 | + setTextDefault(holder.contentTopic, holder.tvName) | ||
114 | + // 单选 / 判断 | ||
115 | + if (type == 1 || type == 3) { | ||
116 | + if (mSelectIndex.isNotEmpty() && mSelectIndex[0] == position) { | ||
117 | + if (showCorrect) { | ||
118 | + if (data.is_correct == 1) { | ||
119 | + setTextGreen(holder.contentTopic, holder.tvName) | ||
120 | + } else { | ||
121 | + setTextRed(holder.contentTopic, holder.tvName) | ||
122 | + } | ||
123 | + } else { | ||
124 | + //未交卷时显示 | ||
125 | + setTextGreen(holder.contentTopic, holder.tvName) | ||
126 | + } | ||
127 | + } else { | ||
128 | + if (showCorrect && data.is_correct == 1) { | ||
129 | + // 正确答背景应变绿色--需求修改成当有错题时正确答案背景色没变化 | ||
130 | +// setTextGreen(holder.contentTopic, holder.tvName) | ||
131 | + } | ||
132 | + } | ||
133 | + } | ||
134 | + // 多选 | ||
135 | + if (type == 2) { | ||
136 | + if (isSelected(position)) { | ||
137 | + if (showCorrect) { | ||
138 | + if (data.is_correct == 1) { | ||
139 | + setTextGreen(holder.contentTopic, holder.tvName) | ||
140 | + } else { | ||
141 | + setTextRed(holder.contentTopic, holder.tvName) | ||
142 | + } | ||
143 | + } else { | ||
144 | + setTextGreen(holder.contentTopic, holder.tvName) | ||
145 | + } | ||
146 | + } else { | ||
147 | + if (showCorrect && data.is_correct == 1) { | ||
148 | + // 正确答背景应变绿色--需求修改成当有错题时正确答案背景色没变化 | ||
149 | +// setTextGreen(holder.contentTopic, holder.tvName) | ||
150 | + } | ||
151 | + } | ||
152 | + } | ||
153 | + } | ||
154 | + | ||
155 | + private fun setTextDefault(view: View, textView: TextView) { | ||
156 | + view.setBackgroundResource(R.drawable.stroke_eb_4) | ||
157 | + textView.setTextColor(ContextCompat.getColor(textView.context, R.color.color_32)) | ||
158 | + } | ||
159 | + | ||
160 | + private fun setTextRed(view: View, textView: TextView) { | ||
161 | + view.setBackgroundResource(R.drawable.topic_back_error) | ||
162 | + textView.setTextColor(ContextCompat.getColor(textView.context, R.color.color_e9)) | ||
163 | + } | ||
164 | + | ||
165 | + private fun setTextGreen(view: View, textView: TextView) { | ||
166 | + view.setBackgroundResource(R.drawable.solid_0825_4) | ||
167 | + textView.setTextColor(ContextCompat.getColor(textView.context, R.color.color_25)) | ||
168 | + } | ||
169 | + | ||
170 | + private fun previewPhoto(data: Array<String>, context: Context, position: Int) { | ||
171 | + val list = mutableListOf<LocalMedia>() | ||
172 | + data.forEach { | ||
173 | + val localMedia = LocalMedia() | ||
174 | + localMedia.path = it | ||
175 | + list.add(localMedia) | ||
176 | + } | ||
177 | + PictureSelector.create(context as Activity) | ||
178 | + .themeStyle(R.style.picture_default_style) | ||
179 | + .imageEngine(GlideEnginePic.createGlideEngine()) | ||
180 | + .openExternalPreview(position, list) | ||
181 | + } | ||
182 | + | ||
183 | +} | ||
184 | + | ||
185 | +class AnswerRecordDetailsAdapter(private val isShowPosition: Boolean = true) : | ||
186 | + BaseAdapter<AnswerDetail, AdapterContentPracticeItemBinding>() { | ||
187 | + // 是否显示正确答案 | ||
188 | + var showCorrect = false | ||
189 | + var selectResultData = HashMap<Int, List<Int>>() | ||
190 | + | ||
191 | + override fun getViewBinding( | ||
192 | + context: Context, | ||
193 | + parent: ViewGroup, | ||
194 | + viewType: Int, | ||
195 | + from: LayoutInflater | ||
196 | + ): AdapterContentPracticeItemBinding { | ||
197 | + return AdapterContentPracticeItemBinding.inflate(from, parent, false) | ||
198 | + } | ||
199 | + | ||
200 | + @SuppressLint("SetTextI18n") | ||
201 | + override fun onBind( | ||
202 | + holder: AdapterContentPracticeItemBinding, | ||
203 | + index: Int, | ||
204 | + data: AnswerDetail | ||
205 | + ) { | ||
206 | + | ||
207 | + val value = if (isShowPosition) { | ||
208 | + "(${index + 1}/${itemCount})${data.item.title}${ConstantType.getType(data.type)}" | ||
209 | + } else { | ||
210 | + "${data.item.title}${ConstantType.getType(data.type)}" | ||
211 | + } | ||
212 | + val span = SpannableString(value) | ||
213 | + | ||
214 | + span.setSpan( | ||
215 | + ForegroundColorSpan(Color.parseColor("#C8C9CC")), | ||
216 | + value.length - 4, | ||
217 | + value.length, | ||
218 | + Spanned.SPAN_EXCLUSIVE_EXCLUSIVE | ||
219 | + ) | ||
220 | + span.setSpan( | ||
221 | + AbsoluteSizeSpan(14.dp2px()), | ||
222 | + value.length - 4, | ||
223 | + value.length, | ||
224 | + Spanned.SPAN_EXCLUSIVE_EXCLUSIVE | ||
225 | + ) | ||
226 | + | ||
227 | + holder.topic.text = span | ||
228 | + val adapterChild = AnswerRecordDetailsItemAdapter() | ||
229 | + adapterChild.addList(data.item.options_arr) | ||
230 | + holder.topicRecycler.adapter = adapterChild | ||
231 | + holder.txtCorrect.text = "正确答案:${data.item.correct}" | ||
232 | + holder.txtAnalysis.text = "解析:${data.item.remark}" | ||
233 | + holder.contentAnalysis.visibility = if (showCorrect) View.VISIBLE else View.GONE | ||
234 | + adapterChild.let { | ||
235 | + val type = data.type.toInt() | ||
236 | + it.type = type | ||
237 | + it.showCorrect = showCorrect | ||
238 | + | ||
239 | + if (type == 1 || type == 3) { | ||
240 | + for (position in data.item.options_arr.indices) { | ||
241 | + if (data.item.options_arr[position].option_name == data.answer) { | ||
242 | + it.itemClick(position) | ||
243 | + break | ||
244 | + } | ||
245 | + } | ||
246 | + } else { | ||
247 | + for (position in data.item.options_arr.indices) { | ||
248 | + val split = data.answer.split(",") | ||
249 | + for (j in split.indices) { | ||
250 | + if (data.item.options_arr[position].option_name == split[j]) { | ||
251 | + it.itemClick(index) | ||
252 | + break | ||
253 | + } | ||
254 | + } | ||
255 | + } | ||
256 | + } | ||
257 | + | ||
258 | + if (selectResultData.containsKey(index)) { | ||
259 | + selectResultData[index]?.let { data -> | ||
260 | + if (data.isNotEmpty()) { | ||
261 | + it.mSelectIndex = data as MutableList<Int> | ||
262 | + } | ||
263 | + } | ||
264 | + } | ||
265 | + it.setItemClickListener(object : OnItemListener { | ||
266 | + override fun onItemClick(position: Int) { | ||
267 | + if (type == 1 || type == 3) { | ||
268 | + if (it.mSelectIndex.isEmpty()) { | ||
269 | + it.mSelectIndex.add(position) | ||
270 | + } else { | ||
271 | + it.mSelectIndex[0] = position | ||
272 | + } | ||
273 | + it.notifyDataSetChanged() | ||
274 | + } else { | ||
275 | + it.itemClick(position) | ||
276 | + } | ||
277 | + selectResultData[index] = it.mSelectIndex | ||
278 | + } | ||
279 | + }) | ||
280 | + } | ||
281 | + } | ||
282 | + | ||
283 | + | ||
284 | + override fun addList(t: List<AnswerDetail>) { | ||
285 | + super.addList(t) | ||
286 | + for (data in getData()) { | ||
287 | + val index = getData().indexOf(data) | ||
288 | + selectResultData[index] = listOf() | ||
289 | + val selectIndex = mutableListOf<Int>() | ||
290 | + | ||
291 | + if (data.type == "1" || data.type == "3") { | ||
292 | + for (position in data.item.options_arr.indices) { | ||
293 | + if (data.item.options_arr[position].option_name == data.answer) { | ||
294 | + selectIndex.add(position) | ||
295 | + selectResultData[index] = selectIndex | ||
296 | + break | ||
297 | + } | ||
298 | + } | ||
299 | + } else { | ||
300 | + for (position in data.item.options_arr.indices) { | ||
301 | + val split = data.answer.split(",") | ||
302 | + for (j in split.indices) { | ||
303 | + if (data.item.options_arr[position].option_name == split[j]) { | ||
304 | + selectIndex.add(position) | ||
305 | + selectResultData[index] = selectIndex | ||
306 | + break | ||
307 | + } | ||
308 | + } | ||
309 | + } | ||
310 | + } | ||
311 | + } | ||
312 | + } | ||
313 | + | ||
314 | + private fun getResultData(): ArrayList<List<Int>> { | ||
315 | + val data = ArrayList<List<Int>>() | ||
316 | + val result = selectResultData.keys | ||
317 | + val dataKey = mutableListOf<Int>() | ||
318 | + for (item in result) { | ||
319 | + dataKey.add(item) | ||
320 | + } | ||
321 | + dataKey.sort() | ||
322 | + for (index in dataKey) { | ||
323 | + selectResultData[index]?.let { | ||
324 | + data.add(it) | ||
325 | + } | ||
326 | + } | ||
327 | + return data | ||
328 | + } | ||
329 | + | ||
330 | + fun getAnswer(): ArrayList<Answer> { | ||
331 | + val data = ArrayList<Answer>() | ||
332 | + val list = getResultData() | ||
333 | + val listSubject = getData() | ||
334 | + for (res in list.indices) { | ||
335 | + val pos = list[res] | ||
336 | + val ppp = listSubject[res] | ||
337 | + data.add(Answer(ppp.item_id, getAnswer(ppp.item.options_arr, pos))) | ||
338 | + } | ||
339 | + return data | ||
340 | + } | ||
341 | + | ||
342 | + fun getAnswer(optionArr: List<OptionArr>, data: List<Int>): String { | ||
343 | + var str = "" | ||
344 | + if (data.isNotEmpty()) { | ||
345 | + for (res in data) { | ||
346 | + if (res < optionArr.size) { | ||
347 | + str = str + optionArr[res].option_name + "," | ||
348 | + } | ||
349 | + } | ||
350 | + } | ||
351 | + return str.substringBeforeLast(","); | ||
352 | + } | ||
353 | + | ||
354 | + fun getCount(): Int { | ||
355 | + var count = 0 | ||
356 | + for (data in selectResultData) { | ||
357 | + if (data.value.isNotEmpty()) { | ||
358 | + count++ | ||
359 | + } | ||
360 | + } | ||
361 | + return count | ||
362 | + } | ||
363 | + | ||
364 | + fun getArrayList(): ArrayList<String> { | ||
365 | + val list = ArrayList<String>() | ||
366 | + val dataList = getResultData() | ||
367 | + for (data in getData()) { | ||
368 | + val position = getData().indexOf(data) | ||
369 | + if (dataList[position].isEmpty()) { | ||
370 | + list.add("") | ||
371 | + } else { | ||
372 | + val element = if (isTrue(data, dataList[position], data.item.options_arr) | ||
373 | + ) "1" else "0" | ||
374 | + list.add(element) | ||
375 | + } | ||
376 | + } | ||
377 | + return list | ||
378 | + } | ||
379 | + | ||
380 | + private fun isTrue( | ||
381 | + testSubject: AnswerDetail, | ||
382 | + mSelectIndex: List<Int>, | ||
383 | + optionArr: List<OptionArr> | ||
384 | + ): Boolean { | ||
385 | + var bool = false | ||
386 | + val type = testSubject.type.toInt() | ||
387 | + if (type == 1 || type == 3) { | ||
388 | + bool = if (mSelectIndex.isNotEmpty()) { | ||
389 | + optionArr[mSelectIndex[0]].is_correct == 1 | ||
390 | + } else { | ||
391 | + false | ||
392 | + } | ||
393 | + } | ||
394 | + if (type == 2) { | ||
395 | + var count = 0 | ||
396 | + var dataCount = 0 | ||
397 | + for (item in optionArr) { | ||
398 | + val position = optionArr.indexOf(item) | ||
399 | + if (item.is_correct == 1) { | ||
400 | + if (mSelectIndex.contains(position)) { | ||
401 | + count++ | ||
402 | + } | ||
403 | + dataCount++; | ||
404 | + } | ||
405 | + } | ||
406 | + bool = count == dataCount && mSelectIndex.size == count | ||
407 | + } | ||
408 | + return bool | ||
409 | + } | ||
410 | + | ||
411 | +} | ||
412 | + |
@@ -44,9 +44,6 @@ class TopicAdapter : BaseAdapter<OptionArr, AdapterTopicBinding>() { | @@ -44,9 +44,6 @@ class TopicAdapter : BaseAdapter<OptionArr, AdapterTopicBinding>() { | ||
44 | // 题目类型 1:单选 2:多选 3:判断 | 44 | // 题目类型 1:单选 2:多选 3:判断 |
45 | var type = 1 | 45 | var type = 1 |
46 | 46 | ||
47 | - // 是否时正确的答题 | ||
48 | - var isTrue: Boolean = true | ||
49 | - | ||
50 | // 是否显示正确答案 | 47 | // 是否显示正确答案 |
51 | var showCorrect = false | 48 | var showCorrect = false |
52 | 49 | ||
@@ -114,7 +111,6 @@ class TopicAdapter : BaseAdapter<OptionArr, AdapterTopicBinding>() { | @@ -114,7 +111,6 @@ class TopicAdapter : BaseAdapter<OptionArr, AdapterTopicBinding>() { | ||
114 | }) | 111 | }) |
115 | } | 112 | } |
116 | 113 | ||
117 | - | ||
118 | setTextDefault(holder.contentTopic, holder.tvName) | 114 | setTextDefault(holder.contentTopic, holder.tvName) |
119 | // 单选 / 判断 | 115 | // 单选 / 判断 |
120 | if (type == 1 || type == 3) { | 116 | if (type == 1 || type == 3) { |
@@ -185,7 +181,6 @@ class TopicAdapter : BaseAdapter<OptionArr, AdapterTopicBinding>() { | @@ -185,7 +181,6 @@ class TopicAdapter : BaseAdapter<OptionArr, AdapterTopicBinding>() { | ||
185 | .openExternalPreview(position, list) | 181 | .openExternalPreview(position, list) |
186 | } | 182 | } |
187 | 183 | ||
188 | - | ||
189 | } | 184 | } |
190 | 185 | ||
191 | class PracticePaperAdapter(private val isShowPosition: Boolean = true) : | 186 | class PracticePaperAdapter(private val isShowPosition: Boolean = true) : |
app/src/main/java/com/br_technology/securitytrain_master/ui/view/bank/viewmodel/MockExamViewModel.kt
@@ -3,7 +3,7 @@ package com.br_technology.securitytrain_master.ui.view.bank.viewmodel | @@ -3,7 +3,7 @@ package com.br_technology.securitytrain_master.ui.view.bank.viewmodel | ||
3 | import androidx.lifecycle.MutableLiveData | 3 | import androidx.lifecycle.MutableLiveData |
4 | import com.br_technology.securitytrain_master.base.repository.ItemRepository | 4 | import com.br_technology.securitytrain_master.base.repository.ItemRepository |
5 | import com.br_technology.securitytrain_master.base.network.response.BaseResponse | 5 | import com.br_technology.securitytrain_master.base.network.response.BaseResponse |
6 | -import com.br_technology.securitytrain_master.base.network.response.CommonDetailList | 6 | +import com.br_technology.securitytrain_master.base.network.response.CommonDataList |
7 | import com.br_technology.securitytrain_master.base.network.response.CommonList | 7 | import com.br_technology.securitytrain_master.base.network.response.CommonList |
8 | import com.br_technology.securitytrain_master.base.view.BaseViewModel | 8 | import com.br_technology.securitytrain_master.base.view.BaseViewModel |
9 | import com.br_technology.securitytrain_master.ui.bean.PaperListDetail | 9 | import com.br_technology.securitytrain_master.ui.bean.PaperListDetail |
@@ -17,7 +17,7 @@ import com.br_technology.securitytrain_master.util.sp_job_id | @@ -17,7 +17,7 @@ import com.br_technology.securitytrain_master.util.sp_job_id | ||
17 | */ | 17 | */ |
18 | class MockExamViewModel : BaseViewModel<ItemRepository>() { | 18 | class MockExamViewModel : BaseViewModel<ItemRepository>() { |
19 | val liveData: MutableLiveData<BaseResponse<CommonList<PracticeBean>>> = MutableLiveData() | 19 | val liveData: MutableLiveData<BaseResponse<CommonList<PracticeBean>>> = MutableLiveData() |
20 | - val paperDetailLiveData: MutableLiveData<BaseResponse<CommonDetailList<PaperListDetail>>> = | 20 | + val paperDetailLiveData: MutableLiveData<BaseResponse<CommonDataList<PaperListDetail>>> = |
21 | MutableLiveData() | 21 | MutableLiveData() |
22 | 22 | ||
23 | fun specialPracticeList( | 23 | fun specialPracticeList( |
app/src/main/java/com/br_technology/securitytrain_master/ui/view/bank/viewmodel/PracticeViewModel.kt
@@ -30,10 +30,20 @@ class PracticeViewModel : BaseViewModel<ItemRepository>() { | @@ -30,10 +30,20 @@ class PracticeViewModel : BaseViewModel<ItemRepository>() { | ||
30 | val subSingleData: MutableLiveData<BaseResponse<SubSingle>> = MutableLiveData() | 30 | val subSingleData: MutableLiveData<BaseResponse<SubSingle>> = MutableLiveData() |
31 | 31 | ||
32 | // 每日一练列表数据 | 32 | // 每日一练列表数据 |
33 | - val dayPracticeLiveData: MutableLiveData<BaseResponse<CommonDetailList<CommonPage<PaperDaily>>>> = | 33 | + val dayPracticeLiveData: MutableLiveData<BaseResponse<CommonDataList<CommonPage<PaperDaily>>>> = |
34 | MutableLiveData() | 34 | MutableLiveData() |
35 | + | ||
35 | // 获取挑战答题弹板信息 | 36 | // 获取挑战答题弹板信息 |
36 | val challengeInfoLiveData: MutableLiveData<BaseResponse<ChallengeInfo>> = MutableLiveData() | 37 | val challengeInfoLiveData: MutableLiveData<BaseResponse<ChallengeInfo>> = MutableLiveData() |
38 | + | ||
39 | + val errorSubDetailLiveData: MutableLiveData<BaseResponse<CommonList<AnswerDetail>>> = | ||
40 | + MutableLiveData() | ||
41 | + | ||
42 | + // 错题详情 | ||
43 | + val errorDetail: MutableLiveData<BaseResponse<ErrorDetail>> = MutableLiveData() | ||
44 | + val subErrorLiveData: MutableLiveData<BaseResponse<Void>> = MutableLiveData() | ||
45 | + | ||
46 | + | ||
37 | fun getTestData(id: String) { | 47 | fun getTestData(id: String) { |
38 | mRepository.getTestSubject(testData, id) | 48 | mRepository.getTestSubject(testData, id) |
39 | } | 49 | } |
@@ -55,6 +65,13 @@ class PracticeViewModel : BaseViewModel<ItemRepository>() { | @@ -55,6 +65,13 @@ class PracticeViewModel : BaseViewModel<ItemRepository>() { | ||
55 | mRepository.subAnswer(itemId, jsonArray, subAnswer) | 65 | mRepository.subAnswer(itemId, jsonArray, subAnswer) |
56 | } | 66 | } |
57 | 67 | ||
68 | + /** | ||
69 | + * 提交错题 | ||
70 | + */ | ||
71 | + fun subError(itemId: Int, answer: String) { | ||
72 | + mRepository.subError(itemId, answer, subErrorLiveData) | ||
73 | + } | ||
74 | + | ||
58 | // 开始答题 | 75 | // 开始答题 |
59 | fun itemStart( | 76 | fun itemStart( |
60 | paper_id: Int?, | 77 | paper_id: Int?, |
@@ -91,4 +108,18 @@ class PracticeViewModel : BaseViewModel<ItemRepository>() { | @@ -91,4 +108,18 @@ class PracticeViewModel : BaseViewModel<ItemRepository>() { | ||
91 | } | 108 | } |
92 | 109 | ||
93 | 110 | ||
111 | + fun errorSubDetail( | ||
112 | + id: Int | ||
113 | + ) { | ||
114 | + mRepository.errorSubDetail(id, errorSubDetailLiveData) | ||
115 | + } | ||
116 | + | ||
117 | + | ||
118 | + fun errorDetail( | ||
119 | + id: Int | ||
120 | + ) { | ||
121 | + mRepository.errorDetail(id, errorDetail) | ||
122 | + } | ||
123 | + | ||
124 | + | ||
94 | } | 125 | } |
@@ -2,7 +2,7 @@ package com.br_technology.securitytrain_master.ui.view.home.viewmodel | @@ -2,7 +2,7 @@ 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.network.response.BaseResponse |
5 | -import com.br_technology.securitytrain_master.base.network.response.CommonDetailList | 5 | +import com.br_technology.securitytrain_master.base.network.response.CommonDataList |
6 | import com.br_technology.securitytrain_master.base.network.response.CommonPage | 6 | import com.br_technology.securitytrain_master.base.network.response.CommonPage |
7 | import com.br_technology.securitytrain_master.base.repository.TrainRepository | 7 | import com.br_technology.securitytrain_master.base.repository.TrainRepository |
8 | import com.br_technology.securitytrain_master.base.view.BaseViewModel | 8 | import com.br_technology.securitytrain_master.base.view.BaseViewModel |
@@ -28,7 +28,7 @@ class CoursePracticeViewModel : BaseViewModel<TrainRepository>() { | @@ -28,7 +28,7 @@ class CoursePracticeViewModel : BaseViewModel<TrainRepository>() { | ||
28 | val subSingleData: MutableLiveData<BaseResponse<SubSingle>> = MutableLiveData() | 28 | val subSingleData: MutableLiveData<BaseResponse<SubSingle>> = MutableLiveData() |
29 | 29 | ||
30 | // 每日一练列表数据 | 30 | // 每日一练列表数据 |
31 | - val dayPracticeLiveData: MutableLiveData<BaseResponse<CommonDetailList<CommonPage<PaperDaily>>>> = | 31 | + val dayPracticeLiveData: MutableLiveData<BaseResponse<CommonDataList<CommonPage<PaperDaily>>>> = |
32 | MutableLiveData() | 32 | MutableLiveData() |
33 | // 获取挑战答题弹板信息 | 33 | // 获取挑战答题弹板信息 |
34 | val challengeInfoLiveData: MutableLiveData<BaseResponse<ChallengeInfo>> = MutableLiveData() | 34 | val challengeInfoLiveData: MutableLiveData<BaseResponse<ChallengeInfo>> = MutableLiveData() |
@@ -35,7 +35,11 @@ class MyErrorQuestionActivity : | @@ -35,7 +35,11 @@ class MyErrorQuestionActivity : | ||
35 | FragmentPagerAdapter.BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT | 35 | FragmentPagerAdapter.BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT |
36 | ) | 36 | ) |
37 | val list = | 37 | val list = |
38 | - mutableListOf(MyErrorQuestionFragment(), MyErrorQuestionFragment(), MyErrorQuestionFragment()) | 38 | + mutableListOf( |
39 | + MyErrorQuestionFragment.newInstance(1), | ||
40 | + MyErrorQuestionFragment.newInstance(2), | ||
41 | + MyErrorQuestionFragment.newInstance(3) | ||
42 | + ) | ||
39 | val titles = listOf("单选题", "判断题", "多选题") | 43 | val titles = listOf("单选题", "判断题", "多选题") |
40 | searchResultAdapter.addData(list.toMutableList()) | 44 | searchResultAdapter.addData(list.toMutableList()) |
41 | searchResultAdapter.addTitle(titles) | 45 | searchResultAdapter.addTitle(titles) |
@@ -29,8 +29,13 @@ class QuestionRecordActivity : | @@ -29,8 +29,13 @@ class QuestionRecordActivity : | ||
29 | FragmentPagerAdapter.BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT | 29 | FragmentPagerAdapter.BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT |
30 | ) | 30 | ) |
31 | val list = | 31 | val list = |
32 | - mutableListOf(SpecialExercisesFragment(), MockExaminationFragment()) | ||
33 | - val titles = listOf("专项练习", "模拟考试") | 32 | + mutableListOf( |
33 | + SpecialExercisesFragment.newInstance(3), | ||
34 | + SpecialExercisesFragment.newInstance(4), | ||
35 | + SpecialExercisesFragment.newInstance(5), | ||
36 | + SpecialExercisesFragment.newInstance(6) | ||
37 | + ) | ||
38 | + val titles = listOf("专项练习", "培训计划考试", "培训计划联系", "模拟考试") | ||
34 | searchResultAdapter.addData(list.toMutableList()) | 39 | searchResultAdapter.addData(list.toMutableList()) |
35 | searchResultAdapter.addTitle(titles) | 40 | searchResultAdapter.addTitle(titles) |
36 | viewPager.adapter = searchResultAdapter | 41 | viewPager.adapter = searchResultAdapter |
@@ -3,27 +3,26 @@ package com.br_technology.securitytrain_master.ui.view.mine.adapter | @@ -3,27 +3,26 @@ package com.br_technology.securitytrain_master.ui.view.mine.adapter | ||
3 | import android.content.Context | 3 | import android.content.Context |
4 | import android.view.LayoutInflater | 4 | import android.view.LayoutInflater |
5 | import android.view.ViewGroup | 5 | import android.view.ViewGroup |
6 | +import com.br_technology.securitytrain_master.R | ||
6 | import com.br_technology.securitytrain_master.base.view.BaseAdapter | 7 | import com.br_technology.securitytrain_master.base.view.BaseAdapter |
7 | import com.br_technology.securitytrain_master.databinding.ItemMyErrorQuestionBinding | 8 | import com.br_technology.securitytrain_master.databinding.ItemMyErrorQuestionBinding |
9 | +import com.br_technology.securitytrain_master.ui.bean.ErrorListItem | ||
8 | import com.br_technology.securitytrain_master.ui.view.home.pojo.VideoCourse | 10 | import com.br_technology.securitytrain_master.ui.view.home.pojo.VideoCourse |
11 | +import com.chad.library.adapter.base.BaseQuickAdapter | ||
12 | +import com.chad.library.adapter.base.viewholder.BaseViewHolder | ||
9 | 13 | ||
10 | /** | 14 | /** |
11 | * Time: 7/31/2021 16:08 | 15 | * Time: 7/31/2021 16:08 |
12 | * Author: Captain | 16 | * Author: Captain |
13 | * Description: 初见时你很迷人 | 17 | * Description: 初见时你很迷人 |
14 | */ | 18 | */ |
15 | -class MyErrorQuestionAdapter : BaseAdapter<VideoCourse, ItemMyErrorQuestionBinding>() { | ||
16 | - override fun getViewBinding( | ||
17 | - context: Context, | ||
18 | - parent: ViewGroup, | ||
19 | - viewType: Int, | ||
20 | - from: LayoutInflater | ||
21 | - ): ItemMyErrorQuestionBinding { | ||
22 | - return ItemMyErrorQuestionBinding.inflate(from, parent, false) | 19 | +class MyErrorQuestionAdapter : BaseQuickAdapter<ErrorListItem,BaseViewHolder>(R.layout.item_my_error_question) { |
20 | + | ||
21 | + init { | ||
22 | + addChildClickViewIds(R.id.iv_del) | ||
23 | } | 23 | } |
24 | 24 | ||
25 | - override fun onBind(holder: ItemMyErrorQuestionBinding, position: Int, data: VideoCourse) { | ||
26 | - // 错题名称 | ||
27 | - holder.tvQuestionTitle.text = data.courseName | 25 | + override fun convert(holder: BaseViewHolder, item: ErrorListItem) { |
26 | + holder.setText(R.id.tv_question_title,item.title) | ||
28 | } | 27 | } |
29 | } | 28 | } |
@@ -3,27 +3,36 @@ package com.br_technology.securitytrain_master.ui.view.mine.adapter | @@ -3,27 +3,36 @@ package com.br_technology.securitytrain_master.ui.view.mine.adapter | ||
3 | import android.content.Context | 3 | import android.content.Context |
4 | import android.view.LayoutInflater | 4 | import android.view.LayoutInflater |
5 | import android.view.ViewGroup | 5 | import android.view.ViewGroup |
6 | +import com.br_technology.securitytrain_master.R | ||
6 | import com.br_technology.securitytrain_master.base.view.BaseAdapter | 7 | import com.br_technology.securitytrain_master.base.view.BaseAdapter |
7 | import com.br_technology.securitytrain_master.databinding.ItemSpecialExercisesBinding | 8 | import com.br_technology.securitytrain_master.databinding.ItemSpecialExercisesBinding |
9 | +import com.br_technology.securitytrain_master.ui.bean.AnswerRecord | ||
8 | import com.br_technology.securitytrain_master.ui.view.home.pojo.VideoCourse | 10 | import com.br_technology.securitytrain_master.ui.view.home.pojo.VideoCourse |
11 | +import com.chad.library.adapter.base.BaseQuickAdapter | ||
12 | +import com.chad.library.adapter.base.viewholder.BaseViewHolder | ||
9 | 13 | ||
10 | /** | 14 | /** |
11 | * Time: 7/31/2021 17:06 | 15 | * Time: 7/31/2021 17:06 |
12 | * Author: Captain | 16 | * Author: Captain |
13 | * Description: 初见时你很迷人 | 17 | * Description: 初见时你很迷人 |
14 | */ | 18 | */ |
15 | -class SpecialExercisesAdapter : BaseAdapter<VideoCourse,ItemSpecialExercisesBinding>() { | ||
16 | - override fun getViewBinding( | ||
17 | - context: Context, | ||
18 | - parent: ViewGroup, | ||
19 | - viewType: Int, | ||
20 | - from: LayoutInflater | ||
21 | - ): ItemSpecialExercisesBinding { | ||
22 | - return ItemSpecialExercisesBinding.inflate(from, parent, false) | ||
23 | - } | ||
24 | - | ||
25 | - override fun onBind(holder: ItemSpecialExercisesBinding, position: Int, data: VideoCourse) { | ||
26 | - // 题名称 | ||
27 | - holder.tvQuestionTitle.text = data.courseName | 19 | +class SpecialExercisesAdapter : BaseQuickAdapter<AnswerRecord,BaseViewHolder>(R.layout.item_special_exercises) { |
20 | + override fun convert(holder: BaseViewHolder, item: AnswerRecord) { | ||
21 | + holder.setText(R.id.tv_question_title,item.title) | ||
22 | + .setText(R.id.tv_timer,item.create_time_text) | ||
23 | + .setText(R.id.tv_answer,"答对:${item.correct}/${item.count}") | ||
28 | } | 24 | } |
25 | +// override fun getViewBinding( | ||
26 | +// context: Context, | ||
27 | +// parent: ViewGroup, | ||
28 | +// viewType: Int, | ||
29 | +// from: LayoutInflater | ||
30 | +// ): ItemSpecialExercisesBinding { | ||
31 | +// return ItemSpecialExercisesBinding.inflate(from, parent, false) | ||
32 | +// } | ||
33 | +// | ||
34 | +// override fun onBind(holder: ItemSpecialExercisesBinding, position: Int, data: VideoCourse) { | ||
35 | +// // 题名称 | ||
36 | +// holder.tvQuestionTitle.text = data.courseName | ||
37 | +// } | ||
29 | } | 38 | } |
1 | package com.br_technology.securitytrain_master.ui.view.mine.fragment | 1 | package com.br_technology.securitytrain_master.ui.view.mine.fragment |
2 | 2 | ||
3 | +import android.content.Intent | ||
4 | +import android.os.Bundle | ||
3 | import com.br_technology.securitytrain_master.R | 5 | import com.br_technology.securitytrain_master.R |
4 | import com.br_technology.securitytrain_master.databinding.FragmentMyErrorQuestionBinding | 6 | import com.br_technology.securitytrain_master.databinding.FragmentMyErrorQuestionBinding |
7 | +import com.br_technology.securitytrain_master.ui.bean.ErrorListItem | ||
8 | +import com.br_technology.securitytrain_master.ui.view.bank.activity.WrongQuestionsActivity | ||
5 | import com.br_technology.securitytrain_master.ui.view.home.pojo.VideoCourse | 9 | import com.br_technology.securitytrain_master.ui.view.home.pojo.VideoCourse |
6 | import com.br_technology.securitytrain_master.ui.view.mine.adapter.MyErrorQuestionAdapter | 10 | import com.br_technology.securitytrain_master.ui.view.mine.adapter.MyErrorQuestionAdapter |
7 | import com.br_technology.securitytrain_master.ui.view.mine.viewmodel.MyErrorQuestionFragmentViewModel | 11 | import com.br_technology.securitytrain_master.ui.view.mine.viewmodel.MyErrorQuestionFragmentViewModel |
8 | import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleFragment | 12 | import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleFragment |
13 | +import kotlin.properties.Delegates | ||
9 | 14 | ||
10 | /** | 15 | /** |
11 | * Time: 7/31/2021 15:47 | 16 | * Time: 7/31/2021 15:47 |
@@ -16,23 +21,84 @@ class MyErrorQuestionFragment : | @@ -16,23 +21,84 @@ class MyErrorQuestionFragment : | ||
16 | BaseLifeCycleFragment<MyErrorQuestionFragmentViewModel, FragmentMyErrorQuestionBinding>( | 21 | BaseLifeCycleFragment<MyErrorQuestionFragmentViewModel, FragmentMyErrorQuestionBinding>( |
17 | FragmentMyErrorQuestionBinding::inflate | 22 | FragmentMyErrorQuestionBinding::inflate |
18 | ) { | 23 | ) { |
19 | - override fun initDataObserver() { | ||
20 | 24 | ||
25 | + private val questionAdapter: MyErrorQuestionAdapter by lazy { | ||
26 | + MyErrorQuestionAdapter() | ||
27 | + } | ||
28 | + private var page = 1 | ||
29 | + private var type by Delegates.notNull<Int>() | ||
30 | + override fun initDataObserver() { | ||
31 | + mViewModel.liveData.observe(this) { | ||
32 | + map[type] = false | ||
33 | + if (it.data.list.data.size <= 20) { | ||
34 | + binding.smartRefresh.setNoMoreData(true) | ||
35 | + } | ||
36 | + if (page == 1) { | ||
37 | + questionAdapter.setNewInstance(it.data.list.data as MutableList<ErrorListItem>) | ||
38 | + } else { | ||
39 | + questionAdapter.addData(it.data.list.data) | ||
40 | + } | ||
41 | + } | ||
42 | + mViewModel.delErrorLiveData.observe(this) { | ||
43 | + showTip("删除成功") | ||
44 | + binding.smartRefresh.autoRefresh() | ||
45 | + } | ||
21 | } | 46 | } |
22 | 47 | ||
23 | override fun initData() { | 48 | override fun initData() { |
24 | super.initData() | 49 | super.initData() |
50 | + type = arguments?.getInt("type", 1) ?: 1 | ||
51 | + | ||
25 | binding.apply { | 52 | binding.apply { |
53 | + smartRefresh.setOnRefreshListener { | ||
54 | + page = 1 | ||
55 | + smartRefresh.setNoMoreData(false) | ||
56 | + mViewModel.errorList(type, page) | ||
57 | + smartRefresh.finishRefresh() | ||
58 | + } | ||
59 | + smartRefresh.setOnLoadMoreListener { | ||
60 | + ++page | ||
61 | + mViewModel.errorList(type, page) | ||
62 | + smartRefresh.finishLoadMore() | ||
63 | + } | ||
64 | + recyclerview.adapter = questionAdapter | ||
65 | + // 删除 | ||
66 | + questionAdapter.setOnItemChildClickListener { adapter, view, position -> | ||
67 | + val errorListItem = adapter.data.get(position) as ErrorListItem | ||
68 | + mViewModel.delError( | ||
69 | + errorListItem.item_id.toInt(), | ||
70 | + type, | ||
71 | + errorListItem.item_type.toInt() | ||
72 | + ) | ||
73 | + } | ||
74 | + // 继续答题 | ||
75 | + questionAdapter.setOnItemClickListener { adapter, view, position -> | ||
76 | + val intent = Intent(requireActivity(), WrongQuestionsActivity::class.java) | ||
77 | + intent.putExtra("id", questionAdapter.data[position].id) | ||
78 | + intent.putExtra("type", type) | ||
79 | + startActivity(intent) | ||
80 | + } | ||
81 | + } | ||
82 | + } | ||
83 | + | ||
84 | + override fun onResume() { | ||
85 | + super.onResume() | ||
86 | + if (map[type] == true) { | ||
87 | + binding.recyclerview.scrollToPosition(0) | ||
88 | + binding.smartRefresh.autoRefresh() | ||
89 | + } | ||
90 | + } | ||
91 | + | ||
26 | 92 | ||
27 | - val myErrorQuestionAdapter = MyErrorQuestionAdapter() | ||
28 | - val list = mutableListOf( | ||
29 | - VideoCourse(R.mipmap.banner, "01:45:00", "自动化制作课程", "1.1", "张钧-三岗职位培训班"), | ||
30 | - VideoCourse(R.mipmap.banner, "01:45:00", "自动化制作课程", "1.1", "张钧-三岗职位培训班"), | ||
31 | - VideoCourse(R.mipmap.banner, "01:45:00", "自动化制作课程", "1.1", "张钧-三岗职位培训班"), | ||
32 | - VideoCourse(R.mipmap.banner, "01:45:00", "自动化制作课程", "1.1", "张钧-三岗职位培训班"), | ||
33 | - ) | ||
34 | - recyclerview.adapter = myErrorQuestionAdapter | ||
35 | - myErrorQuestionAdapter.addList(list) | 93 | + companion object { |
94 | + val map = hashMapOf<Int, Boolean>() | ||
95 | + fun newInstance(type: Int): MyErrorQuestionFragment { | ||
96 | + map[type] = true | ||
97 | + val fragment = MyErrorQuestionFragment() | ||
98 | + val bundle = Bundle() | ||
99 | + bundle.putInt("type", type) | ||
100 | + fragment.arguments = bundle | ||
101 | + return fragment | ||
36 | } | 102 | } |
37 | } | 103 | } |
38 | } | 104 | } |
1 | package com.br_technology.securitytrain_master.ui.view.mine.fragment | 1 | package com.br_technology.securitytrain_master.ui.view.mine.fragment |
2 | 2 | ||
3 | +import android.content.Intent | ||
4 | +import android.os.Bundle | ||
3 | import com.br_technology.securitytrain_master.R | 5 | import com.br_technology.securitytrain_master.R |
4 | import com.br_technology.securitytrain_master.databinding.FragmentSpecialExercisesBinding | 6 | import com.br_technology.securitytrain_master.databinding.FragmentSpecialExercisesBinding |
7 | +import com.br_technology.securitytrain_master.ui.bean.AnswerRecord | ||
8 | +import com.br_technology.securitytrain_master.ui.view.bank.activity.AnswerRecordDetailsActivity | ||
5 | import com.br_technology.securitytrain_master.ui.view.home.pojo.VideoCourse | 9 | import com.br_technology.securitytrain_master.ui.view.home.pojo.VideoCourse |
6 | import com.br_technology.securitytrain_master.ui.view.mine.adapter.SpecialExercisesAdapter | 10 | import com.br_technology.securitytrain_master.ui.view.mine.adapter.SpecialExercisesAdapter |
7 | import com.br_technology.securitytrain_master.ui.view.mine.viewmodel.SpecialExercisesFragmentViewModel | 11 | import com.br_technology.securitytrain_master.ui.view.mine.viewmodel.SpecialExercisesFragmentViewModel |
8 | import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleFragment | 12 | import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleFragment |
13 | +import kotlin.properties.Delegates | ||
9 | 14 | ||
10 | /** | 15 | /** |
11 | * Time: 7/31/2021 17:02 | 16 | * Time: 7/31/2021 17:02 |
@@ -17,24 +22,71 @@ class SpecialExercisesFragment | @@ -17,24 +22,71 @@ class SpecialExercisesFragment | ||
17 | : BaseLifeCycleFragment<SpecialExercisesFragmentViewModel, FragmentSpecialExercisesBinding>( | 22 | : BaseLifeCycleFragment<SpecialExercisesFragmentViewModel, FragmentSpecialExercisesBinding>( |
18 | FragmentSpecialExercisesBinding::inflate | 23 | FragmentSpecialExercisesBinding::inflate |
19 | ) { | 24 | ) { |
20 | - override fun initDataObserver() { | ||
21 | 25 | ||
26 | + | ||
27 | + private var page = 1 | ||
28 | + private var type by Delegates.notNull<Int>() | ||
29 | + private val exercisesAdapter: SpecialExercisesAdapter by lazy { | ||
30 | + SpecialExercisesAdapter() | ||
31 | + } | ||
32 | + | ||
33 | + private val map = hashMapOf(1 to true, 2 to true, 3 to true, 4 to true) | ||
34 | + override fun initDataObserver() { | ||
35 | + mViewModel.liveData.observe(this) { | ||
36 | + if (it.data.list.data.size <= 20) { | ||
37 | + binding.smartRefresh.setNoMoreData(true) | ||
38 | + } | ||
39 | + if (page == 1) { | ||
40 | + exercisesAdapter.setNewInstance(it.data.list.data as MutableList<AnswerRecord>) | ||
41 | + } else { | ||
42 | + exercisesAdapter.addData(it.data.list.data) | ||
43 | + } | ||
44 | + } | ||
22 | } | 45 | } |
23 | 46 | ||
24 | override fun initData() { | 47 | override fun initData() { |
25 | super.initData() | 48 | super.initData() |
49 | + type = arguments?.getInt("type") ?: 1 | ||
50 | + | ||
51 | + | ||
26 | binding.apply { | 52 | binding.apply { |
53 | + smartRefresh.setOnRefreshListener { | ||
54 | + page = 1 | ||
55 | + smartRefresh.setNoMoreData(false) | ||
56 | + mViewModel.errorSubList(type, page) | ||
57 | + smartRefresh.finishRefresh() | ||
58 | + } | ||
59 | + smartRefresh.setOnLoadMoreListener { | ||
60 | + ++page | ||
61 | + mViewModel.errorSubList(type, page) | ||
62 | + smartRefresh.finishLoadMore() | ||
63 | + } | ||
64 | + recyclerview.adapter = exercisesAdapter | ||
65 | + exercisesAdapter.setOnItemClickListener { adapter, view, position -> | ||
66 | + val intent = Intent(requireContext(), AnswerRecordDetailsActivity::class.java) | ||
67 | + intent.putExtra("id", exercisesAdapter.data[position].id) | ||
68 | + startActivity(intent) | ||
69 | + } | ||
70 | + | ||
27 | 71 | ||
28 | - val specialExercisesAdapter = SpecialExercisesAdapter() | ||
29 | - val list = mutableListOf( | ||
30 | - VideoCourse(R.mipmap.banner, "01:45:00", "自动化制作课程", "1.1", "张钧-三岗职位培训班"), | ||
31 | - VideoCourse(R.mipmap.banner, "01:45:00", "自动化制作课程", "1.1", "张钧-三岗职位培训班"), | ||
32 | - VideoCourse(R.mipmap.banner, "01:45:00", "自动化制作课程", "1.1", "张钧-三岗职位培训班"), | ||
33 | - VideoCourse(R.mipmap.banner, "01:45:00", "自动化制作课程", "1.1", "张钧-三岗职位培训班"), | ||
34 | - ) | ||
35 | - recyclerview.adapter = specialExercisesAdapter | ||
36 | - specialExercisesAdapter.addList(list) | ||
37 | } | 72 | } |
38 | } | 73 | } |
39 | 74 | ||
75 | + override fun onResume() { | ||
76 | + super.onResume() | ||
77 | + if (map[type] == true) { | ||
78 | + map[type] = false | ||
79 | + binding.smartRefresh.autoRefresh() | ||
80 | + } | ||
81 | + } | ||
82 | + | ||
83 | + companion object { | ||
84 | + fun newInstance(type: Int): SpecialExercisesFragment { | ||
85 | + val fragment = SpecialExercisesFragment() | ||
86 | + val bundle = Bundle() | ||
87 | + bundle.putInt("type", type) | ||
88 | + fragment.arguments = bundle | ||
89 | + return fragment | ||
90 | + } | ||
91 | + } | ||
40 | } | 92 | } |
@@ -2,7 +2,12 @@ package com.br_technology.securitytrain_master.ui.view.mine.repository | @@ -2,7 +2,12 @@ package com.br_technology.securitytrain_master.ui.view.mine.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.BaseResponse | ||
6 | +import com.br_technology.securitytrain_master.base.network.response.CommonDataList | ||
7 | +import com.br_technology.securitytrain_master.base.network.response.CommonList | ||
8 | +import com.br_technology.securitytrain_master.base.network.response.CommonPage | ||
5 | import com.br_technology.securitytrain_master.base.repository.ApiRepository | 9 | import com.br_technology.securitytrain_master.base.repository.ApiRepository |
10 | +import com.br_technology.securitytrain_master.ui.bean.ErrorListItem | ||
6 | 11 | ||
7 | /** | 12 | /** |
8 | * Time: 7/31/2021 15:48 | 13 | * Time: 7/31/2021 15:48 |
@@ -10,4 +15,25 @@ import com.br_technology.securitytrain_master.base.repository.ApiRepository | @@ -10,4 +15,25 @@ import com.br_technology.securitytrain_master.base.repository.ApiRepository | ||
10 | * Description: 初见时你很迷人 | 15 | * Description: 初见时你很迷人 |
11 | */ | 16 | */ |
12 | class MyErrorQuestionFragmentRepository(val loadState: MutableLiveData<State>) : ApiRepository(loadState) { | 17 | class MyErrorQuestionFragmentRepository(val loadState: MutableLiveData<State>) : ApiRepository(loadState) { |
18 | + //错题列表 | ||
19 | + fun errorList( | ||
20 | + type: Int, | ||
21 | + page: Int, | ||
22 | + page_num: Int, | ||
23 | + liveData: MutableLiveData<BaseResponse<CommonDataList<CommonPage<ErrorListItem>>>> | ||
24 | + ) { | ||
25 | + addRequest(itemService.errorList(type, page, page_num), liveData) | ||
26 | + } | ||
27 | + | ||
28 | + | ||
29 | + //删除错题 | ||
30 | + fun delError( | ||
31 | + item_id: Int, | ||
32 | + type: Int, | ||
33 | + item_type: Int, | ||
34 | + liveData: MutableLiveData<BaseResponse<Void>> | ||
35 | + ) { | ||
36 | + addRequest(itemService.delError(item_id, type, item_type), liveData) | ||
37 | + } | ||
38 | + | ||
13 | } | 39 | } |
@@ -2,7 +2,10 @@ package com.br_technology.securitytrain_master.ui.view.mine.repository | @@ -2,7 +2,10 @@ package com.br_technology.securitytrain_master.ui.view.mine.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.BaseResponse | ||
6 | +import com.br_technology.securitytrain_master.base.network.response.CommonList | ||
5 | import com.br_technology.securitytrain_master.base.repository.ApiRepository | 7 | import com.br_technology.securitytrain_master.base.repository.ApiRepository |
8 | +import com.br_technology.securitytrain_master.ui.bean.ErrorListItem | ||
6 | 9 | ||
7 | /** | 10 | /** |
8 | * Time: 7/31/2021 15:37 | 11 | * Time: 7/31/2021 15:37 |
@@ -10,4 +13,6 @@ import com.br_technology.securitytrain_master.base.repository.ApiRepository | @@ -10,4 +13,6 @@ import com.br_technology.securitytrain_master.base.repository.ApiRepository | ||
10 | * Description: 初见时你很迷人 | 13 | * Description: 初见时你很迷人 |
11 | */ | 14 | */ |
12 | class MyErrorQuestionRepository(val loadState: MutableLiveData<State>) : ApiRepository(loadState) { | 15 | class MyErrorQuestionRepository(val loadState: MutableLiveData<State>) : ApiRepository(loadState) { |
16 | + | ||
17 | + | ||
13 | } | 18 | } |
@@ -2,7 +2,11 @@ package com.br_technology.securitytrain_master.ui.view.mine.repository | @@ -2,7 +2,11 @@ package com.br_technology.securitytrain_master.ui.view.mine.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.BaseResponse | ||
6 | +import com.br_technology.securitytrain_master.base.network.response.CommonList | ||
5 | import com.br_technology.securitytrain_master.base.repository.ApiRepository | 7 | import com.br_technology.securitytrain_master.base.repository.ApiRepository |
8 | +import com.br_technology.securitytrain_master.ui.bean.AnswerDetail | ||
9 | +import com.br_technology.securitytrain_master.ui.bean.AnswerRecord | ||
6 | 10 | ||
7 | /** | 11 | /** |
8 | * Time: 7/31/2021 16:55 | 12 | * Time: 7/31/2021 16:55 |
@@ -10,4 +14,7 @@ import com.br_technology.securitytrain_master.base.repository.ApiRepository | @@ -10,4 +14,7 @@ import com.br_technology.securitytrain_master.base.repository.ApiRepository | ||
10 | * Description: 初见时你很迷人 | 14 | * Description: 初见时你很迷人 |
11 | */ | 15 | */ |
12 | class QuestionRecordRepository(val loadState: MutableLiveData<State>) : ApiRepository(loadState) { | 16 | class QuestionRecordRepository(val loadState: MutableLiveData<State>) : ApiRepository(loadState) { |
17 | + | ||
18 | + | ||
19 | + | ||
13 | } | 20 | } |
@@ -2,7 +2,12 @@ package com.br_technology.securitytrain_master.ui.view.mine.repository | @@ -2,7 +2,12 @@ package com.br_technology.securitytrain_master.ui.view.mine.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.BaseResponse | ||
6 | +import com.br_technology.securitytrain_master.base.network.response.CommonDataList | ||
7 | +import com.br_technology.securitytrain_master.base.network.response.CommonList | ||
8 | +import com.br_technology.securitytrain_master.base.network.response.CommonPage | ||
5 | import com.br_technology.securitytrain_master.base.repository.ApiRepository | 9 | import com.br_technology.securitytrain_master.base.repository.ApiRepository |
10 | +import com.br_technology.securitytrain_master.ui.bean.AnswerRecord | ||
6 | 11 | ||
7 | /** | 12 | /** |
8 | * Time: 7/31/2021 17:02 | 13 | * Time: 7/31/2021 17:02 |
@@ -10,4 +15,15 @@ import com.br_technology.securitytrain_master.base.repository.ApiRepository | @@ -10,4 +15,15 @@ import com.br_technology.securitytrain_master.base.repository.ApiRepository | ||
10 | * Description: 初见时你很迷人 | 15 | * Description: 初见时你很迷人 |
11 | */ | 16 | */ |
12 | class SpecialExercisesFragmentRepository(val loadState: MutableLiveData<State>) : ApiRepository(loadState) { | 17 | class SpecialExercisesFragmentRepository(val loadState: MutableLiveData<State>) : ApiRepository(loadState) { |
18 | + | ||
19 | + //答题记录 | ||
20 | + fun errorSubList( | ||
21 | + type: Int, | ||
22 | + page: Int, | ||
23 | + page_num: Int, | ||
24 | + liveData: MutableLiveData<BaseResponse<CommonDataList<CommonPage<AnswerRecord>>>> | ||
25 | + ) { | ||
26 | + addRequest(itemService.errorSubList(type, page, page_num), liveData) | ||
27 | + } | ||
28 | + | ||
13 | } | 29 | } |
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.CommonDataList | ||
6 | +import com.br_technology.securitytrain_master.base.network.response.CommonList | ||
7 | +import com.br_technology.securitytrain_master.base.network.response.CommonPage | ||
3 | import com.br_technology.securitytrain_master.base.view.BaseViewModel | 8 | import com.br_technology.securitytrain_master.base.view.BaseViewModel |
9 | +import com.br_technology.securitytrain_master.ui.bean.ErrorListItem | ||
4 | import com.br_technology.securitytrain_master.ui.view.mine.repository.MyErrorQuestionFragmentRepository | 10 | import com.br_technology.securitytrain_master.ui.view.mine.repository.MyErrorQuestionFragmentRepository |
5 | 11 | ||
6 | /** | 12 | /** |
@@ -9,4 +15,26 @@ import com.br_technology.securitytrain_master.ui.view.mine.repository.MyErrorQue | @@ -9,4 +15,26 @@ import com.br_technology.securitytrain_master.ui.view.mine.repository.MyErrorQue | ||
9 | * Description: 初见时你很迷人 | 15 | * Description: 初见时你很迷人 |
10 | */ | 16 | */ |
11 | class MyErrorQuestionFragmentViewModel : BaseViewModel<MyErrorQuestionFragmentRepository>() { | 17 | class MyErrorQuestionFragmentViewModel : BaseViewModel<MyErrorQuestionFragmentRepository>() { |
18 | + | ||
19 | + val liveData: MutableLiveData<BaseResponse<CommonDataList<CommonPage<ErrorListItem>>>> = MutableLiveData() | ||
20 | + val delErrorLiveData: MutableLiveData<BaseResponse<Void>> = MutableLiveData() | ||
21 | + | ||
22 | + fun errorList( | ||
23 | + type: Int, | ||
24 | + page: Int, | ||
25 | + ) { | ||
26 | + mRepository.errorList(type, page, 20, liveData) | ||
27 | + } | ||
28 | + | ||
29 | + | ||
30 | + //删除错题 | ||
31 | + fun delError( | ||
32 | + item_id: Int, | ||
33 | + type: Int, | ||
34 | + item_type: Int, | ||
35 | + ) { | ||
36 | + mRepository.delError(item_id,type,item_type,delErrorLiveData) | ||
37 | + } | ||
38 | + | ||
39 | + | ||
12 | } | 40 | } |
@@ -9,4 +9,5 @@ import com.br_technology.securitytrain_master.ui.view.mine.repository.MyErrorQue | @@ -9,4 +9,5 @@ import com.br_technology.securitytrain_master.ui.view.mine.repository.MyErrorQue | ||
9 | * Description: 初见时你很迷人 | 9 | * Description: 初见时你很迷人 |
10 | */ | 10 | */ |
11 | class MyErrorQuestionViewModel : BaseViewModel<MyErrorQuestionRepository>() { | 11 | class MyErrorQuestionViewModel : BaseViewModel<MyErrorQuestionRepository>() { |
12 | + | ||
12 | } | 13 | } |
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.CommonDataList | ||
6 | +import com.br_technology.securitytrain_master.base.network.response.CommonPage | ||
3 | import com.br_technology.securitytrain_master.base.view.BaseViewModel | 7 | import com.br_technology.securitytrain_master.base.view.BaseViewModel |
8 | +import com.br_technology.securitytrain_master.ui.bean.AnswerRecord | ||
4 | import com.br_technology.securitytrain_master.ui.view.mine.repository.SpecialExercisesFragmentRepository | 9 | import com.br_technology.securitytrain_master.ui.view.mine.repository.SpecialExercisesFragmentRepository |
5 | 10 | ||
6 | /** | 11 | /** |
@@ -9,4 +14,15 @@ import com.br_technology.securitytrain_master.ui.view.mine.repository.SpecialExe | @@ -9,4 +14,15 @@ import com.br_technology.securitytrain_master.ui.view.mine.repository.SpecialExe | ||
9 | * Description: 初见时你很迷人 | 14 | * Description: 初见时你很迷人 |
10 | */ | 15 | */ |
11 | class SpecialExercisesFragmentViewModel : BaseViewModel<SpecialExercisesFragmentRepository>() { | 16 | class SpecialExercisesFragmentViewModel : BaseViewModel<SpecialExercisesFragmentRepository>() { |
17 | + | ||
18 | + val liveData: MutableLiveData<BaseResponse<CommonDataList<CommonPage<AnswerRecord>>>> = | ||
19 | + MutableLiveData() | ||
20 | + | ||
21 | + //答题记录 | ||
22 | + fun errorSubList( | ||
23 | + type: Int, | ||
24 | + page: Int, | ||
25 | + ) { | ||
26 | + mRepository.errorSubList(type, page, 20, liveData) | ||
27 | + } | ||
12 | } | 28 | } |
1 | +<?xml version="1.0" encoding="utf-8"?> | ||
2 | +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
3 | + xmlns:app="http://schemas.android.com/apk/res-auto" | ||
4 | + android:layout_width="match_parent" | ||
5 | + android:layout_height="match_parent" | ||
6 | + android:orientation="vertical"> | ||
7 | + | ||
8 | + <RelativeLayout | ||
9 | + android:layout_width="match_parent" | ||
10 | + android:layout_height="wrap_content"> | ||
11 | + | ||
12 | + <ImageView | ||
13 | + android:layout_width="match_parent" | ||
14 | + android:layout_height="wrap_content" | ||
15 | + android:layout_alignTop="@+id/toolbar" | ||
16 | + android:layout_alignBottom="@+id/tool_bar" | ||
17 | + android:layout_centerVertical="true" | ||
18 | + android:contentDescription="@string/logo" | ||
19 | + android:scaleType="fitXY" | ||
20 | + android:src="@mipmap/practice_back" /> | ||
21 | + | ||
22 | + <LinearLayout | ||
23 | + android:id="@+id/toolbar" | ||
24 | + android:layout_width="match_parent" | ||
25 | + android:layout_height="wrap_content"> | ||
26 | + | ||
27 | + <include layout="@layout/layout_tool_bar" /> | ||
28 | + </LinearLayout> | ||
29 | + | ||
30 | + <com.br_technology.securitytrain_master.view.ViewToolBar | ||
31 | + android:id="@+id/tool_bar" | ||
32 | + android:layout_width="match_parent" | ||
33 | + android:layout_height="44dp" | ||
34 | + android:layout_below="@id/toolbar" /> | ||
35 | + | ||
36 | + </RelativeLayout> | ||
37 | + | ||
38 | + <androidx.viewpager2.widget.ViewPager2 | ||
39 | + android:id="@+id/practice_pager" | ||
40 | + android:layout_width="match_parent" | ||
41 | + android:layout_height="0dp" | ||
42 | + android:layout_weight="1" /> | ||
43 | + | ||
44 | + <View | ||
45 | + android:layout_width="match_parent" | ||
46 | + android:layout_height="1dp" | ||
47 | + android:background="@color/color_f7" /> | ||
48 | + | ||
49 | + <LinearLayout | ||
50 | + android:layout_width="match_parent" | ||
51 | + android:layout_height="60dp" | ||
52 | + android:layout_marginStart="16dp" | ||
53 | + android:layout_marginEnd="16dp" | ||
54 | + android:gravity="center_vertical" | ||
55 | + android:orientation="horizontal"> | ||
56 | + | ||
57 | + <TextView | ||
58 | + android:id="@+id/previous" | ||
59 | + android:layout_width="wrap_content" | ||
60 | + android:layout_height="wrap_content" | ||
61 | + android:layout_marginEnd="40dp" | ||
62 | + android:drawableStart="@mipmap/previous" | ||
63 | + android:drawablePadding="4dp" | ||
64 | + android:gravity="center_vertical" | ||
65 | + android:text="上一题" | ||
66 | + android:textColor="@color/color_25" | ||
67 | + android:textSize="14sp" | ||
68 | + android:visibility="gone" /> | ||
69 | + | ||
70 | + | ||
71 | + <TextView | ||
72 | + android:id="@+id/next" | ||
73 | + android:layout_width="wrap_content" | ||
74 | + android:layout_height="wrap_content" | ||
75 | + android:drawableEnd="@mipmap/next" | ||
76 | + android:drawablePadding="4dp" | ||
77 | + android:gravity="center_vertical" | ||
78 | + android:text="下一题" | ||
79 | + android:textColor="@color/color_25" | ||
80 | + android:textSize="14sp" | ||
81 | + android:visibility="visible" /> | ||
82 | + | ||
83 | + <View | ||
84 | + android:layout_width="0dp" | ||
85 | + android:layout_height="match_parent" | ||
86 | + android:layout_weight="1" /> | ||
87 | + | ||
88 | + <TextView | ||
89 | + android:id="@+id/finish_job" | ||
90 | + android:layout_width="104dp" | ||
91 | + android:layout_height="44dp" | ||
92 | + android:background="@drawable/solid_25_4" | ||
93 | + android:gravity="center" | ||
94 | + android:text="交卷" | ||
95 | + android:textColor="@color/white" | ||
96 | + android:textSize="16sp" | ||
97 | + android:visibility="gone" /> | ||
98 | + | ||
99 | + </LinearLayout> | ||
100 | + | ||
101 | +</LinearLayout> |
@@ -18,16 +18,17 @@ | @@ -18,16 +18,17 @@ | ||
18 | android:id="@+id/tab_layout" | 18 | android:id="@+id/tab_layout" |
19 | style="@style/SearchTab" | 19 | style="@style/SearchTab" |
20 | android:layout_width="match_parent" | 20 | android:layout_width="match_parent" |
21 | - android:layout_height="?actionBarSize" | 21 | + android:layout_height="44dp" |
22 | android:overScrollMode="never" | 22 | android:overScrollMode="never" |
23 | - app:tabMode="auto" | 23 | + app:tabMode="fixed" |
24 | + app:tabGravity="fill" | ||
24 | app:tabSelectedTextColor="@color/color_252" | 25 | app:tabSelectedTextColor="@color/color_252" |
25 | app:tabTextColor="@color/color_96" /> | 26 | app:tabTextColor="@color/color_96" /> |
26 | 27 | ||
27 | <View | 28 | <View |
28 | android:layout_width="match_parent" | 29 | android:layout_width="match_parent" |
29 | android:layout_height="8dp" | 30 | android:layout_height="8dp" |
30 | - android:background="@color/color_f7"></View> | 31 | + android:background="@color/color_f7"/> |
31 | 32 | ||
32 | <androidx.viewpager.widget.ViewPager | 33 | <androidx.viewpager.widget.ViewPager |
33 | android:id="@+id/view_pager" | 34 | android:id="@+id/view_pager" |
1 | +<?xml version="1.0" encoding="utf-8"?> | ||
2 | +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
3 | + android:layout_width="match_parent" | ||
4 | + android:layout_height="match_parent" | ||
5 | + android:orientation="vertical"> | ||
6 | + | ||
7 | + <RelativeLayout | ||
8 | + android:layout_width="match_parent" | ||
9 | + android:layout_height="wrap_content"> | ||
10 | + | ||
11 | + <ImageView | ||
12 | + android:layout_width="match_parent" | ||
13 | + android:layout_height="wrap_content" | ||
14 | + android:layout_alignTop="@+id/toolbar" | ||
15 | + android:layout_alignBottom="@+id/tool_bar" | ||
16 | + android:layout_centerVertical="true" | ||
17 | + android:contentDescription="@string/logo" | ||
18 | + android:scaleType="fitXY" | ||
19 | + android:src="@mipmap/practice_back" /> | ||
20 | + | ||
21 | + <LinearLayout | ||
22 | + android:id="@+id/toolbar" | ||
23 | + android:layout_width="match_parent" | ||
24 | + android:layout_height="wrap_content"> | ||
25 | + | ||
26 | + <include layout="@layout/layout_tool_bar" /> | ||
27 | + </LinearLayout> | ||
28 | + | ||
29 | + <com.br_technology.securitytrain_master.view.ViewToolBar | ||
30 | + android:id="@+id/tool_bar" | ||
31 | + android:layout_width="match_parent" | ||
32 | + android:layout_height="44dp" | ||
33 | + android:layout_below="@id/toolbar" /> | ||
34 | + | ||
35 | + </RelativeLayout> | ||
36 | + | ||
37 | + <androidx.viewpager2.widget.ViewPager2 | ||
38 | + android:id="@+id/error_pager" | ||
39 | + android:layout_width="match_parent" | ||
40 | + android:layout_height="0dp" | ||
41 | + android:layout_weight="1" /> | ||
42 | + | ||
43 | + <View | ||
44 | + android:layout_width="match_parent" | ||
45 | + android:layout_height="1dp" | ||
46 | + android:background="@color/color_f7" /> | ||
47 | + | ||
48 | + <LinearLayout | ||
49 | + android:layout_width="match_parent" | ||
50 | + android:layout_height="60dp" | ||
51 | + android:layout_marginStart="16dp" | ||
52 | + android:layout_marginEnd="16dp" | ||
53 | + android:gravity="center_vertical" | ||
54 | + android:orientation="horizontal"> | ||
55 | + <TextView | ||
56 | + android:id="@+id/finish_job" | ||
57 | + android:layout_width="match_parent" | ||
58 | + android:layout_height="44dp" | ||
59 | + android:background="@drawable/solid_25_4" | ||
60 | + android:gravity="center" | ||
61 | + android:text="交卷" | ||
62 | + android:textColor="@color/white" | ||
63 | + android:textSize="16sp" /> | ||
64 | + </LinearLayout> | ||
65 | + | ||
66 | +</LinearLayout> |
1 | <?xml version="1.0" encoding="utf-8"?> | 1 | <?xml version="1.0" encoding="utf-8"?> |
2 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | 2 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
3 | + xmlns:app="http://schemas.android.com/apk/res-auto" | ||
3 | android:layout_width="match_parent" | 4 | android:layout_width="match_parent" |
4 | android:layout_height="match_parent" | 5 | android:layout_height="match_parent" |
5 | - xmlns:app="http://schemas.android.com/apk/res-auto" | ||
6 | android:background="@color/white" | 6 | android:background="@color/white" |
7 | android:orientation="vertical"> | 7 | android:orientation="vertical"> |
8 | 8 | ||
9 | - <androidx.recyclerview.widget.RecyclerView | ||
10 | - android:id="@+id/recyclerview" | 9 | + <com.scwang.smart.refresh.layout.SmartRefreshLayout |
10 | + android:id="@+id/smart_refresh" | ||
11 | android:layout_width="match_parent" | 11 | android:layout_width="match_parent" |
12 | - android:layout_height="match_parent" | ||
13 | - android:layout_marginStart="16dp" | ||
14 | - android:layout_marginTop="24dp" | ||
15 | - android:layout_marginEnd="16dp" | ||
16 | - android:overScrollMode="never" | ||
17 | - android:scrollbars="none" | ||
18 | - app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" /> | 12 | + android:layout_height="match_parent"> |
19 | 13 | ||
14 | + <androidx.recyclerview.widget.RecyclerView | ||
15 | + android:id="@+id/recyclerview" | ||
16 | + android:layout_width="match_parent" | ||
17 | + android:layout_height="match_parent" | ||
18 | + android:layout_marginStart="16dp" | ||
19 | + android:layout_marginTop="16dp" | ||
20 | + android:layout_marginEnd="16dp" | ||
21 | + android:overScrollMode="never" | ||
22 | + android:scrollbars="none" | ||
23 | + app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" /> | ||
24 | + </com.scwang.smart.refresh.layout.SmartRefreshLayout> | ||
20 | 25 | ||
21 | </LinearLayout> | 26 | </LinearLayout> |
@@ -6,15 +6,21 @@ | @@ -6,15 +6,21 @@ | ||
6 | android:layout_width="match_parent" | 6 | android:layout_width="match_parent" |
7 | android:layout_height="match_parent"> | 7 | android:layout_height="match_parent"> |
8 | 8 | ||
9 | - <androidx.recyclerview.widget.RecyclerView | ||
10 | - android:id="@+id/recyclerview" | ||
11 | - android:layout_width="match_parent" | ||
12 | - android:layout_height="match_parent" | ||
13 | - android:layout_marginStart="16dp" | ||
14 | - android:layout_marginEnd="16dp" | ||
15 | - android:overScrollMode="never" | ||
16 | - android:scrollbars="none" | ||
17 | - app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" /> | 9 | + <com.scwang.smart.refresh.layout.SmartRefreshLayout |
10 | + android:id="@+id/smart_refresh" | ||
11 | + android:layout_width="match_parent" | ||
12 | + android:layout_height="match_parent"> | ||
13 | + <androidx.recyclerview.widget.RecyclerView | ||
14 | + android:id="@+id/recyclerview" | ||
15 | + android:layout_width="match_parent" | ||
16 | + android:layout_height="match_parent" | ||
17 | + android:layout_marginStart="16dp" | ||
18 | + android:layout_marginEnd="16dp" | ||
19 | + android:layout_marginTop="16dp" | ||
20 | + android:overScrollMode="never" | ||
21 | + android:scrollbars="none" | ||
22 | + app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" /> | ||
18 | 23 | ||
24 | + </com.scwang.smart.refresh.layout.SmartRefreshLayout> | ||
19 | 25 | ||
20 | </LinearLayout> | 26 | </LinearLayout> |
@@ -8,9 +8,7 @@ | @@ -8,9 +8,7 @@ | ||
8 | <LinearLayout | 8 | <LinearLayout |
9 | android:layout_width="match_parent" | 9 | android:layout_width="match_parent" |
10 | android:layout_height="82dp" | 10 | android:layout_height="82dp" |
11 | - android:layout_marginStart="16dp" | ||
12 | - android:layout_marginEnd="16dp" | ||
13 | - android:layout_marginTop="16dp" | 11 | + android:layout_marginBottom="16dp" |
14 | android:background="@mipmap/item_error_question_bg" | 12 | android:background="@mipmap/item_error_question_bg" |
15 | android:orientation="horizontal"> | 13 | android:orientation="horizontal"> |
16 | 14 | ||
@@ -22,7 +20,6 @@ | @@ -22,7 +20,6 @@ | ||
22 | android:layout_marginStart="16dp" | 20 | android:layout_marginStart="16dp" |
23 | android:layout_marginEnd="16dp" | 21 | android:layout_marginEnd="16dp" |
24 | android:layout_weight="1" | 22 | android:layout_weight="1" |
25 | - android:text="男子从国外赶回陪产,回家第二天被隔离:孩子出生了我却见不到?" | ||
26 | android:textColor="@color/color_32" | 23 | android:textColor="@color/color_32" |
27 | android:textSize="14sp" /> | 24 | android:textSize="14sp" /> |
28 | 25 |
1 | <?xml version="1.0" encoding="utf-8"?> | 1 | <?xml version="1.0" encoding="utf-8"?> |
2 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | 2 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
3 | + xmlns:app="http://schemas.android.com/apk/res-auto" | ||
3 | android:layout_width="match_parent" | 4 | android:layout_width="match_parent" |
4 | android:layout_height="wrap_content" | 5 | android:layout_height="wrap_content" |
5 | android:background="@color/white" | 6 | android:background="@color/white" |
@@ -8,9 +9,7 @@ | @@ -8,9 +9,7 @@ | ||
8 | <LinearLayout | 9 | <LinearLayout |
9 | android:layout_width="match_parent" | 10 | android:layout_width="match_parent" |
10 | android:layout_height="83dp" | 11 | android:layout_height="83dp" |
11 | - android:layout_marginStart="16dp" | ||
12 | - android:layout_marginTop="16dp" | ||
13 | - android:layout_marginEnd="16dp" | 12 | + android:layout_marginBottom="16dp" |
14 | android:background="@drawable/solid_eff2_4" | 13 | android:background="@drawable/solid_eff2_4" |
15 | android:orientation="vertical"> | 14 | android:orientation="vertical"> |
16 | 15 | ||
@@ -26,11 +25,10 @@ | @@ -26,11 +25,10 @@ | ||
26 | android:layout_marginStart="12dp" | 25 | android:layout_marginStart="12dp" |
27 | android:layout_marginTop="16dp" | 26 | android:layout_marginTop="16dp" |
28 | android:layout_weight="1" | 27 | android:layout_weight="1" |
29 | - android:drawableStart="@mipmap/item_special_exercises_icon" | ||
30 | android:drawablePadding="8dp" | 28 | android:drawablePadding="8dp" |
31 | - android:text="专项练习(焊工)" | ||
32 | android:textColor="@color/color_32" | 29 | android:textColor="@color/color_32" |
33 | - android:textSize="14sp" /> | 30 | + android:textSize="14sp" |
31 | + app:drawableStartCompat="@mipmap/item_special_exercises_icon" /> | ||
34 | 32 | ||
35 | <TextView | 33 | <TextView |
36 | android:id="@+id/tv_timer" | 34 | android:id="@+id/tv_timer" |
@@ -38,7 +36,6 @@ | @@ -38,7 +36,6 @@ | ||
38 | android:layout_height="wrap_content" | 36 | android:layout_height="wrap_content" |
39 | android:layout_marginTop="18dp" | 37 | android:layout_marginTop="18dp" |
40 | android:layout_marginEnd="12dp" | 38 | android:layout_marginEnd="12dp" |
41 | - android:text="2020-09-10 12:00" | ||
42 | android:textColor="@color/color_96" | 39 | android:textColor="@color/color_96" |
43 | android:textSize="12sp" /> | 40 | android:textSize="12sp" /> |
44 | 41 | ||
@@ -55,7 +52,6 @@ | @@ -55,7 +52,6 @@ | ||
55 | android:paddingTop="2dp" | 52 | android:paddingTop="2dp" |
56 | android:paddingEnd="8dp" | 53 | android:paddingEnd="8dp" |
57 | android:paddingBottom="2dp" | 54 | android:paddingBottom="2dp" |
58 | - android:text="答对:50/100" | ||
59 | android:textColor="@color/color_25" | 55 | android:textColor="@color/color_25" |
60 | android:textSize="12sp" /> | 56 | android:textSize="12sp" /> |
61 | 57 |
-
请 注册 或 登录 后发表评论