package com.kuanzhai.user.ui.menu
|
|
import androidx.recyclerview.widget.LinearLayoutManager
|
import cn.sinata.xldutils.callPhone
|
import cn.sinata.xldutils.clickDelay
|
import cn.sinata.xldutils.fragment.BaseFragment
|
import cn.sinata.xldutils.utils.SpanBuilder
|
import cn.sinata.xldutils.visible
|
import com.kuanzhai.user.R
|
import com.kuanzhai.user.ui.menu.adapter.LinearImageAdapter
|
import com.luck.picture.lib.PictureVideoPlayActivity
|
import kotlinx.android.synthetic.main.fragment_rent_car_info.*
|
import org.jetbrains.anko.support.v4.startActivity
|
|
class RentInfoFragment : BaseFragment() {
|
override fun contentViewId() = R.layout.fragment_rent_car_info
|
|
private val describeImgs = arrayListOf<String>()
|
private val imgAdapter = LinearImageAdapter(describeImgs)
|
|
override fun onFirstVisibleToUser() {
|
rv_img.layoutManager = LinearLayoutManager(requireContext())
|
rv_img.adapter = imgAdapter
|
refreshUi()
|
}
|
|
fun refreshUi(){
|
(activity as RentCarDetailActivity).order?.apply {
|
tv_title.text = title
|
val price = "租金:${rentMoney}元/天"
|
tv_price.text = SpanBuilder(price).color(requireContext(),3,price.length,R.color.colorRed).build()
|
val ya = "押金:${deposit}元"
|
tv_ya.text = SpanBuilder(ya).color(requireContext(),3,ya.length,R.color.colorRed).build()
|
val brand = "车辆品牌:${brandName}"
|
tv_brand.text = SpanBuilder(brand).color(requireContext(),5,brand.length,R.color.textColor).build()
|
val seats = "座位:${seat}"
|
tv_seat.text = SpanBuilder(seats).color(requireContext(),3,seats.length,R.color.textColor).build()
|
val pai = "排量:${displacement}"
|
tv_pai.text = SpanBuilder(pai).color(requireContext(),3,pai.length,R.color.textColor).build()
|
val dang = "挡位:${gear}"
|
tv_dang.text = SpanBuilder(dang).color(requireContext(),3,dang.length,R.color.textColor).build()
|
val license = "取车证件:${pickUpCarCarCertificates}"
|
tv_license.text = SpanBuilder(license).color(requireContext(),5,license.length,R.color.textColor).build()
|
val name = "联系人:${contactsName}"
|
tv_name.text = SpanBuilder(name).color(requireContext(),4,name.length,R.color.textColor).build()
|
if (isAuth == "2"||userType == 2) tv_verified.visible()
|
|
val address = "联系地址:${provinceName}${cityName}${addres}"
|
tv_address.text = SpanBuilder(address).color(requireContext(),5,address.length,R.color.textColor).build()
|
tv_describe.text = describe
|
// if (videoUrl.isNullOrEmpty()){
|
// iv_video.gone()
|
// iv_play.gone()
|
// }else
|
// Thread{
|
// val f = FileUtils.createVideoThumbnail(videoUrl)
|
// runOnUiThread {
|
// if (!isDetached)
|
// iv_video.setImageBitmap(f)
|
// }
|
// }.start()
|
describeImgs.clear()
|
describeImgs.addAll(describeImgUrl.split(",").filter { it.isNotEmpty() })
|
imgAdapter.notifyDataSetChanged()
|
|
tv_call.clickDelay {
|
callPhone(contactsPhone)
|
}
|
iv_video.setOnClickListener {
|
startActivity<PictureVideoPlayActivity>("videoPath" to (videoUrl?:""),"isExternalPreviewVideo" to true)
|
}
|
}
|
}
|
}
|