| | |
| | | package com.dollearn.student.ui.home |
| | | |
| | | import androidx.core.os.bundleOf |
| | | import androidx.recyclerview.widget.GridLayoutManager |
| | | import androidx.recyclerview.widget.LinearLayoutManager |
| | | import cn.sinata.xldutils.utils.showAllowingStateLoss |
| | | import com.dollearn.student.R |
| | | import com.dollearn.student.dialog.TipDialog |
| | | import com.dollearn.student.network.HttpManager |
| | | import com.dollearn.student.network.entity.Week |
| | | import com.dollearn.student.network.request |
| | |
| | | } |
| | | |
| | | weekAdapter.setOnItemClickListener { view, position -> |
| | | startActivity<ScheduleActivity>("week" to weeks[position].week,"season" to seasonAdapter.checked+1) |
| | | if (weeks[position].canStudy) |
| | | startActivity<ScheduleActivity>("week" to weeks[position].week,"season" to seasonAdapter.checked+1) |
| | | else{ |
| | | val msg = if (seasonAdapter.checked == 0||weeks[0].canStudy) "请先完成上一周目学习后再试" else "请先完成上一季度学习后再试" |
| | | val tipDialog = TipDialog() |
| | | tipDialog.arguments = bundleOf("msg" to msg,"isAlert" to true) |
| | | tipDialog.showAllowingStateLoss(supportFragmentManager,"noStart") |
| | | } |
| | | } |
| | | } |
| | | |
| | | override fun initView() { |
| | | rv_season.layoutManager = LinearLayoutManager(this) |
| | | rv_season.adapter = seasonAdapter |
| | | |
| | | rv_week.layoutManager = GridLayoutManager(this,3) |
| | | rv_week.adapter = weekAdapter |
| | | getWeeks() |
| | | } |
| | | |
| | | private fun getWeeks(){ |
| | |
| | | weekAdapter.notifyDataSetChanged() |
| | | } |
| | | } |
| | | |
| | | override fun onResume() { |
| | | super.onResume() |
| | | getWeeks() |
| | | } |
| | | } |