|
|
package com.br_technology.securitytrain_master.ui.view.mine.activity
|
|
|
|
|
|
import android.content.Intent
|
|
|
import com.br_technology.securitytrain_master.R
|
|
|
import com.br_technology.securitytrain_master.databinding.ActivityMyCredentialsBinding
|
|
|
import com.br_technology.securitytrain_master.expand.addItemDecoration2
|
|
|
import com.br_technology.securitytrain_master.expand.dp2px
|
|
|
import com.br_technology.securitytrain_master.ui.bean.UserCert
|
|
|
import com.br_technology.securitytrain_master.ui.view.home.bean.RecommendData
|
|
|
import com.br_technology.securitytrain_master.ui.view.mine.adapter.MyCredentialsAdapter
|
|
|
import com.br_technology.securitytrain_master.ui.view.mine.viewmodel.MyCredentialsViewModel
|
...
|
...
|
@@ -21,43 +23,59 @@ class MyCredentialsActivity : |
|
|
BaseLifeCycleActivity<MyCredentialsViewModel, ActivityMyCredentialsBinding>(
|
|
|
ActivityMyCredentialsBinding::inflate
|
|
|
) {
|
|
|
private val adapter: MyCredentialsAdapter by lazy {
|
|
|
MyCredentialsAdapter()
|
|
|
}
|
|
|
private var page: Int = 1
|
|
|
override fun initDataObserver() {
|
|
|
|
|
|
mViewModel.liveData.observe(this) {
|
|
|
if (it.data.list.data.size < 10) {
|
|
|
binding.smartRefresh.setNoMoreData(true)
|
|
|
}
|
|
|
if (page == 1) {
|
|
|
adapter.addListClear(it.data.list.data)
|
|
|
} else {
|
|
|
adapter.addList(it.data.list.data)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
override fun initData() {
|
|
|
super.initData()
|
|
|
|
|
|
|
|
|
binding.apply {
|
|
|
recyclerview.addItemDecoration2(2, 8.dp2px(), 16.dp2px())
|
|
|
val recommendList = mutableListOf(
|
|
|
RecommendData(
|
|
|
R.mipmap.card_back,
|
|
|
"思维",
|
|
|
"从这个角度"
|
|
|
),
|
|
|
RecommendData(
|
|
|
R.mipmap.card_back,
|
|
|
"思维",
|
|
|
"从这个角度"
|
|
|
),
|
|
|
RecommendData(
|
|
|
R.mipmap.card_back,
|
|
|
"思维",
|
|
|
"从这个角度"
|
|
|
),
|
|
|
)
|
|
|
val myCredentialsAdapter = MyCredentialsAdapter()
|
|
|
myCredentialsAdapter.addListener(object : OnItemClickListener<RecommendData> {
|
|
|
override fun onClick(position: Int, data: RecommendData) {
|
|
|
// 根据类型跳转
|
|
|
CenterToast(this@MyCredentialsActivity).setTitle("上传成功").show()
|
|
|
smartRefresh.setOnRefreshListener {
|
|
|
smartRefresh.setNoMoreData(false)
|
|
|
page = 1
|
|
|
mViewModel.certList(page)
|
|
|
smartRefresh.finishRefresh()
|
|
|
}
|
|
|
smartRefresh.setOnLoadMoreListener {
|
|
|
++page
|
|
|
mViewModel.certList(page)
|
|
|
smartRefresh.finishLoadMore()
|
|
|
}
|
|
|
|
|
|
recyclerview.addItemDecoration2(2, 8.dp2px(), 16.dp2px())
|
|
|
adapter.addListener(object : OnItemClickListener<UserCert> {
|
|
|
override fun onClick(position: Int, data: UserCert) {
|
|
|
val intent = Intent(baseContext, MyCredentialsDetailActivity::class.java)
|
|
|
intent.putExtra("id", data.id)
|
|
|
startActivity(intent)
|
|
|
}
|
|
|
})
|
|
|
|
|
|
|
|
|
recyclerview.adapter = myCredentialsAdapter
|
|
|
myCredentialsAdapter.addList(recommendList)
|
|
|
adapter.setAddCertListener {
|
|
|
// 添加
|
|
|
startActivity(CredentialsUpLoadActivity::class.java)
|
|
|
}
|
|
|
recyclerview.adapter = adapter
|
|
|
}
|
|
|
}
|
|
|
|
|
|
override fun onResume() {
|
|
|
super.onResume()
|
|
|
binding.smartRefresh.autoRefresh()
|
|
|
}
|
|
|
} |
|
|
\ No newline at end of file |
...
|
...
|
|