package com.igo.user.ui.trip
|
|
import android.widget.LinearLayout
|
import android.widget.TextView
|
import androidx.core.view.isVisible
|
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.RecyclerView
|
import cn.sinata.xldutils.gone
|
import cn.sinata.xldutils.utils.LanguageUtil
|
import cn.sinata.xldutils.visible
|
import com.igo.user.R
|
import com.igo.user.network.entity.Order
|
import com.igo.user.ui.ShowPictureActivity
|
import com.igo.user.ui.TransparentStatusBarActivity
|
import com.igo.user.ui.trip.adapter.ExpressPictureAdapter
|
import com.igo.user.utils.Const
|
import com.igo.user.utils.showMoney
|
import org.jetbrains.anko.find
|
|
class PriceDetailActivity : TransparentStatusBarActivity() {
|
override fun setContentView() = R.layout.activity_price_detail
|
|
private val order by lazy {
|
intent.getParcelableExtra<Order>("order")!!
|
}
|
private val pickupAdapter by lazy { ExpressPictureAdapter(ArrayList<String>()) }
|
private val deliveryAdapter by lazy { ExpressPictureAdapter(ArrayList<String>()) }
|
override fun initClick() {
|
}
|
private val tv_total by lazy { find<TextView>(R.id.tv_total) }
|
private val tv_price_by_platform by lazy { find<TextView>(R.id.tv_price_by_platform) }
|
private val ll_detail by lazy { find<LinearLayout>(R.id.ll_detail) }
|
private val ll_pickup_picture by lazy { find<LinearLayout>(R.id.ll_pickup_picture) }
|
private val rv_pickup by lazy { find<RecyclerView>(R.id.rv_pickup) }
|
private val ll_delivery_picture by lazy { find<LinearLayout>(R.id.ll_delivery_picture) }
|
private val rv_delivery by lazy { find<RecyclerView>(R.id.rv_delivery) }
|
override fun initView() {
|
title = getString(R.string.费用明细)
|
tv_total.text = getString(R.string.money_is, if (order.state == 7) order.orderMoney else order.payMoney).replace(",",".")
|
if (order.orderType != Const.OrderType.TYPE_TAXI) {
|
if (order.isDispute == 1){
|
tv_price_by_platform.visible()
|
tv_price_by_platform.text = getString(R.string.争议订单协商价格).format(order.orderMoney)
|
}else
|
tv_price_by_platform.gone()
|
// if (order.startMoney!=0.0){
|
val view1 = layoutInflater.inflate(R.layout.item_price_detail, null)
|
val tv_name = view1.find<TextView>(R.id.tv_name)
|
val tv_price = view1.find<TextView>(R.id.tv_price)
|
tv_name.text = getString(R.string.起步价及公里数,order.startMileage,order.startDuration).replace(",",".")
|
tv_price.text = order.startMoney.showMoney(this)
|
ll_detail.addView(view1)
|
// }
|
// if (order.mileageMoney!=0.0){
|
val view3 = layoutInflater.inflate(R.layout.item_price_detail, null)
|
val tv_name3 = view3.find<TextView>(R.id.tv_name)
|
val tv_price3 = view3.find<TextView>(R.id.tv_price)
|
tv_name3.text = getString(R.string.里程费及公里数,order.mileage).replace(",",".")
|
tv_price3.text = order.mileageMoney.showMoney(this)
|
ll_detail.addView(view3)
|
// }
|
// if (order.durationMoney!=0.0){
|
/* val view2 = layoutInflater.inflate(R.layout.item_price_detail, null)
|
val tv_name2 = view2.find<TextView>(R.id.tv_name)
|
val tv_price2 = view2.find<TextView>(R.id.tv_price)
|
tv_name2.text = getString(R.string.时长费及时长分钟,order.duration)
|
tv_price2.text = order.durationMoney.showMoney(this)
|
ll_detail.addView(view2)*/
|
// }
|
// if (order.waitMoney!=0.0){
|
/* val view4 = layoutInflater.inflate(R.layout.item_price_detail, null)
|
val tv_name4 = view4.find<TextView>(R.id.tv_name)
|
val tv_price4 = view4.find<TextView>(R.id.tv_price)
|
tv_name4.text = getString(R.string.等待费,order.wait)
|
tv_price4.text = order.waitMoney.showMoney(this)
|
ll_detail.addView(view4)*/
|
// }
|
if (order.parkMoney != 0.0) {
|
val view5 = layoutInflater.inflate(R.layout.item_price_detail, null)
|
val tv_name5 = view5.find<TextView>(R.id.tv_name)
|
val tv_price5 = view5.find<TextView>(R.id.tv_price)
|
tv_name5.text = getString(R.string.停车费)
|
tv_price5.text = order.parkMoney.showMoney(this)
|
ll_detail.addView(view5)
|
}
|
if (order.roadTollMoney != 0.0) {
|
val view = layoutInflater.inflate(R.layout.item_price_detail, null)
|
val tv_name = view.find<TextView>(R.id.tv_name)
|
val tv_price = view.find<TextView>(R.id.tv_price)
|
tv_name.text = getString(R.string.过路费)
|
tv_price.text = order.roadTollMoney.showMoney(this)
|
ll_detail.addView(view)
|
}
|
if (order.longDistanceMoney!=0.0){
|
val view = layoutInflater.inflate(R.layout.item_price_detail, null)
|
val tv_name = view.find<TextView>(R.id.tv_name)
|
val tv_price = view.find<TextView>(R.id.tv_price)
|
tv_name.text = getString(R.string.远途费及公里数,order.longDistance).replace(",",".")
|
tv_price.text = order.longDistanceMoney.showMoney(this)
|
ll_detail.addView(view)
|
}
|
// if (
|
// order.travelMoney!=0.0&& order.moneyType!=1
|
// ){
|
// val view7 = layoutInflater.inflate(R.layout.item_price_detail, null)
|
// view7.tv_name.text = String.format("%s(%s,%s)",if(order.moneyType == 2) "夜间行驶费" else "高峰期费",order.moneyTime,getString(
|
// R.string.全程公里).format(order.longDistance).replace(",","."))
|
// view7.tv_price.text = order.travelMoney.showMoney(this)
|
// ll_detail.addView(view7)
|
// }
|
|
if (order.redPacketMoney != 0.0) {
|
val view = layoutInflater.inflate(R.layout.item_price_detail, null)
|
val tv_name = view.find<TextView>(R.id.tv_name)
|
val tv_price = view.find<TextView>(R.id.tv_price)
|
tv_name.text = getString(R.string.红包抵扣)
|
tv_price.text = "-"+order.redPacketMoney.showMoney(this)
|
ll_detail.addView(view)
|
}
|
if (order.couponMoney != 0.0) {
|
val view = layoutInflater.inflate(R.layout.item_price_detail, null)
|
val tv_name = view.find<TextView>(R.id.tv_name)
|
val tv_price = view.find<TextView>(R.id.tv_price)
|
tv_name.text = getString(R.string.优惠券)
|
tv_price.text = "-"+order.couponMoney.showMoney(this)
|
ll_detail.addView(view)
|
}
|
if (order.discountMoney != 0.0) {
|
val view = layoutInflater.inflate(R.layout.item_price_detail, null)
|
val tv_name = view.find<TextView>(R.id.tv_name)
|
val tv_price = view.find<TextView>(R.id.tv_price)
|
tv_name.text = getString(R.string.活动折扣)
|
tv_price.text = "-"+order.discountMoney.showMoney(this)
|
ll_detail.addView(view)
|
}
|
if (order.discount!=0.0){
|
val view1 = layoutInflater.inflate(R.layout.item_price_detail, null)
|
val tv_name1 = view1.find<TextView>(R.id.tv_name)
|
val tv_price1 = view1.find<TextView>(R.id.tv_price)
|
tv_name1.text = getString(R.string.活动折扣)
|
val language = LanguageUtil.getLanguage()
|
tv_price1.text = when(language){
|
Const.Language.ENGLISH->"${100-(order.discount*10).toInt()}%"
|
Const.Language.CHINESE->"${order.discount}折"
|
else->"${100-(order.discount*10).toInt()}%"
|
}
|
ll_detail.addView(view1)
|
}
|
if (order.priceDifference != 0.0) {
|
val view = layoutInflater.inflate(R.layout.item_price_detail, null)
|
val tv_name = view.find<TextView>(R.id.tv_name)
|
val tv_price = view.find<TextView>(R.id.tv_price)
|
tv_name.text = getString(R.string.差价)
|
tv_price.text = order.priceDifference.showMoney(this)
|
ll_detail.addView(view)
|
}
|
rv_pickup.adapter = pickupAdapter
|
rv_pickup.layoutManager = LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false)
|
rv_delivery.adapter = deliveryAdapter
|
rv_delivery.layoutManager = LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false)
|
|
ll_pickup_picture.isVisible = !order.imgOne.isNullOrEmpty()
|
pickupAdapter.mData = ArrayList<String>().apply { addAll(order.getPickupPictures()) }
|
ll_delivery_picture.isVisible = !order.imgTwo.isNullOrEmpty()
|
deliveryAdapter.mData = ArrayList<String>().apply { addAll(order.getDeliveryPictures()) }
|
}
|
pickupAdapter.setOnItemClickListener { _, position ->
|
startActivity(
|
ShowPictureActivity.getIntent(
|
this,
|
"",
|
ArrayList<String>().apply { addAll(pickupAdapter.mData) },
|
position
|
)
|
)
|
}
|
deliveryAdapter.setOnItemClickListener { _, position ->
|
startActivity(
|
ShowPictureActivity.getIntent(
|
this,
|
"",
|
ArrayList<String>().apply { addAll(deliveryAdapter.mData) },
|
position
|
)
|
)
|
}
|
}
|
}
|