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

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 { object CpDataParser {
fun inviteMsg2cpListEntity(msgEntity: CpInviteInfo) = UserCpListEntity( fun inviteMsg2cpListEntity(msgEntity: CpInviteInfo) = UserCpListEntity(
msgEntity.acceptUid, msgEntity.acceptAvatar, msgEntity.acceptNick, msgEntity.acceptUid,
msgEntity.acceptGender, msgEntity.replyExpireTime.toLong(), msgEntity.declaration, msgEntity.acceptAvatar,
msgEntity.cpId,msgEntity.replyExpireTime,0, msgEntity.inviteUid, msgEntity.inviteAvatar, msgEntity.inviteNick, msgEntity.acceptNick,
msgEntity.inviteGender, 0, msgEntity.propsId, msgEntity.propsImg, msgEntity.acceptGender,
msgEntity.propsName, msgEntity.propsPrice, 0, 0, msgEntity.replyExpireTime.toLong() 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 mBinding.swipeRefresh.isRefreshing = false
} }
} }
vm.cpInviteDetailData.observe(this) {
showReplyDialog(it)
}
} }
private fun showReplyDialog(item: UserCpListEntity) { private fun showReplyDialog(item: UserCpListEntity) {
@@ -72,6 +75,10 @@ class CpInviteRecordActivity : BaseBindingActivity<ActivityCpInviteRecordBinding
override fun onRefuse() { override fun onRefuse() {
showConfirmDialog(item, false) showConfirmDialog(item, false)
} }
override fun onTimeOut() {
queryRecord(type)
}
} }
openDialog() openDialog()
} }
@@ -81,7 +88,7 @@ class CpInviteRecordActivity : BaseBindingActivity<ActivityCpInviteRecordBinding
adapter = InviteRecordAdapter(this) adapter = InviteRecordAdapter(this)
adapter.onVisitClickListener = object : InviteRecordAdapter.OnVisitClickListener { adapter.onVisitClickListener = object : InviteRecordAdapter.OnVisitClickListener {
override fun onVisitClick(item: UserCpListEntity) { override fun onVisitClick(item: UserCpListEntity) {
showReplyDialog(item) vm.getCpInviteDetail(item.cpId)
} }
} }
val layoutManager = LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false) val layoutManager = LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false)
@@ -109,7 +116,7 @@ class CpInviteRecordActivity : BaseBindingActivity<ActivityCpInviteRecordBinding
val shb = CpViewHelper.getColorSpan( val shb = CpViewHelper.getColorSpan(
"是否${if (isAgree) "同意" else "拒绝"}${item.inviteUserNick}成为CP\n", "是否${if (isAgree) "同意" else "拒绝"}${item.inviteUserNick}成为CP\n",
Color.parseColor("#4C5AF1"), Color.parseColor("#4C5AF1"),
5, item.inviteUserNick.length 5, 5 + item.inviteUserNick.length
) )
if (isAgree) { if (isAgree) {
val str = "(同意将自动拒绝其他邀请)" val str = "(同意将自动拒绝其他邀请)"

View File

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

View File

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

View File

@@ -102,4 +102,13 @@ interface Api {
suspend fun cpTaskProcess( suspend fun cpTaskProcess(
@Query("uid") uid: Long @Query("uid") uid: Long
): ServiceResult<CpTaskEntity> ): 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 { launchRequest {
api.cpTaskProcess(uid) 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() private val _cpTaskData: MutableLiveData<CpTaskEntity> = MutableLiveData()
val cpTaskData: LiveData<CpTaskEntity> = _cpTaskData val cpTaskData: LiveData<CpTaskEntity> = _cpTaskData
//记录详情
private val _cpInviteDetailData: MutableLiveData<UserCpListEntity> = MutableLiveData()
val cpInviteDetailData: LiveData<UserCpListEntity> = _cpInviteDetailData
fun getCpInvitePageData(acceptUid: Long) { fun getCpInvitePageData(acceptUid: Long) {
_loadingLiveData.value = true _loadingLiveData.value = true
safeLaunch( 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 = { private val dealCpDataError: (e: Throwable) -> Unit = {
_loadingLiveData.value = false _loadingLiveData.value = false
it.message.toast() it.message.toast()

View File

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

View File

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

View File

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

View File

@@ -1,15 +1,17 @@
package com.yizhuan.xchat_android_core.relation.cp package com.yizhuan.xchat_android_core.relation.cp
import com.google.gson.annotations.SerializedName
data class UserCpListEntity( data class UserCpListEntity(
val acceptUid: Long = 0, val acceptUid: Long = 0,
val acceptUserAvatar: String = "", val acceptUserAvatar: String = "",
val acceptUserNick: String = "", val acceptUserNick: String = "",
val acceptUserSex: Int = 0,//1-男 2女 val acceptUserSex: Int = 0,//1-男 2女
val createTime: Long=0, val createTime: Long = 0,
val declaration: String = "",//关系誓言 val declaration: String = "",//关系誓言
val cpId: Int = 0,//邀请记录id val cpId: Int = 0,//邀请记录id
val replyExpireTime: Int = 0, val replyExpireTime: Int = 0,
val acceptTime:Long=0, val acceptTime: Long = 0,
val inviteUid: Long = 0,//邀请人uid val inviteUid: Long = 0,//邀请人uid
val inviteUserAvatar: String = "",//邀请方头像 val inviteUserAvatar: String = "",//邀请方头像
val inviteUserNick: String = "", val inviteUserNick: String = "",
@@ -18,7 +20,7 @@ data class UserCpListEntity(
val propsId: Int = 0, val propsId: Int = 0,
val propsImg: String = "", val propsImg: String = "",
val propsName: String = "", val propsName: String = "",
val propsPrice: String = "", val propsPrice: Double = 0.0,
val state: Int = 0,//状态1-邀请中2-CP中3-拒绝4-解绑中5-解绑完成 val state: Int = 0,//状态1-邀请中2-CP中3-拒绝4-解绑中5-解绑完成
val unboundUid: Int = 0,//解绑人 val unboundUid: Int = 0,//解绑人
val updateTime: Long = 0 val updateTime: Long = 0