Commit 321ba848 authored by mengcuiguang2's avatar mengcuiguang2

代码优化

parent 90a5925b
......@@ -57,115 +57,20 @@ class VipAdapter(val vipList: MutableList<VipBean.ListBean>) :
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
val vipBean = vipList[position]
if (vipBean.trial != 0) {
holder.tvVipItemLable.setPadding(0, 0, 0, 0)
holder.tvVipItemLable.text = "限时特惠"
holder.tvVipItemLable.gravity = Gravity.CENTER
holder.tvVipItemLable.setBackgroundResource(R.mipmap.ic_vip_lable)
} else {
holder.tvVipItemLable.setPadding(0, 0, 0, 0)
holder.tvVipItemLable.text = "热门"
holder.tvVipItemLable.gravity = Gravity.CENTER
holder.tvVipItemLable.setBackgroundResource(R.mipmap.ic_vip_lable)
}
// try {
// if(!TextUtils.isEmpty(vipBean.topTitle)){
//
// val topArray= vipBean.topTitle.split(",")
// holder.tvVipItemCurMoney.text = SpanUtils()
// .append(topArray[0])
// .append(topArray[1])
// .setFontSize(BubbleUtils.sp2px(28))
// .append(topArray[2])
// .create()
// holder.tvVipItemMoney.text = topArray[3]
// holder.tvVipItemTitle.text = topArray[4]
// }else{
// holder.tvVipItemTitle.text = vipBean.title
// if (vipBean.price < 1) {
// holder.tvVipItemCurMoney.text = "¥${vipBean.price}"
// } else {
// holder.tvVipItemCurMoney.text = "¥${vipBean.price}"
//// holder.tvVipItemCurMoney.text = "¥${String.format("%.0f", vipBean.price)}"
// }
// if (vipBean.oldPrice > 0) {
// holder.tvVipItemMoney.visibility = View.VISIBLE
// holder.tvVipItemMoney.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG) //中间横线(删除线)
// if (vipBean.oldPrice < 1) {
// holder.tvVipItemMoney.text = "原价:${vipBean.oldPrice}"
// } else {
// holder.tvVipItemMoney.text = "原价:${String.format("%.0f", vipBean.oldPrice)}"
// }
// } else {
// holder.tvVipItemMoney.visibility = View.INVISIBLE
// }
//
// }
// }catch (e:Exception){
// e.printStackTrace()
holder.tvVipItemTitle.text = vipBean.title
// if (vipBean.price < 1) {
// holder.tvVipItemCurMoney.text = "¥${vipBean.price}"
// } else {
// holder.tvVipItemCurMoney.text = "¥${vipBean.price}"
//// holder.tvVipItemCurMoney.text = "¥${String.format("%.0f", vipBean.price)}"
// }
if (vipBean.payToModel == 2) {
// 跳转小程序领券
holder.tvVipItemCurMoney.text = SpanUtils()
.append(vipBean.oldPrice.toFloat().toString())
// .setFontSize(BubbleUtils.sp2px(34))
.append(" 元\n")
.setFontSize(BubbleUtils.sp2px(14))
.append("原价:" + vipBean.price.toFloat().toString() + " 元")
.setFontSize(BubbleUtils.sp2px(12))
.setStrikethrough()
.create()
} else {
if (vipBean.price == 0.0) {
holder.tvVipItemCurMoney.text = SpanUtils()
.append("0.01")
// .setFontSize(BubbleUtils.sp2px(34))
.append("元")
.setFontSize(BubbleUtils.sp2px(14))
.create()
} else {
holder.tvVipItemCurMoney.text = SpanUtils()
.append(vipBean.price.toString())
// .setFontSize(BubbleUtils.sp2px(34))
.append("元")
.setFontSize(BubbleUtils.sp2px(14))
.create()
}
}
// if (vipBean.oldPrice > 0) {
// holder.tvVipItemMoney.visibility = View.VISIBLE
// holder.tvVipItemMoney.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG) //中间横线(删除线)
// if (vipBean.oldPrice < 1) {
// holder.tvVipItemMoney.text = "原价:${vipBean.oldPrice}"
// } else {
// holder.tvVipItemMoney.text = "原价:${String.format("%.0f", vipBean.oldPrice)}"
// }
// } else {
// holder.tvVipItemMoney.visibility = View.INVISIBLE
// }
// }
// holder.tvVipItemMoney.text = vipBean.topTitle
try {
if (!TextUtils.isEmpty(vipBean.topTitle)) {
val topArray = vipBean.topTitle.split(",")
if (topArray != null && topArray.size > 0) {
holder.tvVipItemLable.text = topArray[0] ?: ""
holder.tvVipItemCurMoney.text = topArray[1] ?: ""
holder.tvVipItemMoney.text = topArray[2] ?: ""
holder.tvVipItemTitle.text = topArray[3] ?: ""
}
holder.tvVipItemLable.visibility=View.VISIBLE
holder.tvVipItemLable.text = topArray[0]
holder.tvVipItemMoney.text = topArray[1]
holder.tvVipItemCurMoney.text = topArray[2]
holder.tvVipItemTitle.text = topArray[3]
}else{
holder.tvVipItemLable.visibility=View.GONE
}
}else{
holder.tvVipItemLable.visibility=View.GONE
}
} catch (e:Exception) {
e.printStackTrace()
......
......@@ -3,7 +3,7 @@
android:shape="rectangle">
<!-- 填充的颜色 -->
<stroke android:width="2dp" android:color="#EFBC6A" />
<solid android:color="@color/black" />
<solid android:color="#282d34" />
<!-- 设置按钮的四个角为弧形 -->
<!-- android:radius 弧形的半径 -->
<corners android:radius="10dip" />
......
......@@ -3,7 +3,7 @@
android:shape="rectangle">
<!-- 填充的颜色 -->
<solid android:color="@color/black" />
<solid android:color="#282d34" />
<!-- 设置按钮的四个角为弧形 -->
<!-- android:radius 弧形的半径 -->
<corners android:radius="10dip" />
......
......@@ -52,7 +52,7 @@
android:layout_marginTop="10dp"
android:layout_marginBottom="16dp"
android:textColor="#939AA3"
android:textSize="14sp"
android:textSize="15sp"
tools:text="原价:123" />
</LinearLayout>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment