| | |
| | | import com.dollearn.student.network.entity.SubjectBean |
| | | import com.dollearn.student.network.request |
| | | import com.dollearn.student.ui.TransparentStatusBarActivity |
| | | import com.dollearn.student.utils.Const |
| | | import com.dollearn.student.utils.event.EmptyEvent |
| | | import kotlinx.android.synthetic.main.activity_listen.* |
| | | import org.greenrobot.eventbus.EventBus |
| | | |
| | | class MatchActivity:TransparentStatusBarActivity() { |
| | | override fun setContentView() = R.layout.activity_listen |
| | |
| | | fun next(){ |
| | | if (view_pager.currentItem == fragments.lastIndex){ |
| | | handler?.removeMessages(0) |
| | | ResultActivity.startResult(this,day,week,season,3,totalCount,rightCount,data!!.data.integral,time,data!!.data.id) |
| | | ResultActivity.startResult(this,day,week,season,5,totalCount,rightCount,data!!.data.integral,time,data!!.data.id) |
| | | finish() |
| | | }else{ |
| | | (fragments[view_pager.currentItem+1] as MatchFragment).recover() |
| | |
| | | } |
| | | |
| | | private fun recover(){ |
| | | HttpManager.teamSchedule(day,week,3).request(this){_,data-> |
| | | view_pager.setCurrentItem(data?.topicIds?.size?:0,false) |
| | | HttpManager.teamSchedule(day,week,5).request(this){_,data-> |
| | | view_pager.setCurrentItem((data?.schedule?:1)-1,false) |
| | | if (view_pager.currentItem != 0) |
| | | tv_last.visible() |
| | | totalCount = data?.answerNumber?:0 |
| | | rightCount = data?.correctNumber?:0 |
| | | } |
| | |
| | | tipDialog.arguments = bundleOf("msg" to "未完成全部答题,确认退出吗?") |
| | | tipDialog.setCallback(object :TipDialog.OnClickCallback{ |
| | | override fun onOk() { |
| | | if (view_pager.currentItem == 0) |
| | | val list = (data?.subjectList?: arrayListOf()).flatMap { it }.subList(0,view_pager.currentItem) |
| | | HttpManager.exitLearning(view_pager.currentItem,season,time,totalCount,rightCount,day,week,5,data?.data?.id?:"", list.joinToString(",") { it.id }).request(this@MatchActivity){ _, _-> |
| | | finish() |
| | | else{ |
| | | val list = (data?.subjectList?: arrayListOf()).flatMap { it }.subList(0,view_pager.currentItem) |
| | | HttpManager.exitLearning(totalCount,rightCount,day,week,3,data?.data?.id?:"", list.joinToString(",") { it.id }).request(this@MatchActivity){ _, _-> |
| | | finish() |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | super.onDestroy() |
| | | handler?.removeMessages(0) |
| | | handler = null |
| | | EventBus.getDefault().post(EmptyEvent(Const.EventCode.STOP_TIMER)) |
| | | } |
| | | } |