package com.dollearn.student.ui.course
|
|
import android.view.View
|
import androidx.recyclerview.widget.LinearLayoutManager
|
import com.dollearn.student.R
|
import com.dollearn.student.network.HttpManager
|
import com.dollearn.student.network.entity.Evaluation
|
import com.dollearn.student.network.request
|
import com.dollearn.student.ui.TransparentStatusBarActivity
|
import com.dollearn.student.ui.course.adapter.EvaluationAdapter
|
import kotlinx.android.synthetic.main.layout_common_list.*
|
|
class EvaluationActivity : TransparentStatusBarActivity() {
|
override fun setContentView() = R.layout.layout_common_list
|
|
private val stuId by lazy { intent.getStringExtra("stuId")?:"" }
|
private val list = arrayListOf<Evaluation>()
|
private val adapter = EvaluationAdapter(list)
|
override fun initClick() {
|
}
|
|
override fun initView() {
|
rv_list.layoutManager = LinearLayoutManager(this)
|
rv_list.adapter = adapter
|
refreshLayout.setEnableLoadMore(false)
|
refreshLayout.setOnRefreshListener {
|
getEvaluations()
|
}
|
getEvaluations()
|
}
|
|
private fun getEvaluations(){
|
HttpManager.stuComment(stuId).request(this,success = { _, data->
|
refreshLayout.finishRefresh(true)
|
list.clear()
|
list.addAll(data?: arrayListOf())
|
adapter.notifyDataSetChanged()
|
tv_empty.visibility = if (list.isEmpty()) View.VISIBLE else View.GONE
|
}){_,_->
|
refreshLayout.finishRefresh(false)
|
}
|
}
|
}
|