lmw
2023-06-13 adf8013576cbdd12e5ebea8ff7e32baf5d558b27
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
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)
            }
        }
    }
}