作者 杨谦

1.答题参与人数...

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