lmw
2024-06-17 f571288a24fcf10143dcc8015ffbbf38dbc0c614
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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)
        }
    }
}