feat: vip 功能开关页面

This commit is contained in:
eggmanQQQ
2024-10-22 13:55:00 +08:00
parent 17a470e847
commit 55fe32db6e
9 changed files with 454 additions and 18 deletions

View File

@@ -337,6 +337,9 @@
<activity
android:name=".ui.setting.SettingActivity"
android:screenOrientation="portrait" />
<activity
android:name=".ui.setting.VipSetActivity"
android:screenOrientation="portrait" />
<activity
android:name=".ui.relation.AttentionListActivity"
android:screenOrientation="portrait" />

View File

@@ -33,11 +33,13 @@ import com.chwl.app.support.FragmentVisibleStateHelper
import com.chwl.app.ui.im.RouterHandler
import com.chwl.app.ui.relation.AttentionListActivity
import com.chwl.app.ui.relation.FansListActivity
import com.chwl.app.ui.setting.VipSetActivity
import com.chwl.app.ui.utils.ImageLoadUtils
import com.chwl.app.ui.wallet.WalletActivity
import com.chwl.app.ui.webview.CommonWebViewActivity
import com.chwl.app.view.GenderAgeTextView
import com.chwl.app.vip.VipCenterActivity
import com.chwl.app.vip.VipSettingActivity
import com.chwl.app.vip.VipViewModel
import com.chwl.core.auth.AuthModel
import com.chwl.core.gift.bean.BoomMsgAwardBean
@@ -373,19 +375,8 @@ class MeFragment : BaseFragment(), View.OnClickListener {
R.id.tv_user_name -> {
//todo do 测试按钮
if (BuildConfig.DEBUG) {
val data1 = arrayListOf<BoomMsgAwardBean>()
for (i in 0 until 10) {
data1.add(BoomMsgAwardBean().apply {
awardPic = "http://beta.img.pekolive.com/FpHRJteaNhJrb-ZBvS3cweeZoPV4?imageslim"
uid = AuthModel.get().currentUid
})
}
RoomBoomRewardDialog(requireContext()).apply {
list = data1
}.show()
WLog.writeLog("测试按钮 测试log")
VipSetActivity.start(requireActivity());
// VipSettingActivity.start(requireActivity())
}
}

View File

@@ -9,6 +9,7 @@ import com.chwl.app.earn.activity.EarnRecordActivity;
import com.chwl.app.pay.activity.GiveGoldActivity;
import com.chwl.app.ui.feedback.FeedbackActivity;
import com.chwl.app.ui.game_team.record.GameTeamRecordActivity;
import com.chwl.app.ui.setting.VipSetActivity;
import com.chwl.app.vip.VipCenterActivity;
import com.chwl.core.module_hall.hall.bean.H5FamilyInfo;
import com.chwl.core.module_hall.hall.bean.UserClanInfo;
@@ -288,6 +289,9 @@ public class RouterHandler {
case RouterType.MY_SET:
UIHelper.showSettingAct(context);
break;
case RouterType.MY_VIP_SET:
VipSetActivity.Companion.start(context);
break;
case RouterType.MY_REVENUE:
EarnRecordActivity.start(context);
break;

View File

@@ -0,0 +1,172 @@
package com.chwl.app.ui.setting
import android.content.Context
import android.content.Intent
import android.view.View
import android.widget.ImageView
import com.chwl.app.R
import com.chwl.app.avroom.ButtonItemFactory
import com.chwl.app.base.BaseViewBindingActivity
import com.chwl.app.databinding.VipSetActivityBinding
import com.chwl.app.ui.widget.UserInfoDialog
import com.chwl.core.auth.AuthModel
import com.chwl.core.bean.response.ServiceResult
import com.chwl.core.user.UserModel
import com.chwl.core.user.bean.UserInfo
import com.chwl.core.utils.net.RxHelper
import com.chwl.library.common.util.setMargin
import com.chwl.library.common.util.setViewWH
import com.chwl.library.net.rxnet.RxNet
import com.chwl.library.utils.ResUtil
import com.chwl.library.utils.SingleToastUtil
import com.example.lib_utils.ktx.getDimension
import com.example.lib_utils.log.ILog
import com.google.gson.JsonElement
import com.netease.nim.uikit.StatusBarUtil
import io.reactivex.Single
import retrofit2.http.GET
import retrofit2.http.Query
class VipSetActivity : BaseViewBindingActivity<VipSetActivityBinding>(), ILog, View.OnClickListener {
companion object {
var index = 0
@JvmStatic
fun start(context: Context) {
val starter = Intent(context, VipSetActivity::class.java)
context.startActivity(starter)
}
}
override fun init() {
binding.click = this
initTitleBar(ResUtil.getString(R.string.vipSetTitle))
initVipIcons(binding.vipSetIcons1
, R.drawable.vip_center_identification_vipidentity_lv5
, R.drawable.vip_center_identification_vipidentity_lv6
, R.drawable.vip_center_identification_vipidentity_lv7
, R.drawable.vip_center_identification_vipidentity_lv8
, R.drawable.vip_center_identification_vipidentity_lv9
)
initVipIcons(binding.vipSetIcons2
, R.drawable.vip_center_identification_vipidentity_lv6
, R.drawable.vip_center_identification_vipidentity_lv7
, R.drawable.vip_center_identification_vipidentity_lv8
, R.drawable.vip_center_identification_vipidentity_lv9
)
initVipIcons(binding.vipSetIcons3
, R.drawable.vip_center_identification_vipidentity_lv7
, R.drawable.vip_center_identification_vipidentity_lv8
, R.drawable.vip_center_identification_vipidentity_lv9
)
initVipIcons(binding.vipSetIcons4
, R.drawable.vip_center_identification_vipidentity_lv8
, R.drawable.vip_center_identification_vipidentity_lv9
)
UserModel.get().getUserInfo(AuthModel.get().currentUid)
.compose(bindToLifecycle())
.doOnSuccess {
it.userVipInfoVO?.let { vInfo->
setSwitchView(binding.vipSetSwitch1,vInfo.enterHide)
setSwitchView(binding.vipSetSwitch2,vInfo.enterHide)
setSwitchView(binding.vipSetSwitch3,vInfo.enterHide)
setSwitchView(binding.vipSetSwitch4,vInfo.enterHide)
}
}
.doOnError {
}
.subscribe()
}
override fun needSteepStateBar(): Boolean {
return true
}
override fun setStatusBar() {
super.setStatusBar()
StatusBarUtil.transparencyBar(this)
StatusBarUtil.StatusBarLightMode(this)
}
private fun initVipIcons(layout:android.widget.LinearLayout,vararg ids:Int){
ids.forEach {
val icon = ImageView(context);
layout.addView(icon)
icon.setViewWH(R.dimen.dp_43.getDimension().toInt(),R.dimen.dp_20.getDimension().toInt(), isDP = false )
icon.setMargin(end = R.dimen.dp_5.getDimension().toInt(), isDP = false)
icon.setBackgroundResource(it)
}
}
private fun switchClick(view: View) {
val value = view.tag
if (value is Boolean && view is ImageView) {
switchApi(view,!value)
.doOnSuccess {
view.tag = !value
setSwitchView(view,!value)
}
.doOnError {
}
.compose(bindToLifecycle())
.subscribe()
}
}
private fun switchApi(view : ImageView,value:Boolean) : Single<String> {
when (view) {
binding.vipSetSwitch1 -> return api.notFollowed(value).compose(RxHelper.handleIgnoreData()).compose(RxHelper.handleSchedulers())
binding.vipSetSwitch2 -> return api.notTrace(value).compose(RxHelper.handleIgnoreData()).compose(RxHelper.handleSchedulers())
binding.vipSetSwitch3 -> return api.invisible(value).compose(RxHelper.handleIgnoreData()).compose(RxHelper.handleSchedulers())
binding.vipSetSwitch4 -> return api.notKick(value).compose(RxHelper.handleIgnoreData()).compose(RxHelper.handleSchedulers())
else -> return api.notFollowed(!value).compose(RxHelper.handleIgnoreData()).compose(RxHelper.handleSchedulers())
}
}
private fun setSwitchView(view: ImageView, isSwitch: Boolean) {
view.tag = isSwitch
view.setImageResource(if (isSwitch) R.drawable.icon_room_set_lock_true else R.drawable.icon_room_set_lock_false)
}
private final val api = RxNet.create(Api::class.java);
interface Api{
/**
* 不被关注
*/
@GET("/vip/changeInvisibleInRoom")
fun notFollowed(@Query("open") open: Boolean): Single<ServiceResult<JsonElement>>
/**
* 防跟随
*/
@GET("/vip/changeInvisibleInRoom")
fun notTrace(@Query("open") open: Boolean): Single<ServiceResult<JsonElement>>
/**
* 开关隐身进房状态
*/
@GET("/vip/changeInvisibleInRoom")
fun invisible(@Query("open") open: Boolean): Single<ServiceResult<JsonElement>>
/**
* 防踢
*/
@GET("/vip/changeInvisibleInRoom")
fun notKick(@Query("open") open: Boolean): Single<ServiceResult<JsonElement>>
}
override fun onClick(v: View?) {
v?.let {
when (it) {
binding.vipSetSwitch1,
binding.vipSetSwitch2,
binding.vipSetSwitch3,
binding.vipSetSwitch4 -> switchClick(it)
}
}
}
}

View File

@@ -0,0 +1,244 @@
<?xml version="1.0" encoding="utf-8"?>
<layout>
<data>
<variable
name="click"
type="android.view.View.OnClickListener" />
</data>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
android:orientation="vertical">
<com.chwl.app.base.TitleBar
android:id="@+id/title_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_30" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingHorizontal="@dimen/dp_16">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_15"
android:text="@string/vipSetTitle2"
android:textColor="@color/color_313131"
android:textSize="22sp" />
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="@dimen/dp_64"
android:layout_marginTop="@dimen/dp_20">
<com.chwl.library.widget.text.DrawableTextView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:dt_drawableType="shape"
app:dt_radius="@dimen/dp_8"
app:dt_soildColor="#f2f3f7" />
<LinearLayout
android:id="@+id/vipSetIcons1"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_20"
android:layout_marginHorizontal="@dimen/dp_10"
android:layout_marginTop="@dimen/dp_10"
android:orientation="horizontal"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/vipSetTitle1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginHorizontal="@dimen/dp_10"
android:layout_marginBottom="@dimen/dp_10"
android:text="@string/vipSetItemTitle1"
android:textColor="@color/color_313131"
android:textSize="14sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<ImageView
android:id="@+id/vipSetSwitch1"
android:layout_width="@dimen/dp_45"
android:layout_height="@dimen/dp_25"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:layout_marginEnd="@dimen/dp_10"
android:onClick="@{click}"
android:src="@drawable/icon_room_set_lock_false"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="@dimen/dp_64"
android:layout_marginTop="@dimen/dp_20">
<com.chwl.library.widget.text.DrawableTextView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:dt_drawableType="shape"
app:dt_radius="@dimen/dp_8"
app:dt_soildColor="#f2f3f7" />
<LinearLayout
android:id="@+id/vipSetIcons2"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_20"
android:layout_marginHorizontal="@dimen/dp_10"
android:layout_marginTop="@dimen/dp_10"
android:orientation="horizontal"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/vipSetTitle2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginHorizontal="@dimen/dp_10"
android:layout_marginBottom="@dimen/dp_10"
android:text="@string/vipSetItemTitle2"
android:textColor="@color/color_313131"
android:textSize="14sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<ImageView
android:id="@+id/vipSetSwitch2"
android:layout_width="@dimen/dp_45"
android:layout_height="@dimen/dp_25"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:layout_marginEnd="@dimen/dp_10"
android:onClick="@{click}"
android:src="@drawable/icon_room_set_lock_false"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="@dimen/dp_64"
android:layout_marginTop="@dimen/dp_20">
<com.chwl.library.widget.text.DrawableTextView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:dt_drawableType="shape"
app:dt_radius="@dimen/dp_8"
app:dt_soildColor="#f2f3f7" />
<LinearLayout
android:id="@+id/vipSetIcons3"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_20"
android:layout_marginHorizontal="@dimen/dp_10"
android:layout_marginTop="@dimen/dp_10"
android:orientation="horizontal"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/vipSetTitle3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginHorizontal="@dimen/dp_10"
android:layout_marginBottom="@dimen/dp_10"
android:text="@string/vipSetItemTitle3"
android:textColor="@color/color_313131"
android:textSize="14sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<ImageView
android:id="@+id/vipSetSwitch3"
android:layout_width="@dimen/dp_45"
android:layout_height="@dimen/dp_25"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:layout_marginEnd="@dimen/dp_10"
android:onClick="@{click}"
android:src="@drawable/icon_room_set_lock_false"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="@dimen/dp_64"
android:layout_marginTop="@dimen/dp_20">
<com.chwl.library.widget.text.DrawableTextView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:dt_drawableType="shape"
app:dt_radius="@dimen/dp_8"
app:dt_soildColor="#f2f3f7" />
<LinearLayout
android:id="@+id/vipSetIcons4"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_20"
android:layout_marginHorizontal="@dimen/dp_10"
android:layout_marginTop="@dimen/dp_10"
android:orientation="horizontal"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/vipSetTitle4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginHorizontal="@dimen/dp_10"
android:layout_marginBottom="@dimen/dp_10"
android:text="@string/vipSetItemTitle4"
android:textColor="@color/color_313131"
android:textSize="14sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<ImageView
android:id="@+id/vipSetSwitch4"
android:layout_width="@dimen/dp_45"
android:layout_height="@dimen/dp_25"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:layout_marginEnd="@dimen/dp_10"
android:onClick="@{click}"
android:src="@drawable/icon_room_set_lock_false"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>
</LinearLayout>
</layout>

View File

@@ -5386,6 +5386,15 @@ You cannot join again within 24 hours after leaving</string>
<string name="roomAvatar">roomAvatar</string>
<string name="vipSetTitle">vipSetTitle</string>
<string name="vipSetTitle2">vipSetTitle2</string>
<string name="vipSetItemTitle1">vipSetItemTitle1</string>
<string name="vipSetItemTitle2">vipSetItemTitle2</string>
<string name="vipSetItemTitle3">vipSetItemTitle3</string>
<string name="vipSetItemTitle4">vipSetItemTitle4</string>

View File

@@ -229,6 +229,11 @@ public class RouterType {
*/
public static final int MY_DRESS_ITEM = 79;
/**
* - Vip设置
*/
public static final int MY_VIP_SET = 80;
/**
* 收益记录目前只是本地用到所以用了100000

View File

@@ -10,23 +10,23 @@ import com.chwl.library.utils.SizeUtils
import com.example.lib_utils.UiUtils.isRtl
fun View.setMargin(start:Int?=null,top:Int?=null,end:Int?=null,bottom:Int?=null) {
fun View.setMargin(start:Int?=null,top:Int?=null,end:Int?=null,bottom:Int?=null,isDP:Boolean = true) {
val lp = this.layoutParams as MarginLayoutParams
if (start != null) {
lp.marginStart = start
lp.marginStart = if (isDP)SizeUtils.dp2px(this.context,start.toFloat()) else start
}
if (top != null) {
lp.topMargin = top
lp.topMargin = if (isDP)SizeUtils.dp2px(this.context,top.toFloat()) else top
}
if (end != null) {
lp.marginEnd = end
lp.marginEnd = if (isDP)SizeUtils.dp2px(this.context,end.toFloat()) else end
}
if (bottom != null) {
lp.bottomMargin = bottom
lp.bottomMargin = if (isDP)SizeUtils.dp2px(this.context,bottom.toFloat()) else bottom
}
this.layoutParams = lp
}

View File

@@ -80,6 +80,14 @@ fun Int.getString(vararg : Any): String {
return AppUtils.getApp().getString(this,vararg)
}
fun Int.getDimension(): Float {
return AppUtils.getApp().resources.getDimension(this)
}
fun Int.dimToPx(): Float {
return AppUtils.getApp().resources.getDimension(this).toDP()
}
/**
* 获取资源drawable
* */