邀请记录增加详情接口 修改礼物价格显示

This commit is contained in:
yitao_hello
2022-02-25 21:16:28 +08:00
parent ffc8fc4f94
commit 214bc49033
11 changed files with 83 additions and 17 deletions

View File

@@ -5,11 +5,27 @@ import com.yizhuan.xchat_android_core.relation.cp.UserCpListEntity
object CpDataParser {
fun inviteMsg2cpListEntity(msgEntity: CpInviteInfo) = UserCpListEntity(
msgEntity.acceptUid, msgEntity.acceptAvatar, msgEntity.acceptNick,
msgEntity.acceptGender, msgEntity.replyExpireTime.toLong(), msgEntity.declaration,
msgEntity.cpId,msgEntity.replyExpireTime,0, msgEntity.inviteUid, msgEntity.inviteAvatar, msgEntity.inviteNick,
msgEntity.inviteGender, 0, msgEntity.propsId, msgEntity.propsImg,
msgEntity.propsName, msgEntity.propsPrice, 0, 0, msgEntity.replyExpireTime.toLong()
msgEntity.acceptUid,
msgEntity.acceptAvatar,
msgEntity.acceptNick,
msgEntity.acceptGender,
msgEntity.replyExpireTime.toLong(),
msgEntity.declaration,
msgEntity.cpId,
msgEntity.replyExpireTime,
0,
msgEntity.inviteUid,
msgEntity.inviteAvatar,
msgEntity.inviteNick,
msgEntity.inviteGender,
0,
msgEntity.propsId,
msgEntity.propsImg,
msgEntity.propsName,
msgEntity.propsPrice,
0,
0,
msgEntity.replyExpireTime.toLong()
)
/**

View File

@@ -59,6 +59,9 @@ class CpInviteRecordActivity : BaseBindingActivity<ActivityCpInviteRecordBinding
mBinding.swipeRefresh.isRefreshing = false
}
}
vm.cpInviteDetailData.observe(this) {
showReplyDialog(it)
}
}
private fun showReplyDialog(item: UserCpListEntity) {
@@ -72,6 +75,10 @@ class CpInviteRecordActivity : BaseBindingActivity<ActivityCpInviteRecordBinding
override fun onRefuse() {
showConfirmDialog(item, false)
}
override fun onTimeOut() {
queryRecord(type)
}
}
openDialog()
}
@@ -81,7 +88,7 @@ class CpInviteRecordActivity : BaseBindingActivity<ActivityCpInviteRecordBinding
adapter = InviteRecordAdapter(this)
adapter.onVisitClickListener = object : InviteRecordAdapter.OnVisitClickListener {
override fun onVisitClick(item: UserCpListEntity) {
showReplyDialog(item)
vm.getCpInviteDetail(item.cpId)
}
}
val layoutManager = LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false)
@@ -109,7 +116,7 @@ class CpInviteRecordActivity : BaseBindingActivity<ActivityCpInviteRecordBinding
val shb = CpViewHelper.getColorSpan(
"是否${if (isAgree) "同意" else "拒绝"}${item.inviteUserNick}成为CP\n",
Color.parseColor("#4C5AF1"),
5, item.inviteUserNick.length
5, 5 + item.inviteUserNick.length
)
if (isAgree) {
val str = "(同意将自动拒绝其他邀请)"

View File

@@ -67,8 +67,12 @@ class CpInvitePageDialog(context: Context) : View.OnClickListener,
hint = builder
}
binding.tvPrice.apply {
CpViewHelper.setInviteGiftPriceStyle(context, invitePageEntity?.propsPrice ?: "", this)
invitePageEntity?.let {
CpViewHelper.setInviteGiftPriceStyle(
context,
it.propsPrice.toInt().toString(),
binding.tvPrice
)
}
}

View File

@@ -47,7 +47,11 @@ class CpInviteReplyDialog(context: Context) :
0,
data.inviteUserNick.length
)
CpViewHelper.setInviteGiftPriceStyle(context, data.propsPrice, binding.tvPrice)
CpViewHelper.setInviteGiftPriceStyle(
context,
data.propsPrice.toInt().toString(),
binding.tvPrice
)
binding.tvDeclaration.text = data.declaration
ImageLoadUtilsV2.loadImage(binding.ivGift, cpInviteData?.propsImg)
}
@@ -84,7 +88,12 @@ class CpInviteReplyDialog(context: Context) :
}
override fun onNext(t: Long) {
val remain = (r - t).toInt()
var remain = (r - t).toInt()
if (remain <= 0) {
remain = 0
stopCountDown()
listener?.onTimeOut()
}
val h = remain / 3600
val m = (remain % 3600) / 60
val s = remain % 3600 % 60
@@ -118,5 +127,6 @@ class CpInviteReplyDialog(context: Context) :
interface ReplyListener {
fun onAgree()
fun onRefuse()
fun onTimeOut()//计时过期
}
}

View File

@@ -102,4 +102,13 @@ interface Api {
suspend fun cpTaskProcess(
@Query("uid") uid: Long
): ServiceResult<CpTaskEntity>
/**
* 邀请记录详情
* /user/couple/cpRecordDetail
*/
@GET("/user/couple/cpRecordDetail")
suspend fun inviteRecordDetail(
@Query("cpId") cpId: Int
): ServiceResult<UserCpListEntity>
}

View File

@@ -62,6 +62,10 @@ object CpModel : BaseModel() {
launchRequest {
api.cpTaskProcess(uid)
}
suspend fun cpInviteDetail(cpId: Int): UserCpListEntity? =
launchRequest {
api.inviteRecordDetail(cpId)
}
}

View File

@@ -39,6 +39,10 @@ class CpViewModel : BaseViewModel() {
private val _cpTaskData: MutableLiveData<CpTaskEntity> = MutableLiveData()
val cpTaskData: LiveData<CpTaskEntity> = _cpTaskData
//记录详情
private val _cpInviteDetailData: MutableLiveData<UserCpListEntity> = MutableLiveData()
val cpInviteDetailData: LiveData<UserCpListEntity> = _cpInviteDetailData
fun getCpInvitePageData(acceptUid: Long) {
_loadingLiveData.value = true
safeLaunch(
@@ -175,6 +179,16 @@ class CpViewModel : BaseViewModel() {
)
}
fun getCpInviteDetail(cpId:Int){
safeLaunch(
onError = dealCpDataError,
block = {
_cpInviteDetailData.value = CpModel.cpInviteDetail(cpId)
_loadingLiveData.value = false
}
)
}
private val dealCpDataError: (e: Throwable) -> Unit = {
_loadingLiveData.value = false
it.message.toast()

View File

@@ -81,7 +81,7 @@
android:layout_marginTop="1dp"
android:background="@drawable/bg_invite_dialog_price"
android:gravity="center"
android:text="邀请函\n52000钻石"
tools:text="邀请函\n52000钻石"
android:textColor="@color/white"
android:textSize="@dimen/sp_13"
app:layout_constraintLeft_toLeftOf="parent"

View File

@@ -21,7 +21,7 @@ data class CpInviteInfo(
val propsId: Int = 0,
val propsName: String = "",
val propsImg: String = "",
val propsPrice: String = "",
val propsPrice: Double=0.0,
val recommenTxtList: List<String>? = null,
val declaration: String = ""
)

View File

@@ -17,7 +17,7 @@ data class CpInvitePageEntity(
val propsId: Int=0,
val propsImg: String="",
val propsName: String="",
val propsPrice: String="",
val propsPrice: Double=0.0,
val recommenTxtList:List<String>?=null,
val recommenTxt:String=""
)

View File

@@ -1,5 +1,7 @@
package com.yizhuan.xchat_android_core.relation.cp
import com.google.gson.annotations.SerializedName
data class UserCpListEntity(
val acceptUid: Long = 0,
val acceptUserAvatar: String = "",
@@ -18,7 +20,7 @@ data class UserCpListEntity(
val propsId: Int = 0,
val propsImg: String = "",
val propsName: String = "",
val propsPrice: String = "",
val propsPrice: Double = 0.0,
val state: Int = 0,//状态1-邀请中2-CP中3-拒绝4-解绑中5-解绑完成
val unboundUid: Int = 0,//解绑人
val updateTime: Long = 0