1:完成家族中续签请求接口和弹框展示的文案
This commit is contained in:
@@ -40,7 +40,7 @@ class MyFamilyBean {
|
|||||||
var mic_cycle: String = "" //麦圈
|
var mic_cycle: String = "" //麦圈
|
||||||
var nobility_image: String = "" //贵族
|
var nobility_image: String = "" //贵族
|
||||||
var nickname_color: String = "" //贵族颜色
|
var nickname_color: String = "" //贵族颜色
|
||||||
var free_renewal: String = "" //免费续签次数
|
var free_renewal: Int = 0 //免费续签次数
|
||||||
var today_earnings: String = "" //今日收礼收益
|
var today_earnings: String = "" //今日收礼收益
|
||||||
var yesterday_earnings: String = "" //昨日收礼收益
|
var yesterday_earnings: String = "" //昨日收礼收益
|
||||||
var is_online: Int = 0 //是否在线 1在线 0离线
|
var is_online: Int = 0 //是否在线 1在线 0离线
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import android.view.Gravity;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
|
import android.text.SpannableString;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||||
@@ -26,6 +27,7 @@ public class ConfirmDialog extends Dialog {
|
|||||||
|
|
||||||
private String title;
|
private String title;
|
||||||
private String message;
|
private String message;
|
||||||
|
private SpannableString spannableMessage;
|
||||||
private String positiveButtonText;
|
private String positiveButtonText;
|
||||||
private String negativeButtonText;
|
private String negativeButtonText;
|
||||||
private View.OnClickListener positiveButtonClickListener;
|
private View.OnClickListener positiveButtonClickListener;
|
||||||
@@ -50,6 +52,23 @@ public class ConfirmDialog extends Dialog {
|
|||||||
this.isCountdownEnabled = isCountdownEnabled;
|
this.isCountdownEnabled = isCountdownEnabled;
|
||||||
this.countdownSeconds = countdownSeconds;
|
this.countdownSeconds = countdownSeconds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 新增构造函数,支持SpannableString
|
||||||
|
public ConfirmDialog(Context context, String title, SpannableString spannableMessage,
|
||||||
|
String positiveButtonText, String negativeButtonText,
|
||||||
|
View.OnClickListener positiveButtonClickListener,
|
||||||
|
View.OnClickListener negativeButtonClickListener,
|
||||||
|
boolean isCountdownEnabled, int countdownSeconds) {
|
||||||
|
super(context);
|
||||||
|
this.title = title;
|
||||||
|
this.spannableMessage = spannableMessage;
|
||||||
|
this.positiveButtonText = positiveButtonText;
|
||||||
|
this.negativeButtonText = negativeButtonText;
|
||||||
|
this.positiveButtonClickListener = positiveButtonClickListener;
|
||||||
|
this.negativeButtonClickListener = negativeButtonClickListener;
|
||||||
|
this.isCountdownEnabled = isCountdownEnabled;
|
||||||
|
this.countdownSeconds = countdownSeconds;
|
||||||
|
}
|
||||||
|
|
||||||
private void init() {
|
private void init() {
|
||||||
Window window = getWindow();
|
Window window = getWindow();
|
||||||
@@ -76,7 +95,12 @@ public class ConfirmDialog extends Dialog {
|
|||||||
|
|
||||||
// 设置文本
|
// 设置文本
|
||||||
tvTitle.setText(title);
|
tvTitle.setText(title);
|
||||||
tvMessage.setText(message);
|
// 根据是否有spannableMessage来设置不同的文本
|
||||||
|
if (spannableMessage != null) {
|
||||||
|
tvMessage.setText(spannableMessage);
|
||||||
|
} else {
|
||||||
|
tvMessage.setText(message);
|
||||||
|
}
|
||||||
btnPositive.setText(positiveButtonText);
|
btnPositive.setText(positiveButtonText);
|
||||||
btnNegative.setText(negativeButtonText);
|
btnNegative.setText(negativeButtonText);
|
||||||
|
|
||||||
|
|||||||
@@ -884,4 +884,12 @@ public interface ApiServer {
|
|||||||
|
|
||||||
@GET(Constants.GET_SKILL_LIST)
|
@GET(Constants.GET_SKILL_LIST)
|
||||||
Call<BaseModel<List<String>>> skillList();
|
Call<BaseModel<List<String>>> skillList();
|
||||||
|
|
||||||
|
@FormUrlEncoded
|
||||||
|
@POST(Constants.POST_FREE_RE_SIGN)
|
||||||
|
Call<BaseModel<String>> freeReSign(@Field("user_id") String user_id);
|
||||||
|
|
||||||
|
@FormUrlEncoded
|
||||||
|
@POST(Constants.POST_RE_SIGN)
|
||||||
|
Call<BaseModel<String>> reSign(@Field("user_id") String user_id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4738,5 +4738,35 @@ public class RetrofitClient {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void freeReSign(int type, String userId,BaseObserver<String> observer) {
|
||||||
|
if (type==1) {
|
||||||
|
sApiServer.freeReSign(userId).enqueue(new Callback<BaseModel<String>>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResponse(Call<BaseModel<String>> call, Response<BaseModel<String>> response) {
|
||||||
|
onNextRetu(response, observer);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(Call<BaseModel<String>> call, Throwable t) {
|
||||||
|
LogUtils.e("freeReSign", t.fillInStackTrace());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}else {
|
||||||
|
sApiServer.reSign(userId).enqueue(new Callback<BaseModel<String>>() {
|
||||||
|
@Override
|
||||||
|
public void onResponse(Call<BaseModel<String>> call, Response<BaseModel<String>> response) {
|
||||||
|
onNextRetu(response, observer);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(Call<BaseModel<String>> call, Throwable t) {
|
||||||
|
LogUtils.e("reSign", t.fillInStackTrace());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -431,6 +431,8 @@ public class Constants {
|
|||||||
public static final String POST_FRIEND_LIST_MORE = "/api/User/get_friend_list_more";//挚友列表查看更多
|
public static final String POST_FRIEND_LIST_MORE = "/api/User/get_friend_list_more";//挚友列表查看更多
|
||||||
public static final String POST_SEND_LOG = "api/Report/android_log_report";//上传log信息
|
public static final String POST_SEND_LOG = "api/Report/android_log_report";//上传log信息
|
||||||
public static final String GET_SKILL_LIST = "/api/Sign/skill_list";//才艺列表
|
public static final String GET_SKILL_LIST = "/api/Sign/skill_list";//才艺列表
|
||||||
|
public static final String POST_FREE_RE_SIGN = "/api/Sign/free_re_sign";//免费续约
|
||||||
|
public static final String POST_RE_SIGN = "/api/Sign/re_sign";//续签(花金币)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -54,6 +54,10 @@ class UserFamilyActivity : BaseMvpActivity<UserFamilyPresenter, ActivityUserFami
|
|||||||
MvpPre?.myFamily(type)
|
MvpPre?.myFamily(type)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun upData(){
|
||||||
|
MvpPre?.myFamily(type)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
override fun getLayoutId(): Int {
|
override fun getLayoutId(): Int {
|
||||||
return R.layout.activity_user_family
|
return R.layout.activity_user_family
|
||||||
|
|||||||
@@ -2,6 +2,9 @@ package com.xscm.modulemain.activity.user.fragment
|
|||||||
|
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
|
import android.text.Spannable
|
||||||
|
import android.text.SpannableString
|
||||||
|
import android.text.style.ForegroundColorSpan
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import com.blankj.utilcode.util.ActivityUtils
|
import com.blankj.utilcode.util.ActivityUtils
|
||||||
import com.blankj.utilcode.util.ToastUtils
|
import com.blankj.utilcode.util.ToastUtils
|
||||||
@@ -9,15 +12,20 @@ import com.tencent.imsdk.v2.V2TIMConversation
|
|||||||
import com.tencent.qcloud.tuicore.TUIConstants
|
import com.tencent.qcloud.tuicore.TUIConstants
|
||||||
import com.tencent.qcloud.tuikit.tuichat.classicui.page.TUIGroupChatActivity
|
import com.tencent.qcloud.tuikit.tuichat.classicui.page.TUIGroupChatActivity
|
||||||
import com.xscm.modulemain.R
|
import com.xscm.modulemain.R
|
||||||
|
import com.xscm.modulemain.activity.room.activity.RoomActivity
|
||||||
import com.xscm.modulemain.activity.user.activity.HeartCpActivity
|
import com.xscm.modulemain.activity.user.activity.HeartCpActivity
|
||||||
import com.xscm.modulemain.activity.user.activity.TotalRevenueActivity
|
import com.xscm.modulemain.activity.user.activity.TotalRevenueActivity
|
||||||
|
import com.xscm.modulemain.activity.user.activity.UserFamilyActivity
|
||||||
import com.xscm.modulemain.activity.user.activity.UserHomepageActivity
|
import com.xscm.modulemain.activity.user.activity.UserHomepageActivity
|
||||||
import com.xscm.modulemain.adapter.MyFamilyAdapter
|
import com.xscm.modulemain.adapter.MyFamilyAdapter
|
||||||
import com.xscm.modulemain.databinding.FragmentMyFamilyBinding
|
import com.xscm.modulemain.databinding.FragmentMyFamilyBinding
|
||||||
import com.xscm.moduleutil.base.BaseFragment
|
import com.xscm.moduleutil.base.BaseFragment
|
||||||
import com.xscm.moduleutil.bean.MyFamilyBean
|
import com.xscm.moduleutil.bean.MyFamilyBean
|
||||||
import com.xscm.moduleutil.dialog.ConfirmDialog
|
import com.xscm.moduleutil.dialog.ConfirmDialog
|
||||||
|
import com.xscm.moduleutil.http.BaseObserver
|
||||||
|
import com.xscm.moduleutil.http.RetrofitClient
|
||||||
import com.xscm.moduleutil.widget.CommonEmptyView
|
import com.xscm.moduleutil.widget.CommonEmptyView
|
||||||
|
import io.reactivex.disposables.Disposable
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author qx
|
* @Author qx
|
||||||
@@ -29,7 +37,7 @@ class MyFamilyFragment(var data: MyFamilyBean) : BaseFragment<FragmentMyFamilyBi
|
|||||||
private var dataList = mutableListOf<MyFamilyBean.GroupMembersListsBean>()
|
private var dataList = mutableListOf<MyFamilyBean.GroupMembersListsBean>()
|
||||||
private var adapter: MyFamilyAdapter? = null
|
private var adapter: MyFamilyAdapter? = null
|
||||||
private var userId: Int = 0
|
private var userId: Int = 0
|
||||||
private var myFamilyBean : MyFamilyBean= MyFamilyBean()
|
private var myFamilyBean: MyFamilyBean = MyFamilyBean()
|
||||||
|
|
||||||
|
|
||||||
override fun onDestroyView() {
|
override fun onDestroyView() {
|
||||||
@@ -42,8 +50,8 @@ class MyFamilyFragment(var data: MyFamilyBean) : BaseFragment<FragmentMyFamilyBi
|
|||||||
|
|
||||||
override fun initView() {
|
override fun initView() {
|
||||||
mBinding.tvZsyNum2.setOnClickListener {
|
mBinding.tvZsyNum2.setOnClickListener {
|
||||||
val intent= Intent(activity, TotalRevenueActivity::class.java)
|
val intent = Intent(activity, TotalRevenueActivity::class.java)
|
||||||
intent.putExtra("userId",userId)
|
intent.putExtra("userId", userId)
|
||||||
startActivity(intent)
|
startActivity(intent)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,7 +62,7 @@ class MyFamilyFragment(var data: MyFamilyBean) : BaseFragment<FragmentMyFamilyBi
|
|||||||
intent.putExtra(TUIConstants.TUIChat.CHAT_NAME, myFamilyBean.name)
|
intent.putExtra(TUIConstants.TUIChat.CHAT_NAME, myFamilyBean.name)
|
||||||
intent.putExtra(TUIConstants.TUIChat.CHAT_TYPE, V2TIMConversation.V2TIM_GROUP)
|
intent.putExtra(TUIConstants.TUIChat.CHAT_TYPE, V2TIMConversation.V2TIM_GROUP)
|
||||||
startActivity(intent)
|
startActivity(intent)
|
||||||
}else{
|
} else {
|
||||||
ToastUtils.showLong("家族群至少需要签约一位徒弟")
|
ToastUtils.showLong("家族群至少需要签约一位徒弟")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -64,12 +72,10 @@ class MyFamilyFragment(var data: MyFamilyBean) : BaseFragment<FragmentMyFamilyBi
|
|||||||
intent.putExtra("userId", myFamilyBean.user_id.toString())
|
intent.putExtra("userId", myFamilyBean.user_id.toString())
|
||||||
startActivity(intent)
|
startActivity(intent)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getLayoutId(): Int {
|
override fun getLayoutId(): Int {
|
||||||
return R.layout.fragment_my_family
|
return R.layout.fragment_my_family
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@@ -88,40 +94,50 @@ class MyFamilyFragment(var data: MyFamilyBean) : BaseFragment<FragmentMyFamilyBi
|
|||||||
|
|
||||||
private fun queren1(
|
private fun queren1(
|
||||||
type: Int,
|
type: Int,
|
||||||
content: String?,
|
content: SpannableString?,
|
||||||
userId: String,
|
userId: String,
|
||||||
) {
|
) {
|
||||||
// 创建并显示确认对话框
|
// 创建并显示确认对话框
|
||||||
ConfirmDialog(
|
val dialog = ConfirmDialog(
|
||||||
ActivityUtils.getTopActivity(),
|
ActivityUtils.getTopActivity(),
|
||||||
"续约提示",
|
"续约提示",
|
||||||
content,
|
content,
|
||||||
if (type == 1) "确认免费续约" else "确认续约",
|
if (type == 1) "确认免费续约" else "确认续约",
|
||||||
"取消",
|
"取消",
|
||||||
View.OnClickListener { v: View? ->
|
{ v: View? ->
|
||||||
if (type == 1) {
|
RetrofitClient.getInstance()
|
||||||
|
.freeReSign(type, userId, object : BaseObserver<String>() {
|
||||||
|
override fun onSubscribe(d: Disposable) {
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
override fun onNext(t: String) {
|
||||||
val userids = userId.toInt()
|
(ActivityUtils.getTopActivity() as? UserFamilyActivity)?.let { userFamilyActivity ->
|
||||||
val intent = Intent(ActivityUtils.getTopActivity(), HeartCpActivity::class.java)
|
userFamilyActivity.upData()
|
||||||
intent.putExtra("userId", userids)
|
}
|
||||||
startActivity(intent)
|
}
|
||||||
}
|
|
||||||
|
});
|
||||||
},
|
},
|
||||||
View.OnClickListener { v: View? -> }, false, 0
|
{ v: View? -> }, false, 0
|
||||||
).show()
|
)
|
||||||
|
|
||||||
|
dialog.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun myFamily1(data: MyFamilyBean) {
|
fun myFamily1(data: MyFamilyBean) {
|
||||||
|
|
||||||
myFamilyBean= data
|
myFamilyBean = data
|
||||||
userId = data.user_id
|
userId = data.user_id
|
||||||
dataList.clear()
|
dataList.clear()
|
||||||
dataList.addAll(data.group_members_lists)
|
dataList.addAll(data.group_members_lists)
|
||||||
|
|
||||||
mBinding.headView.setData(data.group_owner_info?.avatar,data.group_owner_info?.dress,data.group_owner_info?.nobility_image)
|
mBinding.headView.setData(
|
||||||
|
data.group_owner_info?.avatar,
|
||||||
|
data.group_owner_info?.dress,
|
||||||
|
data.group_owner_info?.nobility_image
|
||||||
|
)
|
||||||
mBinding.tvUserName.text = data.group_owner_info?.nickname
|
mBinding.tvUserName.text = data.group_owner_info?.nickname
|
||||||
if (data.group_owner_info?.nickname_color?.isNotEmpty() == true){
|
if (data.group_owner_info?.nickname_color?.isNotEmpty() == true) {
|
||||||
mBinding.tvUserName.startColor = Color.parseColor(data.group_owner_info?.nickname_color)
|
mBinding.tvUserName.startColor = Color.parseColor(data.group_owner_info?.nickname_color)
|
||||||
mBinding.tvUserName.shineColor = Color.parseColor(data.group_owner_info?.nickname_color)
|
mBinding.tvUserName.shineColor = Color.parseColor(data.group_owner_info?.nickname_color)
|
||||||
mBinding.tvUserName.endColor = Color.parseColor(data.group_owner_info?.nickname_color)
|
mBinding.tvUserName.endColor = Color.parseColor(data.group_owner_info?.nickname_color)
|
||||||
@@ -133,7 +149,7 @@ class MyFamilyFragment(var data: MyFamilyBean) : BaseFragment<FragmentMyFamilyBi
|
|||||||
mBinding.tvZsyNum.text = data.group_earnings
|
mBinding.tvZsyNum.text = data.group_earnings
|
||||||
mBinding.tvSignNum.setText("签约次数:${data.group_members_num}")
|
mBinding.tvSignNum.setText("签约次数:${data.group_members_num}")
|
||||||
|
|
||||||
adapter = MyFamilyAdapter(activity!!,userId, R.layout.item_family_members, dataList)
|
adapter = MyFamilyAdapter(activity!!, userId, R.layout.item_family_members, dataList)
|
||||||
mBinding.recyclerView.adapter = adapter
|
mBinding.recyclerView.adapter = adapter
|
||||||
val commonEmptyView = CommonEmptyView(activity!!)
|
val commonEmptyView = CommonEmptyView(activity!!)
|
||||||
commonEmptyView.setImg(R.mipmap.ic_empty)
|
commonEmptyView.setImg(R.mipmap.ic_empty)
|
||||||
@@ -143,8 +159,29 @@ class MyFamilyFragment(var data: MyFamilyBean) : BaseFragment<FragmentMyFamilyBi
|
|||||||
adapter?.setOnItemChildClickListener { adapter, view, position ->
|
adapter?.setOnItemChildClickListener { adapter, view, position ->
|
||||||
if (view.id == R.id.tv_renew) {
|
if (view.id == R.id.tv_renew) {
|
||||||
val item = dataList[position]
|
val item = dataList[position]
|
||||||
queren1(1, "是否确认免费续约", item.user_id.toString())
|
|
||||||
}else if (view.id == R.id.iv_head) {
|
if (item.free_renewal > 0) {
|
||||||
|
queren1(
|
||||||
|
1,
|
||||||
|
onMessage(1, item.nickname, item.free_renewal, null, null, null),
|
||||||
|
item.user_id.toString()
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
queren1(
|
||||||
|
2,
|
||||||
|
onMessage(
|
||||||
|
2,
|
||||||
|
item.nickname,
|
||||||
|
item.free_renewal,
|
||||||
|
item.sign_user_ratio,
|
||||||
|
item.sign_times,
|
||||||
|
item.market_value.toInt()
|
||||||
|
),
|
||||||
|
item.user_id.toString()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (view.id == R.id.iv_head) {
|
||||||
val item = dataList[position]
|
val item = dataList[position]
|
||||||
val intent = Intent(activity, UserHomepageActivity::class.java)
|
val intent = Intent(activity, UserHomepageActivity::class.java)
|
||||||
intent.putExtra("userId", item.user_id.toString())
|
intent.putExtra("userId", item.user_id.toString())
|
||||||
@@ -152,4 +189,43 @@ class MyFamilyFragment(var data: MyFamilyBean) : BaseFragment<FragmentMyFamilyBi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun onMessage(
|
||||||
|
type: Int,//类型 1:免费续约 2:续签 花金币
|
||||||
|
userName: String? = null, //当前徒弟的名称
|
||||||
|
remainingCount: Int? = 0, //当前免费续签次数
|
||||||
|
percentage: Int? = null, //身价的百分比,是按照这个进行扣款的
|
||||||
|
days: Int? = null,// 花钱后最总的时长
|
||||||
|
userValue: Int? = null //当前徒弟的身价
|
||||||
|
): SpannableString {
|
||||||
|
return when (type) {
|
||||||
|
1 -> SpannableString("尊敬的用户:\n 您的徒弟【${userName ?: "?"}】当前为首次签约的免费签约期。续约后,师徒合约将延续7天,您剩余的免费续约次数:${remainingCount ?: "?"} 次")
|
||||||
|
2 -> {
|
||||||
|
// 计算预估金币数,向上取整
|
||||||
|
val actualUserValue = userValue ?: 1000 // 如果未提供用户身价,默认使用1000
|
||||||
|
val percentageValue = percentage ?: 10
|
||||||
|
val estimatedCoins =
|
||||||
|
kotlin.math.ceil(actualUserValue * percentageValue / 100.0).toInt()
|
||||||
|
|
||||||
|
val mainText =
|
||||||
|
"尊敬的用户:\n 本次续约将预估支付${estimatedCoins}金币(【${userName ?: "?"}】身价的 ${percentageValue}% )作为续约费用,续约后,师徒合约将延长 ${days ?: 30} 天\n\n"
|
||||||
|
val noteText = "注:支付价格是预估价格,徒弟身价是实时变化,续约后无法取消"
|
||||||
|
val fullText = "$mainText$noteText"
|
||||||
|
val spannable = SpannableString(fullText)
|
||||||
|
|
||||||
|
// 设置注释部分为红色
|
||||||
|
val color = Color.RED
|
||||||
|
spannable.setSpan(
|
||||||
|
ForegroundColorSpan(color),
|
||||||
|
mainText.length,
|
||||||
|
fullText.length,
|
||||||
|
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE
|
||||||
|
)
|
||||||
|
|
||||||
|
spannable
|
||||||
|
}
|
||||||
|
|
||||||
|
else -> SpannableString("")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user