package com.igo.user.ui.trip
|
|
import android.widget.TextView
|
import androidx.recyclerview.widget.LinearLayoutManager
|
import cn.sinata.xldutils.utils.hideIdCard
|
import cn.sinata.xldutils.view.SwipeRefreshRecyclerLayout
|
import com.facebook.drawee.view.SimpleDraweeView
|
import com.igo.user.R
|
import com.igo.user.network.HttpManager
|
import com.igo.user.network.entity.Evaluation
|
import com.igo.user.network.request
|
import com.igo.user.ui.TransparentStatusBarActivity
|
import com.igo.user.ui.trip.adapter.EvaluateAdapter
|
import org.jetbrains.anko.find
|
|
class DriverDetailActivity : TransparentStatusBarActivity() {
|
override fun setContentView() = R.layout.activity_driver_detail
|
|
private val datas = arrayListOf<Evaluation>()
|
private val adapter by lazy {
|
EvaluateAdapter(datas)
|
}
|
|
override fun initClick() {
|
}
|
private val lv_list by lazy { find<SwipeRefreshRecyclerLayout>(R.id.lv_list) }
|
private val iv_head by lazy { find<SimpleDraweeView>(R.id.iv_head) }
|
private val tv_name by lazy { find<TextView>(R.id.tv_name) }
|
private val tv_car_num by lazy { find<TextView>(R.id.tv_car_num) }
|
private val tv_id_card by lazy { find<TextView>(R.id.tv_id_card) }
|
private val tv_score by lazy { find<TextView>(R.id.tv_score) }
|
private val tv_count by lazy { find<TextView>(R.id.tv_count) }
|
|
override fun initView() {
|
title = getString(R.string.司机主页)
|
lv_list.setMode(SwipeRefreshRecyclerLayout.Mode.Both)
|
lv_list.setLayoutManager(LinearLayoutManager(this,LinearLayoutManager.VERTICAL,false))
|
lv_list.setOnRefreshListener(object :SwipeRefreshRecyclerLayout.OnRefreshListener{
|
override fun onRefresh() {
|
page = 1
|
getEvaluation()
|
}
|
|
override fun onLoadMore() {
|
page++
|
getEvaluation()
|
}
|
})
|
lv_list.setAdapter(adapter)
|
getData()
|
getEvaluation()
|
}
|
|
private val id by lazy {
|
intent.getIntExtra("id",0)
|
}
|
|
private fun getData(){
|
HttpManager.queryDriverInfo(id).request(this){ _, data->
|
data?.run {
|
iv_head.setImageURI(avatar)
|
tv_name.text = name
|
tv_car_num.text = String.format("%s %s",licensePlate,brand)
|
tv_id_card.text = getString(R.string.身份证号)+":"+idcode.hideIdCard()
|
tv_score.text = String.format("%.1f",fraction)
|
tv_count.text = orderNum.toString()
|
}
|
}
|
}
|
|
private var page = 1
|
private fun getEvaluation(){
|
HttpManager.queryDriverEvaluate(id, page).request(this,success = {_,data->
|
data?.run {
|
lv_list.isRefreshing = false
|
if (page == 1)
|
datas.clear()
|
datas.addAll(this)
|
adapter.notifyDataSetChanged()
|
if (datas.isEmpty()){
|
lv_list.setLoadMoreText(getString(R.string.暂无数据))
|
}
|
}
|
},error = {_,_->
|
lv_list.isRefreshing = false
|
})
|
}
|
}
|