Commit 1e1014b3 authored by 张释方's avatar 张释方

修改新人有礼弹框页面逻辑

parent 3ee9de0e
package com.mints.street.adapter
import android.content.Context
import android.graphics.Paint
import com.alibaba.android.vlayout.LayoutHelper
import com.alibaba.android.vlayout.layout.GridLayoutHelper
import com.fry.base.adapter.AbstractVLayoutBaseAdapter
import com.fry.base.adapter.BindingViewHolder
import com.fry.base.binding.setMargin
import com.mints.street.R
import com.mints.street.databinding.ItemGridBenfitAdpaterBinding
import com.mints.street.databinding.ItemGridPaymentAdpaterBinding
import me.goldze.mvvmhabit.utils.AppUtils
class GridBenfitAdapter(val context: Context, val list: List<String>) :
AbstractVLayoutBaseAdapter<ItemGridBenfitAdpaterBinding,
List<String>>(context, list, 3) {
private var datalist: List<String>? = list
private var mposition: Int = 0//设置首次进来默认选中第一个
override fun onBindViewHolder(holder: BindingViewHolder<ItemGridBenfitAdpaterBinding>, position: Int) {
//设置 view边距
if (position % 3 == 0) {
holder.binding.bg.setMargin(AppUtils.dp2Px(context, 20F), AppUtils.dp2Px(context, 10F),
AppUtils.dp2Px(context, 10F), 0, null, null, null)
} else if (position % 3 == 1) {
holder.binding.bg.setMargin(AppUtils.dp2Px(context, 10F), AppUtils.dp2Px(context, 10F),
AppUtils.dp2Px(context, 10F), 0, null, null, null)
} else {
holder.binding.bg.setMargin(AppUtils.dp2Px(context, 10F), AppUtils.dp2Px(context, 10F),
AppUtils.dp2Px(context, 20F), 0, null, null, null)
}
// holder.binding.bg.setMargin(AppUtils.dp2Px(context, 20F), AppUtils.dp2Px(context, 10F),
// 0, 0, null, null, null)
}
override fun getItemCount(): Int {
return if (datalist == null) {
0
} else {
datalist!!.size
}
}
override fun getLayoutId(viewType: Int) = R.layout.item_grid_benfit_adpater
fun getPosition() = mposition
override fun onCreateLayoutHelper(): LayoutHelper {
val hp: GridLayoutHelper = GridLayoutHelper(3)
hp.setAutoExpand(false)
return hp
}
}
......@@ -29,8 +29,8 @@ class GridMapAdapter(val context: Context, var list: List<VrmapBean.Internal>?)
holder.binding.bg.setMargin(AppUtils.dp2Px(context, 10F), AppUtils.dp2Px(context, 10F),
AppUtils.dp2Px(context, 5F), 0, null, null, null)
} else {
holder.binding.bg.setMargin(AppUtils.dp2Px(context, 5F), AppUtils.dp2Px(context, 10F), AppUtils.dp2Px(context, 10F),
0, null, null, null)
holder.binding.bg.setMargin(AppUtils.dp2Px(context, 5F), AppUtils.dp2Px(context, 10F),
AppUtils.dp2Px(context, 10F), 0, null, null, null)
}
datalist?.let {
......
......@@ -40,7 +40,7 @@ class OpenvipActivity : BaseActivity<ActivityOpenvipBinding, OpenvipViewModel>()
private var mAdapter: DelegateAdapter? = null
private var gridPaymentAdapter: GridPaymentAdapter? = null
private var vipList: MutableList<VipBean.ListBean>? = null
private var currentPayType=""
private var currentPayType = ""
override fun initVariableId() = BR.viewModel
override fun initContentView(savedInstanceState: Bundle?) = R.layout.activity_openvip
......@@ -51,7 +51,7 @@ class OpenvipActivity : BaseActivity<ActivityOpenvipBinding, OpenvipViewModel>()
override fun initData() {
super.initData()
if(!TextUtils.isEmpty(UserManager.INSTANCE.getUserID())){
if (!TextUtils.isEmpty(UserManager.INSTANCE.getUserID())) {
//获取vip福利信息
viewModel.getVipProductsByType()
//获取支付方式
......@@ -153,7 +153,7 @@ class OpenvipActivity : BaseActivity<ActivityOpenvipBinding, OpenvipViewModel>()
viewModel.Vipdata.observe(this, Observer<VipBean> {
vipList = it.list as MutableList<VipBean.ListBean>?
//展示 推荐套餐内容
gridPaymentAdapter=GridPaymentAdapter(this, it.list!!)
gridPaymentAdapter = GridPaymentAdapter(this, it.list!!)
mAdapter?.addAdapter(gridPaymentAdapter)
})
viewModel.vippayParams.observe(this, Observer<WxPayParamBean> {
......@@ -172,7 +172,7 @@ class OpenvipActivity : BaseActivity<ActivityOpenvipBinding, OpenvipViewModel>()
}
})
viewModel.isPaySuc.observe(this, Observer<Boolean> {
if(it){
if (it) {
ToastUtils.showShort("支付成功")
finish()
}
......@@ -187,12 +187,12 @@ class OpenvipActivity : BaseActivity<ActivityOpenvipBinding, OpenvipViewModel>()
for (str in it.list!!) {
if (str.equals("WEIXIN")) {
ly_weixin.visibility = View.VISIBLE
currentPayType="WEIXIN"
currentPayType = "WEIXIN"
}
if (str.equals("ALIPAY")) {
ly_alipay.visibility = View.VISIBLE
if(TextUtils.isEmpty(currentPayType)){
currentPayType="ALIPAY"
if (TextUtils.isEmpty(currentPayType)) {
currentPayType = "ALIPAY"
}
}
}
......@@ -227,12 +227,12 @@ class OpenvipActivity : BaseActivity<ActivityOpenvipBinding, OpenvipViewModel>()
R.id.ly_weixin -> {//微信支付
//设置选中样式
setOnChecked(1)
currentPayType="WEIXIN"
currentPayType = "WEIXIN"
}
R.id.ly_alipay -> {//支付宝支付
//设置选中样式
setOnChecked(2)
currentPayType="ALIPAY"
currentPayType = "ALIPAY"
}
R.id.bt_try -> {//点击开通全球会员按钮
payVip()
......@@ -240,9 +240,9 @@ class OpenvipActivity : BaseActivity<ActivityOpenvipBinding, OpenvipViewModel>()
}
}
private fun payVip(){
if (vipList != null && vipList!!.size > 0&&gridPaymentAdapter!=null) {
if (TextUtils.equals("WEIXIN",currentPayType)) {
private fun payVip() {
if (vipList != null && vipList!!.size > 0 && gridPaymentAdapter != null) {
if (TextUtils.equals("WEIXIN", currentPayType)) {
viewModel.getVipPayParams("WEIXIN", vipList!![gridPaymentAdapter!!.getPosition()].pid)
} else {
viewModel.getVipPayParams("ALIPAY", vipList!![gridPaymentAdapter!!.getPosition()].pid)
......@@ -251,7 +251,13 @@ class OpenvipActivity : BaseActivity<ActivityOpenvipBinding, OpenvipViewModel>()
}
private fun backvipDialog() {
/*DialogUtils.showbennfitsDialog(this, object : DialogListener() {
override fun onClick(dialog: Dialog?, v: View?) {
if (dialog != null && dialog.isShowing) {
dialog.dismiss()
}
}
})*/
DialogUtils.showbackvipDialog(this, object : DialogListener() {
override fun onClick(dialog: Dialog?, v: View?) {
if (dialog != null && dialog.isShowing) {
......
......@@ -5,15 +5,20 @@ import android.content.Context
import android.view.Gravity
import android.view.KeyEvent
import android.view.WindowManager
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.alibaba.android.vlayout.DelegateAdapter
import com.alibaba.android.vlayout.VirtualLayoutManager
import com.mints.street.R
import com.mints.street.adapter.GridBenfitAdapter as GridBenfitAdapter
class ShowBenfitDialog (context: Context, private val listener: DialogListener) :
class ShowBenfitDialog(context: Context, private val listener: DialogListener) :
Dialog(context, R.style.dialog) {
private val lp: WindowManager.LayoutParams
// private val tv_payment: TextView
// private val tv_close: TextView
private var recycleView: RecyclerView? = null
private var vLayout: VirtualLayoutManager? = null
private var mAdapter: DelegateAdapter? = null
private var gridbenfitAdapter: GridBenfitAdapter? = null
init {
setContentView(R.layout.dialog_showbenfit)
......@@ -30,16 +35,19 @@ class ShowBenfitDialog (context: Context, private val listener: DialogListener)
setOnKeyListener { _, i, _ ->
i == KeyEvent.KEYCODE_BACK
}
/*// 查找View
tv_payment = findViewById(R.id.tv_payment)
tv_close = findViewById(R.id.tv_close)
initView();
}
private fun initView() {
recycleView = findViewById(R.id.recyclerview)
//recycleView管理(展示套餐推荐)
vLayout = VirtualLayoutManager(context)
mAdapter = DelegateAdapter(vLayout, false)
recycleView?.adapter = mAdapter
recycleView?.layoutManager = vLayout
tv_payment.setOnClickListener {
listener.onClick(it)
}
tv_close.setOnClickListener {
listener.onClick(it)
}*/
//展示 推荐套餐内容
gridbenfitAdapter= GridBenfitAdapter(context, listOf("1","2","3","1","2","3"))
mAdapter?.addAdapter(gridbenfitAdapter)
}
}
\ No newline at end of file
......@@ -12,191 +12,14 @@
android:layout_height="390dp"
android:background="@mipmap/dialog_bg_benfit">
<ImageView
android:id="@+id/imageView7"
android:layout_width="66dp"
android:layout_height="66dp"
app:layout_constraintBottom_toTopOf="@+id/guideline13"
app:layout_constraintEnd_toStartOf="@+id/guideline14"
app:layout_constraintStart_toStartOf="@+id/guideline18"
app:layout_constraintTop_toTopOf="@+id/guideline12"
app:srcCompat="@mipmap/ic_launcher_main" />
<ImageView
android:id="@+id/imageView20"
android:layout_width="66dp"
android:layout_height="66dp"
app:layout_constraintBottom_toTopOf="@+id/guideline17"
app:layout_constraintEnd_toStartOf="@+id/guideline19"
app:layout_constraintStart_toStartOf="@+id/guideline15"
app:layout_constraintTop_toTopOf="@+id/guideline13"
app:srcCompat="@mipmap/ic_launcher_main" />
<ImageView
android:id="@+id/imageView21"
android:layout_width="66dp"
android:layout_height="66dp"
app:layout_constraintBottom_toTopOf="@+id/guideline17"
app:layout_constraintEnd_toStartOf="@+id/guideline14"
app:layout_constraintStart_toStartOf="@+id/guideline18"
app:layout_constraintTop_toTopOf="@+id/guideline13"
app:srcCompat="@mipmap/ic_launcher_main" />
<ImageView
android:id="@+id/imageView22"
android:layout_width="66dp"
android:layout_height="66dp"
app:layout_constraintBottom_toTopOf="@+id/guideline13"
app:layout_constraintEnd_toStartOf="@+id/guideline19"
app:layout_constraintStart_toStartOf="@+id/guideline15"
app:layout_constraintTop_toTopOf="@+id/guideline12"
app:srcCompat="@mipmap/ic_launcher_main" />
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="北京故宫"
android:textColor="@color/black"
app:layout_constraintBottom_toTopOf="@+id/guideline13"
app:layout_constraintEnd_toStartOf="@+id/guideline14"
app:layout_constraintStart_toStartOf="@+id/guideline18"
app:layout_constraintTop_toBottomOf="@+id/imageView7" />
<TextView
android:id="@+id/textView4"
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="北京故宫"
android:textColor="@color/black"
app:layout_constraintBottom_toTopOf="@+id/guideline17"
app:layout_constraintEnd_toStartOf="@+id/guideline14"
app:layout_constraintStart_toStartOf="@+id/guideline18"
app:layout_constraintTop_toBottomOf="@+id/imageView21" />
<TextView
android:id="@+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="北京故宫"
android:textColor="@color/black"
app:layout_constraintBottom_toTopOf="@+id/guideline17"
app:layout_constraintEnd_toStartOf="@+id/guideline19"
app:layout_constraintStart_toStartOf="@+id/guideline15"
app:layout_constraintTop_toBottomOf="@+id/imageView20" />
<TextView
android:id="@+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="北京故宫"
android:textColor="@color/black"
app:layout_constraintBottom_toTopOf="@+id/guideline17"
app:layout_constraintEnd_toStartOf="@+id/guideline15"
app:layout_constraintStart_toStartOf="@+id/guideline14"
app:layout_constraintTop_toBottomOf="@+id/imageView5" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="北京故宫"
android:textColor="@color/black"
app:layout_constraintBottom_toTopOf="@+id/guideline13"
app:layout_constraintEnd_toStartOf="@+id/guideline19"
app:layout_constraintStart_toStartOf="@+id/guideline15"
app:layout_constraintTop_toBottomOf="@+id/imageView22" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="北京故宫"
android:textColor="@color/black"
app:layout_constraintBottom_toTopOf="@+id/guideline13"
app:layout_constraintEnd_toStartOf="@+id/guideline15"
app:layout_constraintStart_toStartOf="@+id/guideline14"
app:layout_constraintTop_toBottomOf="@+id/imageView23" />
<ImageView
android:id="@+id/imageView23"
android:layout_width="66dp"
android:layout_height="66dp"
app:layout_constraintBottom_toTopOf="@+id/guideline13"
app:layout_constraintEnd_toStartOf="@+id/guideline15"
app:layout_constraintStart_toStartOf="@+id/guideline14"
app:layout_constraintTop_toTopOf="@+id/guideline12"
app:srcCompat="@mipmap/ic_launcher_main" />
<ImageView
android:id="@+id/imageView12"
android:layout_width="16dp"
android:layout_height="16dp"
app:layout_constraintBottom_toBottomOf="@+id/imageView7"
app:layout_constraintEnd_toEndOf="@+id/imageView7"
app:layout_constraintStart_toStartOf="@+id/imageView7"
app:layout_constraintTop_toTopOf="@+id/imageView7"
app:srcCompat="@mipmap/dialog_location_benfit" />
<ImageView
android:id="@+id/imageView24"
android:layout_width="16dp"
android:layout_height="16dp"
app:layout_constraintBottom_toBottomOf="@+id/imageView20"
app:layout_constraintEnd_toEndOf="@+id/imageView20"
app:layout_constraintStart_toStartOf="@+id/imageView20"
app:layout_constraintTop_toTopOf="@+id/imageView20"
app:srcCompat="@mipmap/dialog_location_benfit" />
<ImageView
android:id="@+id/imageView25"
android:layout_width="16dp"
android:layout_height="16dp"
app:layout_constraintBottom_toBottomOf="@+id/imageView22"
app:layout_constraintEnd_toEndOf="@+id/imageView22"
app:layout_constraintStart_toStartOf="@+id/imageView22"
app:layout_constraintTop_toTopOf="@+id/imageView22"
app:srcCompat="@mipmap/dialog_location_benfit" />
<ImageView
android:id="@+id/imageView26"
android:layout_width="16dp"
android:layout_height="16dp"
app:layout_constraintBottom_toBottomOf="@+id/imageView23"
app:layout_constraintEnd_toEndOf="@+id/imageView23"
app:layout_constraintStart_toStartOf="@+id/imageView23"
app:layout_constraintTop_toTopOf="@+id/imageView23"
app:srcCompat="@mipmap/dialog_location_benfit" />
<ImageView
android:id="@+id/imageView27"
android:layout_width="16dp"
android:layout_height="16dp"
app:layout_constraintBottom_toBottomOf="@+id/imageView21"
app:layout_constraintEnd_toEndOf="@+id/imageView21"
app:layout_constraintStart_toStartOf="@+id/imageView21"
app:layout_constraintTop_toTopOf="@+id/imageView21"
app:srcCompat="@mipmap/dialog_location_benfit" />
<ImageView
android:id="@+id/imageView5"
android:layout_width="66dp"
android:layout_height="66dp"
app:layout_constraintBottom_toTopOf="@+id/guideline17"
app:layout_constraintEnd_toStartOf="@+id/guideline15"
app:layout_constraintStart_toStartOf="@+id/guideline14"
app:layout_constraintTop_toTopOf="@+id/guideline13"
app:srcCompat="@mipmap/ic_launcher_main" />
<ImageView
android:id="@+id/imageView6"
android:layout_width="16dp"
android:layout_height="16dp"
app:layout_constraintBottom_toBottomOf="@+id/imageView5"
app:layout_constraintEnd_toEndOf="@+id/imageView5"
app:layout_constraintStart_toStartOf="@+id/imageView5"
app:layout_constraintTop_toTopOf="@+id/imageView5"
app:srcCompat="@mipmap/dialog_location_benfit" />
app:layout_constraintStart_toStartOf="@+id/guideline18"
app:layout_constraintTop_toTopOf="@+id/guideline12" />
<androidx.constraintlayout.widget.Guideline
android:id="@+id/guideline12"
......@@ -205,13 +28,6 @@
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.35" />
<androidx.constraintlayout.widget.Guideline
android:id="@+id/guideline13"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.65" />
<androidx.constraintlayout.widget.Guideline
android:id="@+id/guideline17"
android:layout_width="wrap_content"
......@@ -219,13 +35,6 @@
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.95" />
<androidx.constraintlayout.widget.Guideline
android:id="@+id/guideline14"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.36" />
<androidx.constraintlayout.widget.Guideline
android:id="@+id/guideline18"
android:layout_width="wrap_content"
......@@ -240,13 +49,6 @@
android:orientation="vertical"
app:layout_constraintGuide_percent="0.92" />
<androidx.constraintlayout.widget.Guideline
android:id="@+id/guideline15"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.64" />
</androidx.constraintlayout.widget.ConstraintLayout>
<ImageView
......
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android">
<data>
<variable
name="viewModel"
type="com.mints.street.adapter.GridBenfitAdapter" />
</data>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/bg"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/imageView3"
android:layout_width="66dp"
android:layout_height="66dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@mipmap/ic_launcher_main" />
<ImageView
android:id="@+id/imageView4"
android:layout_width="16dp"
android:layout_height="16dp"
app:layout_constraintBottom_toBottomOf="@+id/imageView3"
app:layout_constraintEnd_toEndOf="@+id/imageView3"
app:layout_constraintStart_toStartOf="@+id/imageView3"
app:layout_constraintTop_toTopOf="@+id/imageView3"
app:srcCompat="@mipmap/dialog_location_benfit" />
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="北京故宫"
android:textColor="@color/black"
android:textSize="14sp"
app:layout_constraintEnd_toEndOf="@+id/imageView3"
app:layout_constraintStart_toStartOf="@+id/imageView3"
app:layout_constraintTop_toBottomOf="@+id/imageView3" />
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
\ 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