作者 杨谦

1.答题参与人数...

@@ -18,12 +18,6 @@ import retrofit2.http.POST @@ -18,12 +18,6 @@ import retrofit2.http.POST
18 * PS: Not easy to write code, please indicate. 18 * PS: Not easy to write code, please indicate.
19 */ 19 */
20 interface AllItemApi : ApiService { 20 interface AllItemApi : ApiService {
21 - /**  
22 - * 答题相关参数  
23 - */  
24 - @FormUrlEncoded  
25 - @POST("/api/item/item_about")  
26 - fun itemAbout(): Observable<BaseResponse<AnswerAbout>>  
27 21
28 /** 22 /**
29 * 挑战答题规则 23 * 挑战答题规则
@@ -19,6 +19,12 @@ import retrofit2.http.* @@ -19,6 +19,12 @@ import retrofit2.http.*
19 */ 19 */
20 20
21 interface ApiService { 21 interface ApiService {
  22 + /**
  23 + * 答题相关参数
  24 + */
  25 + @POST("/api/item/item_about")
  26 + fun itemAbout(): Observable<BaseResponse<AnswerAbout>>
  27 +
22 //获取验证码 28 //获取验证码
23 @FormUrlEncoded 29 @FormUrlEncoded
24 @POST("/api/sms/send") 30 @POST("/api/sms/send")
@@ -53,6 +53,7 @@ class BankFragment : @@ -53,6 +53,7 @@ class BankFragment :
53 super.initData() 53 super.initData()
54 practiceList = mutableListOf() 54 practiceList = mutableListOf()
55 mViewModel.practiceList(page, 20) 55 mViewModel.practiceList(page, 20)
  56 + mViewModel.getAbout()
56 binding.apply { 57 binding.apply {
57 // 标题栏类型 58 // 标题栏类型
58 type.text = sp_job_name 59 type.text = sp_job_name
@@ -137,6 +138,9 @@ class BankFragment : @@ -137,6 +138,9 @@ class BankFragment :
137 classifyPop.showAsDropDown(binding.type) 138 classifyPop.showAsDropDown(binding.type)
138 } 139 }
139 }) 140 })
  141 + mViewModel.mAnswerAbout.observe(this, {
  142 + binding.leaderboard.text = "${it.data.count}人参与"
  143 + })
140 //专项练习列表 144 //专项练习列表
141 mViewModel.mPracticeBean.observe(this, { 145 mViewModel.mPracticeBean.observe(this, {
142 binding.swipeRefreshlayout.isRefreshing = false 146 binding.swipeRefreshlayout.isRefreshing = false
@@ -2,12 +2,13 @@ package com.br_technology.securitytrain_master.ui.view.bank.repository @@ -2,12 +2,13 @@ package com.br_technology.securitytrain_master.ui.view.bank.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.AnswerAbout
6 import com.br_technology.securitytrain_master.ui.view.bank.bean.PracticeBean 9 import com.br_technology.securitytrain_master.ui.view.bank.bean.PracticeBean
7 import com.br_technology.securitytrain_master.ui.view.home.bean.WorkTypeBean 10 import com.br_technology.securitytrain_master.ui.view.home.bean.WorkTypeBean
8 import com.wjx.android.wanandroidmvvm.base.observer.BaseObserver 11 import com.wjx.android.wanandroidmvvm.base.observer.BaseObserver
9 -import com.br_technology.securitytrain_master.base.network.response.BaseResponse  
10 -import com.br_technology.securitytrain_master.base.network.response.CommonList  
11 import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers 12 import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
12 import io.reactivex.rxjava3.schedulers.Schedulers 13 import io.reactivex.rxjava3.schedulers.Schedulers
13 14
@@ -33,6 +34,11 @@ class BankRepository(val loadState: MutableLiveData<State>): ApiRepository(loadS @@ -33,6 +34,11 @@ class BankRepository(val loadState: MutableLiveData<State>): ApiRepository(loadS
33 34
34 } 35 }
35 36
  37 + //答题相关参数
  38 + fun getAnswerAbout(liveData: MutableLiveData<BaseResponse<AnswerAbout>>) {
  39 + addRequest(apiService.itemAbout(), liveData)
  40 + }
  41 +
36 fun practiceList( 42 fun practiceList(
37 pos_id : Int, 43 pos_id : Int,
38 page : Int, 44 page : Int,
@@ -5,6 +5,7 @@ import androidx.lifecycle.MutableLiveData @@ -5,6 +5,7 @@ import androidx.lifecycle.MutableLiveData
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.CommonList 6 import com.br_technology.securitytrain_master.base.network.response.CommonList
7 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.AnswerAbout
8 import com.br_technology.securitytrain_master.ui.view.bank.bean.PracticeBean 9 import com.br_technology.securitytrain_master.ui.view.bank.bean.PracticeBean
9 import com.br_technology.securitytrain_master.ui.view.bank.repository.BankRepository 10 import com.br_technology.securitytrain_master.ui.view.bank.repository.BankRepository
10 import com.br_technology.securitytrain_master.ui.view.home.bean.WorkTypeBean 11 import com.br_technology.securitytrain_master.ui.view.home.bean.WorkTypeBean
@@ -17,11 +18,16 @@ import com.br_technology.securitytrain_master.util.sp_job_id @@ -17,11 +18,16 @@ import com.br_technology.securitytrain_master.util.sp_job_id
17 */ 18 */
18 class BankViewModel : BaseViewModel<BankRepository>() { 19 class BankViewModel : BaseViewModel<BankRepository>() {
19 var mWorkTypeBean: MutableLiveData<BaseResponse<WorkTypeBean>> = MutableLiveData() 20 var mWorkTypeBean: MutableLiveData<BaseResponse<WorkTypeBean>> = MutableLiveData()
  21 + var mAnswerAbout: MutableLiveData<BaseResponse<AnswerAbout>> = MutableLiveData()
20 22
21 fun beanData(): LiveData<BaseResponse<WorkTypeBean>> { 23 fun beanData(): LiveData<BaseResponse<WorkTypeBean>> {
22 return mWorkTypeBean 24 return mWorkTypeBean
23 } 25 }
24 26
  27 + fun getAbout() {
  28 + mRepository.getAnswerAbout(mAnswerAbout)
  29 + }
  30 +
25 fun workType( 31 fun workType(
26 ) { 32 ) {
27 mRepository.workType(mWorkTypeBean) 33 mRepository.workType(mWorkTypeBean)
@@ -43,7 +43,6 @@ class ClassifyPop(context: Activity, type: Int) : PopupWindow(context) { @@ -43,7 +43,6 @@ class ClassifyPop(context: Activity, type: Int) : PopupWindow(context) {
43 setBackgroundDrawable(ContextCompat.getDrawable(context, android.R.color.transparent)) 43 setBackgroundDrawable(ContextCompat.getDrawable(context, android.R.color.transparent))
44 isOutsideTouchable = false 44 isOutsideTouchable = false
45 45
46 -  
47 binding.apply { 46 binding.apply {
48 mWorkTypeList = mutableListOf() 47 mWorkTypeList = mutableListOf()
49 courseType.addItemDecoration3(3, 14, 32) 48 courseType.addItemDecoration3(3, 14, 32)