...
|
...
|
@@ -7,10 +7,14 @@ import com.br_technology.securitytrain_master.databinding.FragmentSpecialExercis |
|
|
import com.br_technology.securitytrain_master.expand.addItemDecorationCustom
|
|
|
import com.br_technology.securitytrain_master.ui.bean.AnswerRecord
|
|
|
import com.br_technology.securitytrain_master.ui.view.bank.activity.AnswerRecordDetailsActivity
|
|
|
import com.br_technology.securitytrain_master.ui.view.bank.event.ExcerSize
|
|
|
import com.br_technology.securitytrain_master.ui.view.mine.adapter.SpecialExercisesAdapter
|
|
|
import com.br_technology.securitytrain_master.ui.view.mine.viewmodel.SpecialExercisesFragmentViewModel
|
|
|
import com.br_technology.securitytrain_master.util.TranslateUnit
|
|
|
import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleFragment
|
|
|
import org.greenrobot.eventbus.EventBus
|
|
|
import org.greenrobot.eventbus.Subscribe
|
|
|
import org.greenrobot.eventbus.ThreadMode
|
|
|
import kotlin.properties.Delegates
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -24,14 +28,22 @@ class SpecialExercisesFragment |
|
|
FragmentSpecialExercisesBinding::inflate
|
|
|
) {
|
|
|
|
|
|
|
|
|
private var page = 1
|
|
|
private var type by Delegates.notNull<Int>()
|
|
|
private val exercisesAdapter: SpecialExercisesAdapter by lazy {
|
|
|
SpecialExercisesAdapter()
|
|
|
}
|
|
|
|
|
|
private val map = hashMapOf(1 to true, 2 to true, 3 to true, 4 to true)
|
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
|
super.onCreate(savedInstanceState)
|
|
|
EventBus.getDefault().register(this)
|
|
|
}
|
|
|
|
|
|
override fun onDestroy() {
|
|
|
super.onDestroy()
|
|
|
EventBus.getDefault().unregister(this)
|
|
|
}
|
|
|
|
|
|
override fun initDataObserver() {
|
|
|
mViewModel.liveData.observe(this) {
|
|
|
binding.smartRefresh.finishRefresh()
|
...
|
...
|
@@ -69,7 +81,7 @@ class SpecialExercisesFragment |
|
|
loadMore()
|
|
|
}
|
|
|
recyclerview.adapter = exercisesAdapter
|
|
|
exercisesAdapter.setOnItemClickListener { adapter, view, position ->
|
|
|
exercisesAdapter.setOnItemClickListener { _, _, position ->
|
|
|
val intent = Intent(requireContext(), AnswerRecordDetailsActivity::class.java)
|
|
|
intent.putExtra("id", exercisesAdapter.data[position].id)
|
|
|
startActivity(intent)
|
...
|
...
|
@@ -85,15 +97,22 @@ class SpecialExercisesFragment |
|
|
binding.smartRefresh.setEnableLoadMore(false)
|
|
|
}
|
|
|
|
|
|
private fun loadMore(){
|
|
|
++page
|
|
|
@Subscribe(threadMode = ThreadMode.MAIN)
|
|
|
fun onRankListEvent(event: ExcerSize?) {
|
|
|
if (event?.type == type) {
|
|
|
refresh()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private fun loadMore() {
|
|
|
page += 1
|
|
|
mViewModel.errorSubList(type, page)
|
|
|
binding.smartRefresh.setEnableRefresh(false)
|
|
|
binding.smartRefresh.setEnableLoadMore(false)
|
|
|
}
|
|
|
|
|
|
override fun onResume() {
|
|
|
super.onResume()
|
|
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
|
|
super.onViewCreated(view, savedInstanceState)
|
|
|
refresh()
|
|
|
}
|
|
|
|
...
|
...
|
|