Commit 2693685b authored by jyx's avatar jyx

更新vip页面样式

parent de66b7fb
......@@ -10,8 +10,8 @@ android {
applicationId "com.duben.infinitefunjia"
minSdkVersion rootProject.ext.androidMinSdkVersion
targetSdkVersion rootProject.ext.androidTargetSdkVersion
versionCode 728
versionName "7.2.8"
versionCode 729
versionName "7.2.9"
flavorDimensions "default"
// dex突破65535的限制
......
......@@ -24,6 +24,7 @@ public class VipBean implements Serializable {
private boolean showCycTips;// 判断是否提示
private double firstPayPrice;
private double oldPrice;
private double firstPayPriceAfterBack;
private int days;
private int trial;//是否签约 0-没签约 1-签约
private int trialFirstDay;
......@@ -41,6 +42,13 @@ public class VipBean implements Serializable {
//带uid转支付宝小程序 挽留用的第二个小程序
private String payToModel2SecondAlipayAppid;
public double getFirstPayPriceAfterBack() {
return firstPayPriceAfterBack;
}
public void setFirstPayPriceAfterBack(double firstPayPriceAfterBack) {
this.firstPayPriceAfterBack = firstPayPriceAfterBack;
}
public String getButtonText() {
return buttonText;
......
......@@ -2,6 +2,7 @@ package com.duben.infinitefunjia.ui.activitys
import android.animation.ValueAnimator
import android.app.Dialog
import android.content.Context
import android.content.Intent
import android.graphics.Color
import android.net.Uri
......@@ -9,9 +10,11 @@ import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.text.TextUtils
import android.util.DisplayMetrics
import android.util.Log
import android.view.KeyEvent
import android.view.View
import android.view.WindowManager
import android.widget.CompoundButton
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager
......@@ -407,8 +410,9 @@ class VipActivity : BaseActivity(), VipView, View.OnClickListener,
private fun initRvView() {
if (vipList != null && vipList!!.size > 0) {
val gridLayoutManager = LinearLayoutManager(this)
rvVip.layoutManager = gridLayoutManager
val linearLayoutManager = LinearLayoutManager(this)
linearLayoutManager.orientation = LinearLayoutManager.HORIZONTAL
rvVip.layoutManager = linearLayoutManager
vipAdapter = VipAdapter(vipList!!)
rvVip.adapter = vipAdapter
vipAdapter.setOnItemClickListener(this)
......@@ -430,16 +434,38 @@ class VipActivity : BaseActivity(), VipView, View.OnClickListener,
cbVipAgreement.setOnCheckedChangeListener(this)
}
override fun onItemClick(position: Int) {
override fun onItemClick(position: Int, view: View) {
vipAdapter.setPosition(position)
vipAdapter.notifyDataSetChanged()
//设置content样式
if (vipList != null && vipList!!.size > 0) {
setVipContent(vipList!![position])
if (vipList!!.size > 2) {
if (position > 1 && position < vipList!!.size - 2) {
moveToCenter(view);
} else if (position in 0..1) {
rvVip.smoothScrollToPosition(0);
} else {
rvVip.smoothScrollToPosition(vipList!!.size - 1);
}
}
}
}
private fun moveToCenter(itemView: View) {
val locationView = IntArray(2)
itemView.getLocationOnScreen(locationView)
val viewWidth = itemView.width
val wm = getSystemService(Context.WINDOW_SERVICE) as WindowManager
val dm = DisplayMetrics()
wm.defaultDisplay.getMetrics(dm)
val centerX = dm.widthPixels / 2
val distance = locationView[0] - centerX + viewWidth / 2
rvVip.smoothScrollBy(distance, 0)
}
fun wxPay(wxParanBean: WxPayParamBean, payToModel: Int) {
if (payToModel == 1) {
// 纯签约
......
package com.duben.infinitefunjia.ui.adapter
import android.content.Context
import android.view.Gravity
import android.graphics.Color
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
......@@ -12,8 +12,9 @@ import com.duben.infinitefunjia.R
import com.duben.infinitefunjia.mvp.model.VipBean
import com.duben.infinitefunjia.utils.BubbleUtils
import com.duben.infinitefunjia.utils.SpanUtils
import com.duben.infinitefunjia.utils.UIUtils
class VipAdapter(val vipList: MutableList<VipBean.ListBean>) :
class VipAdapter(private val vipList: MutableList<VipBean.ListBean>) :
RecyclerView.Adapter<VipAdapter.ViewHolder>() {
var myPos: Int = 0
......@@ -22,8 +23,8 @@ class VipAdapter(val vipList: MutableList<VipBean.ListBean>) :
lateinit var mOnItemClickListener: OnItemClickListener
init {
if (vipList != null && vipList.size > 0) {
for (i in 0..vipList.size - 1) {
if (vipList.size > 0) {
for (i in 0 until vipList.size) {
if (vipList[i].activityType == 1) {
myPos = i
break
......@@ -35,6 +36,7 @@ class VipAdapter(val vipList: MutableList<VipBean.ListBean>) :
inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
val rlVipItemRoot: FrameLayout = view.findViewById(R.id.rlVipItemRoot)
val tvVipItemCurMoney: TextView = view.findViewById(R.id.tvVipItemCurMoney)
val tvVipItemOldMoney: TextView = view.findViewById(R.id.tvVipItemOldMoney)
val tvVipItemMoney: TextView = view.findViewById(R.id.tvVipItemMoney)
val tvVipItemTitle: TextView = view.findViewById(R.id.tvVipItemTitle)
val tvVipItemLable: TextView = view.findViewById(R.id.tvVipItemLable)
......@@ -43,127 +45,84 @@ class VipAdapter(val vipList: MutableList<VipBean.ListBean>) :
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
context = parent.context
val view = LayoutInflater.from(context).inflate(R.layout.item_rv_vip, parent, false)
val viewHolder = ViewHolder(view)
return viewHolder
return ViewHolder(view)
}
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.price==0.0){
holder.tvVipItemOldMoney.text = SpanUtils()
.append("原价 ")
.setFontSize(BubbleUtils.sp2px(10))
.setStrikethrough()
.append("" + vipBean.oldPrice)
.setFontSize(BubbleUtils.sp2px(12))
.setBold()
.setStrikethrough()
.create()
if (vipBean.firstPayPriceAfterBack == 0.0) {
holder.tvVipItemCurMoney.text = SpanUtils()
.append("免费试用")
.setFontSize(BubbleUtils.sp2px(34))
.append("¥")
.append("0")
.setFontSize(BubbleUtils.sp2px(36))
.create()
}else{
} else {
holder.tvVipItemCurMoney.text = SpanUtils()
.append(vipBean.price.toString())
.setFontSize(BubbleUtils.sp2px(34))
.append("元")
.append("¥")
.append(vipBean.firstPayPriceAfterBack.toString())
.setFontSize(BubbleUtils.sp2px(36))
.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
if (position == 0) {
val layoutParams = holder.rlVipItemRoot.layoutParams as FrameLayout.LayoutParams
layoutParams.width = UIUtils.dp2px(170)
holder.rlVipItemRoot.layoutParams = layoutParams
}
holder.rlVipItemRoot.setOnClickListener {
mOnItemClickListener.onItemClick(position)
mOnItemClickListener.onItemClick(position, it)
notifyDataSetChanged()
}
if (getPosition() == position) {
//当前选中
holder.rlVipItemRoot.setBackgroundResource(R.drawable.shape_vip_adapter)
// holder.tvVipItemCurMoney.setTextColor(
// ContextCompat.getColor(
// context,
// R.color.color_FD7E0E
// )
// )
holder.tvVipItemLable.visibility = View.VISIBLE
holder.tvVipItemTitle.setTextColor(Color.parseColor("#9C5200"))
holder.tvVipItemCurMoney.setTextColor(Color.parseColor("#7F4D14"))
holder.tvVipItemOldMoney.setTextColor(Color.parseColor("#B57924"))
holder.tvVipItemMoney.setTextColor(Color.parseColor("#673810"))
holder.tvVipItemMoney.setBackgroundResource(R.drawable.shape_vip_bottom_s)
} else {
holder.rlVipItemRoot.setBackgroundResource(R.drawable.shape_vip_adapter_none)
// holder.tvVipItemCurMoney.setTextColor(
// ContextCompat.getColor(
// context,
// R.color.white
// )
// )
holder.tvVipItemLable.visibility = View.GONE
holder.tvVipItemTitle.setTextColor(Color.WHITE)
holder.tvVipItemCurMoney.setTextColor(Color.WHITE)
holder.tvVipItemOldMoney.setTextColor(Color.parseColor("#85898A"))
holder.tvVipItemMoney.setTextColor(Color.parseColor("#B0B1B0"))
holder.tvVipItemMoney.setBackgroundResource(R.drawable.shape_vip_bottom)
}
holder.itemView.setTag(position)
holder.itemView.tag = position
}
override fun getItemCount() = vipList?.size
override fun getItemCount() = vipList.size
interface OnItemClickListener {
fun onItemClick(position: Int)
fun onItemClick(position: Int, view: View)
}
fun setOnItemClickListener(listener: OnItemClickListener) {
......
......@@ -2,10 +2,14 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<!-- 填充的颜色 -->
<stroke android:width="2dp" android:color="#EFBC6A" />
<solid android:color="#282d34" />
<!-- <stroke android:width="2dp" android:color="#EFBC6A" />-->
<!-- 填充的颜色 -->
<gradient
android:angle="270"
android:endColor="#FFEAB9"
android:startColor="#FBF3DE" />
<!-- 设置按钮的四个角为弧形 -->
<!-- android:radius 弧形的半径 -->
<corners android:radius="10dip" />
<corners android:radius="20dip" />
</shape>
\ No newline at end of file
......@@ -3,9 +3,10 @@
android:shape="rectangle">
<!-- 填充的颜色 -->
<solid android:color="#282d34" />
<solid android:color="#353738" />
<!-- 设置按钮的四个角为弧形 -->
<!-- android:radius 弧形的半径 -->
<corners android:radius="10dip" />
<corners android:radius="20dip" />
<stroke android:width="1dp" android:color="#484848"/>
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<!-- 填充的颜色 -->
<!-- <gradient-->
<!-- android:angle="180"-->
<!-- android:endColor="#f2d6a4"-->
<!-- android:startColor="#efbc6a" />-->
<solid android:color="#494B4C" />
<!-- 设置按钮的四个角为弧形 -->
<!-- android:radius 弧形的半径 -->
<corners
android:bottomLeftRadius="20dp"
android:bottomRightRadius="20dp"
android:topLeftRadius="0dp"
android:topRightRadius="0dp" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<!-- 填充的颜色 -->
<!-- <gradient-->
<!-- android:angle="180"-->
<!-- android:endColor="#f2d6a4"-->
<!-- android:startColor="#efbc6a" />-->
<solid android:color="#FBD07A" />
<!-- 设置按钮的四个角为弧形 -->
<!-- android:radius 弧形的半径 -->
<corners
android:bottomLeftRadius="20dp"
android:bottomRightRadius="20dp"
android:topLeftRadius="0dp"
android:topRightRadius="0dp" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<!-- 填充的颜色 -->
<gradient
android:angle="180"
android:endColor="#FC3B02"
android:startColor="#FC8D16" />
<!-- 设置按钮的四个角为弧形 -->
<!-- android:radius 弧形的半径 -->
<corners
android:bottomLeftRadius="0dp"
android:bottomRightRadius="8dp"
android:topLeftRadius="8dp"
android:topRightRadius="8dp" />
</shape>
\ No newline at end of file
......@@ -138,7 +138,7 @@
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rvVip"
android:layout_width="match_parent"
android:layout_height="140dp"
android:layout_height="170dp"
android:layout_gravity="center_horizontal"
android:background="@null"
android:overScrollMode="never" />
......@@ -249,7 +249,7 @@
android:layout_marginLeft="40dp"
android:layout_marginTop="10dp"
android:layout_marginRight="40dp"
android:layout_marginBottom="5dp"
android:layout_marginBottom="10dp"
app:shimmer_animation_duration="1200"
app:shimmer_color="#50ffffff">
......
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_width="wrap_content"
android:layout_height="158dp"
android:layout_marginLeft="5dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:orientation="vertical">
<FrameLayout
android:id="@+id/rlVipItemRoot"
android:layout_width="match_parent"
android:layout_height="110dp"
android:layout_width="130dp"
android:layout_height="150dp"
android:layout_marginTop="8dp"
android:background="@drawable/shape_vip_adapter_none"
android:orientation="vertical">
<RelativeLayout
<LinearLayout
android:layout_width="match_parent"
android:layout_marginTop="-8dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical">
android:layout_gravity="center_vertical"
android:layout_marginTop="-8dp"
android:orientation="vertical">
<TextView
android:id="@+id/tvVipItemTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="18dp"
android:textColor="#efbc6a"
android:textSize="20sp"
android:layout_centerVertical="true"
android:textColor="#9C5200"
android:textSize="16sp"
android:textStyle="bold"
tools:text="包年会员" />
......@@ -40,42 +37,49 @@
android:id="@+id/tvVipItemCurMoney"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"
android:layout_marginRight="18dp"
android:layout_gravity="center_horizontal"
android:gravity="center"
android:textColor="#efbc6a"
android:textSize="16sp"
android:textColor="#B4782E"
android:textSize="18sp"
tools:text="$78" />
<TextView
android:id="@+id/tvVipItemOldMoney"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center"
android:textColor="#efbc6a"
android:textSize="10sp"
tools:text="$78" />
</RelativeLayout>
</LinearLayout>
<TextView
android:id="@+id/tvVipItemMoney"
android:layout_width="match_parent"
android:layout_height="28dp"
android:layout_gravity="bottom"
android:background="@drawable/shape_vip_lable"
android:background="@drawable/shape_vip_bottom_s"
android:gravity="center"
android:textColor="@color/color_A24240"
android:textSize="12sp"
tools:text="原价:123" />
android:textColor="#673810"
android:textSize="14sp"
tools:text="原价:12q3" />
</FrameLayout>
<TextView
android:id="@+id/tvVipItemLable"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@mipmap/ic_vip_lable"
android:layout_height="24dp"
android:layout_marginStart="-1dp"
android:background="@drawable/shape_vip_label"
android:gravity="center"
android:paddingLeft="6dp"
android:paddingLeft="10dp"
android:paddingTop="2dp"
android:paddingRight="6dp"
android:paddingRight="10dp"
android:paddingBottom="2dp"
android:textColor="@color/color_815136"
android:textColor="@color/white"
android:textSize="14sp"
tools:text="包年会员" />
</FrameLayout>
\ 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