Commit 7b3f6b7f authored by 张释方's avatar 张释方

完成根据数组数据控制支付方式顺序,完善热门景点功能。

parent bf188896
/build
mapping.txt
seeds.txt
unused.txt
\ No newline at end of file
unused.txt
/src/main/res/mipmap-xhdpi/
package com.mints.street.adapter
import android.content.Context
import androidx.recyclerview.widget.DividerItemDecoration
import androidx.recyclerview.widget.RecyclerView
import com.alibaba.android.vlayout.layout.LinearLayoutHelper
import com.blankj.utilcode.util.ActivityUtils.startActivity
import com.fry.base.adapter.AbstractVLayoutBaseAdapter
import com.fry.base.adapter.BindingViewHolder
import com.mints.street.R
import com.mints.street.databinding.ItemHotViewAdapterBinding
import com.mints.street.main.my.OpenvipActivity
import com.mints.street.manager.UserManager
import me.goldze.mvvmhabit.utils.RxUtils
class ItemHotViewAdapter(val context: Context, var list: List<String>?) :
AbstractVLayoutBaseAdapter<ItemHotViewAdapterBinding, List<String>?>(
......@@ -16,10 +22,16 @@ class ItemHotViewAdapter(val context: Context, var list: List<String>?) :
var a = context.resources.displayMetrics;
val bgLayoutParams = holder.binding.bg.layoutParams
bgLayoutParams.width = a.widthPixels
holder.itemView.setOnClickListener {
RxUtils.onMultiClick(holder.itemView){
//判断是否当前是否是会员,
if (!UserManager.INSTANCE.userIsLogin()){
//否-跳转到开通vip界面
startActivity(OpenvipActivity::class.java)
}else{
//是-继续浏览,
}
}
}
override fun getItemCount() = list?.size?: 0
......
......@@ -122,8 +122,8 @@ class HomeFragment() : BaseFragment<FragmentHomeBinding, HomeViewModel>(), Senso
RxUtils.onMultiClick(binding.ivClick) {
viewModel.authorized("", currentLat.toString(), currentLon.toString(), false)
}
//点击热门景点
RxUtils.onMultiClick(binding.lyHotview) {
KLog.e("zsf__","热门景点点击事件响应了-----------------")
hotViewDialog.show()
}
viewModel.getMapBean()
......
......@@ -71,8 +71,8 @@ class OpenvipActivity : BaseActivity<ActivityOpenvipBinding, OpenvipViewModel>()
private fun initListener() {
iv_left_icon.setOnClickListener(this)
bt_try.setOnClickListener(this)
ly_weixin.setOnClickListener(this)
ly_alipay.setOnClickListener(this)
ly_payfirst.setOnClickListener(this)
ly_paysecond.setOnClickListener(this)
loginDialog.setListener(object : WxLoginDialog.WxLoginListener {
override fun loginSuc(wxInfo: String) {
......@@ -105,14 +105,6 @@ class OpenvipActivity : BaseActivity<ActivityOpenvipBinding, OpenvipViewModel>()
list.add(page7)
list.add(page5)
list.add(page8)
// page1.setOnClickListener {
// if (UserManager.INSTANCE.userIsLogin()) {
// payVip()
// } else {
// loginDialog.show()
// }
// }
//设置显示的数据
cfp_data_viewpager.setViewList(list)
......@@ -169,7 +161,7 @@ class OpenvipActivity : BaseActivity<ActivityOpenvipBinding, OpenvipViewModel>()
}
//添加page点击时间
//添加page点击
fun pageOnClick(view: View?) {
if (UserManager.INSTANCE.userIsLogin()) {
payVip()
......@@ -211,18 +203,49 @@ class OpenvipActivity : BaseActivity<ActivityOpenvipBinding, OpenvipViewModel>()
return@Observer
} else {
//设置 默认支付方式 (根据返回参数的第一个值)
setfirstpaymentwey(it.list!![0])
if (it.list!![0].isNotEmpty()) {
setfirstpaymentwey(it.list!![0])
}
for (str in it.list!!) {
if (str.equals("WEIXIN")) {
ly_weixin.visibility = View.VISIBLE
currentPayType = "WEIXIN"
if (str.isNotEmpty() && str.equals("WEIXIN")) {
//第一个位置是否展示
if (ly_payfirst.visibility == View.GONE) {//没有-展示相应的支付方式
//设置展示内容
iv_ly_payfirst.setImageResource(R.mipmap.icon_pay_wx)
tv_ly_payfirst.setText("微信支付")
ly_payfirst.visibility = View.VISIBLE
}else{
iv_ly_paysecond.setImageResource(R.mipmap.icon_pay_wx)
tv_ly_paysecond.setText("微信支付")
ly_paysecond.visibility=View.VISIBLE
}
if (TextUtils.isEmpty(currentPayType)) {
currentPayType = "WEIXIN"
}
// ly_payfirst.visibility = View.VISIBLE
// if (TextUtils.isEmpty(currentPayType)) {
// currentPayType = "WEIXIN"
// }
}
if (str.equals("ALIPAY")) {
ly_alipay.visibility = View.VISIBLE
//第一个位置是否展示
if (ly_payfirst.visibility == View.GONE) {//没有-展示相应的支付方式
//设置展示内容
iv_ly_payfirst.setImageResource(R.mipmap.icon_pay_zfb)
tv_ly_payfirst.setText("支付宝支付")
ly_payfirst.visibility = View.VISIBLE
}else{
iv_ly_paysecond.setImageResource(R.mipmap.icon_pay_zfb)
tv_ly_paysecond.setText("支付宝支付")
ly_paysecond.visibility=View.VISIBLE
}
if (TextUtils.isEmpty(currentPayType)) {
currentPayType = "ALIPAY"
}
// ly_second.visibility = View.VISIBLE
// if (TextUtils.isEmpty(currentPayType)) {
// currentPayType = "ALIPAY"
// }
}
}
}
......@@ -260,12 +283,12 @@ class OpenvipActivity : BaseActivity<ActivityOpenvipBinding, OpenvipViewModel>()
R.id.iv_left_icon -> {
backvipDialog()
}
R.id.ly_weixin -> {//微信支付
R.id.ly_payfirst -> {//微信支付
//设置选中样式
setOnChecked(1)
currentPayType = "WEIXIN"
}
R.id.ly_alipay -> {//支付宝支付
R.id.ly_paysecond -> {//支付宝支付
//设置选中样式
setOnChecked(2)
currentPayType = "ALIPAY"
......@@ -291,13 +314,6 @@ 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) {
......@@ -315,7 +331,6 @@ class OpenvipActivity : BaseActivity<ActivityOpenvipBinding, OpenvipViewModel>()
finish()
}
}
}
})
}
......@@ -376,20 +391,5 @@ class OpenvipActivity : BaseActivity<ActivityOpenvipBinding, OpenvipViewModel>()
}
}
override fun onResume() {
super.onResume()
KLog.e("OpenvipActivity", "onResume")
// if(userManager.userIsLogin()&&userManager.getVipFlag()){
// finish()
// }
}
// override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
// super.onActivityResult(requestCode, resultCode, data)
// KLog.e("OpenvipActivity","onActivityResult")
// }
}
package com.mints.street.widget;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.util.Log;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
public class GridItemDecoration extends RecyclerView.ItemDecoration {
public static final int HORIZONTAL = 0;
public static final int VERTICAL = 1;
private static final String TAG = "DividerItem";
private static final int[] ATTRS = new int[]{16843284};
private Drawable mDivider;
private int mOrientation;
private final Rect mBounds = new Rect();
public GridItemDecoration(Context context, int orientation) {
TypedArray a = context.obtainStyledAttributes(ATTRS);
this.mDivider = a.getDrawable(0);
if (this.mDivider == null) {
Log.w("DividerItem", "@android:attr/listDivider was not set in the theme used for this DividerItemDecoration. Please set that attribute all call setDrawable()");
}
a.recycle();
this.setOrientation(orientation);
}
public void setOrientation(int orientation) {
if (orientation != 0 && orientation != 1) {
throw new IllegalArgumentException("Invalid orientation. It should be either HORIZONTAL or VERTICAL");
} else {
this.mOrientation = orientation;
}
}
public void setDrawable(@NonNull Drawable drawable) {
if (drawable == null) {
throw new IllegalArgumentException("Drawable cannot be null.");
} else {
this.mDivider = drawable;
}
}
public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) {
if (parent.getLayoutManager() != null && this.mDivider != null) {
if (this.mOrientation == 1) {
this.drawVertical(c, parent);
} else {
this.drawHorizontal(c, parent);
}
}
}
private void drawVertical(Canvas canvas, RecyclerView parent) {
canvas.save();
int left;
int right;
if (parent.getClipToPadding()) {
left = parent.getPaddingLeft();
right = parent.getWidth() - parent.getPaddingRight();
canvas.clipRect(left, parent.getPaddingTop(), right, parent.getHeight() - parent.getPaddingBottom());
} else {
left = 0;
right = parent.getWidth();
}
int childCount = parent.getChildCount();
//当最后一个子项的时候去除下划线
for (int i = 0; i < childCount - 1; ++i) {
View child = parent.getChildAt(i);
parent.getDecoratedBoundsWithMargins(child, this.mBounds);
int bottom = this.mBounds.bottom + Math.round(child.getTranslationY());
int top = bottom - this.mDivider.getIntrinsicHeight();
this.mDivider.setBounds(left, top, right, bottom);
this.mDivider.draw(canvas);
}
canvas.restore();
}
private void drawHorizontal(Canvas canvas, RecyclerView parent) {
canvas.save();
int top;
int bottom;
if (parent.getClipToPadding()) {
top = parent.getPaddingTop();
bottom = parent.getHeight() - parent.getPaddingBottom();
canvas.clipRect(parent.getPaddingLeft(), top, parent.getWidth() - parent.getPaddingRight(), bottom);
} else {
top = 0;
bottom = parent.getHeight();
}
int childCount = parent.getChildCount();
for (int i = 0; i < childCount; ++i) {
View child = parent.getChildAt(i);
parent.getLayoutManager().getDecoratedBoundsWithMargins(child, this.mBounds);
int right = this.mBounds.right + Math.round(child.getTranslationX());
int left = right - this.mDivider.getIntrinsicWidth();
this.mDivider.setBounds(left, top, right, bottom);
this.mDivider.draw(canvas);
}
canvas.restore();
}
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
if (this.mDivider == null) {
outRect.set(0, 0, 0, 0);
} else {
if (this.mOrientation == 1) {
outRect.set(0, 0, 0, this.mDivider.getIntrinsicHeight());
} else {
outRect.set(0, 0, this.mDivider.getIntrinsicWidth(), 0);
}
}
}
}
\ No newline at end of file
......@@ -5,6 +5,7 @@ import android.view.LayoutInflater
import android.view.View
import android.widget.ImageView
import androidx.fragment.app.FragmentActivity
import androidx.recyclerview.widget.DividerItemDecoration
import androidx.recyclerview.widget.RecyclerView
import com.alibaba.android.vlayout.DelegateAdapter
import com.alibaba.android.vlayout.VirtualLayoutManager
......@@ -15,6 +16,7 @@ import com.mints.street.adapter.ItemHotViewAdapter
import com.mints.street.bean.VreperienceBean
import com.mints.street.main.home.HomeFragment
import com.mints.street.main.home.HomeViewModel
import com.mints.street.widget.GridItemDecoration
class HotViewDialog(context: FragmentActivity, viewModel: HomeViewModel, homeFragment: HomeFragment) {
......@@ -43,6 +45,9 @@ class HotViewDialog(context: FragmentActivity, viewModel: HomeViewModel, homeFra
mBottomSheetDialog!!.window!!.findViewById<View>(R.id.design_bottom_sheet).setBackgroundColor(Color.TRANSPARENT)
val iv_close:ImageView=view1.findViewById(R.id.iv_close)
val recycler_view:RecyclerView=view1.findViewById(R.id.recycler_view)
//添加下划线
view1.findViewById<RecyclerView>(R.id.recycler_view)
.addItemDecoration(GridItemDecoration(context, DividerItemDecoration.VERTICAL))
vLayout = VirtualLayoutManager(context!!);
mAdapter = DelegateAdapter(vLayout,false)
......
......@@ -89,7 +89,7 @@
android:layout_height="130dp" />
<LinearLayout
android:id="@+id/ly_weixin"
android:id="@+id/ly_payfirst"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
......@@ -98,6 +98,7 @@
android:visibility="gone">
<ImageView
android:id="@+id/iv_ly_payfirst"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_alignParentLeft="true"
......@@ -106,6 +107,7 @@
android:src="@mipmap/icon_pay_wx" />
<TextView
android:id="@+id/tv_ly_payfirst"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
......@@ -124,7 +126,7 @@
</LinearLayout>
<LinearLayout
android:id="@+id/ly_alipay"
android:id="@+id/ly_paysecond"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
......@@ -133,6 +135,7 @@
android:visibility="gone">
<ImageView
android:id="@+id/iv_ly_paysecond"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_alignParentLeft="true"
......@@ -141,6 +144,7 @@
android:src="@mipmap/icon_pay_zfb" />
<TextView
android:id="@+id/tv_ly_paysecond"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
......
<?xml version="1.0" encoding="utf-8"?>
<layout 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">
xmlns:app="http://schemas.android.com/apk/res-auto">
<data>
......@@ -14,7 +13,7 @@
android:layout_margin="15dp"
android:id="@+id/bg"
android:layout_width="100dp"
android:layout_height="210dp"
android:layout_height="wrap_content"
android:background="@drawable/shape_bg_vrdata"
android:elevation="5dp"
android:orientation="vertical">
......@@ -38,8 +37,8 @@
android:layout_marginStart="10dp"
android:layout_width="60dp"
android:layout_height="10dp"
android:layout_marginBottom="10dp"
app:starNormal="@mipmap/star_icon"
app:starNumber="5"/>
</LinearLayout>
</layout>
\ No newline at end of file
......@@ -2,35 +2,47 @@
<layout 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">
<data>
<variable
name="viewModel"
type="com.mints.street.adapter.ItemHotViewAdapter" />
</data>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/bg"
android:background="@color/white"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:layout_marginStart="5dp"
android:layout_marginEnd="5dp"
android:layout_marginBottom="5dp"
android:background="@android:color/transparent"
android:padding="10dp">
<com.mints.street.widget.XCRoundRectImageView
android:id="@+id/image1"
android:layout_width="100dp"
android:layout_height="70dp"
android:layout_width="0dp"
android:layout_height="100dp"
android:src="@mipmap/icon_card6"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/guideline3"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:src="@mipmap/icon_card6" />
<androidx.constraintlayout.widget.Guideline
android:id="@+id/guideline3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.4" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="景点名称"
android:textColor="@color/black"
android:textSize="18dp"
......@@ -52,36 +64,38 @@
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="距离"
android:layout_marginLeft="2dp"
android:textSize="14dp"
tools:text="距离"
android:text="距离"
android:textColor="#99000000"
android:textSize="14dp"
app:layout_constraintStart_toEndOf="@+id/view"
app:layout_constraintTop_toTopOf="@+id/textView2" />
app:layout_constraintTop_toTopOf="@+id/textView2"
tools:text="距离" />
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="景点介绍。。。"
tools:text="景点介绍。。。"
android:textColor="#99000000"
app:layout_constraintStart_toEndOf="@+id/image1"
app:layout_constraintTop_toBottomOf="@+id/textView2" />
app:layout_constraintTop_toBottomOf="@+id/textView2"
tools:text="景点介绍。。。" />
<TextView
android:background="@drawable/shape_btn_friends_unenabled"
tools:text="看街景"
android:id="@+id/textView5"
android:layout_width="70dp"
android:layout_height="30dp"
android:layout_marginLeft="10dp"
android:background="@drawable/shape_btn_friends_unenabled"
android:gravity="center"
android:layout_height="20dp"
android:textSize="12sp"
android:textColor="@color/black"
android:text="看街景"
android:textColor="@color/black"
android:textSize="12sp"
app:layout_constraintBottom_toBottomOf="@+id/image1"
app:layout_constraintStart_toEndOf="@+id/image1" />
app:layout_constraintStart_toEndOf="@+id/image1"
tools:text="看街景" />
</androidx.constraintlayout.widget.ConstraintLayout>
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="350dp"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@drawable/shape_dialog_bg">
<ImageView
android:id="@+id/iv_close"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_margin="10dp"
android:layout_margin="8dp"
android:src="@mipmap/icon_hot_view_close"
android:layout_gravity="end"/>
<androidx.recyclerview.widget.RecyclerView
......
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