Browse Source

红包详情列表

honghengqiang 1 year ago
parent
commit
ecb4ec121a

+ 7 - 0
baseswago/src/main/java/com/swago/baseswago/inter/RoomApi.kt

@@ -463,4 +463,11 @@ interface RoomApi {
     @FormUrlEncoded
     @POST("/v1/rtc/barrage/send")
     suspend fun sendDanMu(@Field("room_id") room_id: String,@Field("message") message: String):Any
+
+    /**
+     * 红包领取详情
+     */
+    @FormUrlEncoded
+    @POST("/v1/rtc/broadcast/package/detail")
+    suspend fun getRedReceivedList(@Field("package_id") package_id: String):RedReceiveListModel
 }

+ 13 - 0
baseswago/src/main/java/com/swago/baseswago/model/live/RedReceiveListModel.kt

@@ -0,0 +1,13 @@
+package com.swago.baseswago.model.live
+
+data class RedReceiveListModel(
+    val list: List<RedReceiveModel>
+)
+
+data class RedReceiveModel(
+    val created_at: String,
+    val package_coins: String,
+    val user_head_img_url: String,
+    val user_id: String,
+    val user_name: String
+)

BIN
baseswago/src/main/res/mipmap-xxhdpi/ic_lucky_best.webp


+ 2 - 0
baseswago/src/main/res/values/strings.xml

@@ -250,5 +250,7 @@
     <string name="change_password">修改密码</string>
     <string name="pwd_change_success">密码修改成功</string>
     <string name="do_you_confirm_change_pwd">您确定要修改您的密码么?</string>
+    <string name="red_bag_detail">红包详情</string>
+    <string name="lucky_best">手气最佳</string>
 
 </resources>

+ 4 - 0
room/src/main/java/com/swago/room/base/BaseComFragment.kt

@@ -60,6 +60,7 @@ import com.swago.room.gift.GiftDialog
 import com.swago.room.gift.GiftVm
 import com.swago.room.gift.control.SvgPlayerManager
 import com.swago.room.giftdandao.GiftDanDaoManager
+import com.swago.room.hongbao.RedDetailListDialog
 import com.swago.room.hongbao.RedEnvelopResultDialog
 import com.swago.room.hongbao.RedEnvelopeDialog
 import com.swago.room.inter.IFooter
@@ -479,6 +480,9 @@ abstract class BaseComFragment<T : FragmentBaseComBinding> : BaseXFragment<T>(),
                         openGiftDialog(iRoomInfo.getAnchorName(), iRoomInfo.getAnchorId())
                     }
                 }
+                this.openRedDetailDialog =  {
+                    RedDetailListDialog.newInstance(it.id,it.senderAvatar, it.senderName,it.senderLevel).show(parentFragmentManager,"RedDetailListDialog")
+                }
                 this.addSenderMsgToRoomChatList = {
                     addChatMsgToRv(it)
                 }

+ 95 - 0
room/src/main/java/com/swago/room/hongbao/RedDetailListDialog.kt

@@ -0,0 +1,95 @@
+package com.swago.room.hongbao
+
+import android.os.Bundle
+import android.view.Gravity
+import androidx.fragment.app.viewModels
+import androidx.recyclerview.widget.LinearLayoutManager
+import androidx.recyclerview.widget.RecyclerView
+import com.chad.library.adapter.base.BaseQuickAdapter
+import com.swago.baseswago.cusview.SwagoRecyclerView
+import com.swago.baseswago.dialog.BaseListDialogFragment
+import com.swago.baseswago.model.live.RedReceiveModel
+import com.swago.baseswago.util.AppContext
+import com.swago.loadUrl
+import com.swago.room.R
+import com.swago.room.databinding.DialogRedDetailListBinding
+import com.swago.room.vm.RoomOtherVm
+
+class RedDetailListDialog : BaseListDialogFragment<DialogRedDetailListBinding,RedReceiveModel>() {
+
+    private val roomOtherVm  by viewModels<RoomOtherVm>()
+
+    private var packageId = ""
+    private var avatar = ""
+    private var name = ""
+    private var level = 1
+
+    companion object{
+        fun newInstance(packageId:String,avatar:String,name:String,level:Int): RedDetailListDialog {
+            val args = Bundle()
+            args.putString("packageId",packageId)
+            args.putString("avatar",avatar)
+            args.putString("name",name)
+            args.putInt("level",level)
+            val fragment = RedDetailListDialog()
+            fragment.arguments = args
+            return fragment
+        }
+    }
+
+    init {
+        setGravity(Gravity.BOTTOM)
+        setCanCancel(false)
+        setDimAmount(0.5f)
+    }
+
+
+    override val smartRecyclerView: SwagoRecyclerView<RedReceiveModel> by lazy {
+        binding.swagoRv as SwagoRecyclerView<RedReceiveModel>
+    }
+    override val adapter: BaseQuickAdapter<RedReceiveModel, *> by lazy {
+        RedReceivedAdapter()
+    }
+
+    override val layoutManager: RecyclerView.LayoutManager by lazy {
+        LinearLayoutManager(context)
+    }
+    override val loadData: (page: Int) -> Unit = {
+        roomOtherVm.getRedReceivedList(packageId)
+    }
+
+    override fun initViewData() {
+        binding.ivClose.setOnClickListener {
+            dismissAllowingStateLoss()
+        }
+        arguments?.let {
+            packageId = it.getString("packageId","")
+            avatar = it.getString("avatar","")
+            name = it.getString("name","")
+            level = it.getInt("level",1)
+            activity?.let {
+                binding.ivAvatar.loadUrl(it,avatar)
+                binding.tvName.text = AppContext.getContext().resources.getString(R.string.from_who_red_envelope).format(name)
+                binding.tvLevel.setUserLevel(level)
+            }
+        }
+    }
+
+    override fun initLiveData() {
+        roomOtherVm.redListLiveData.observe(this){
+            if (it == null){
+                smartRecyclerView.onFetchDataError()
+            }else{
+                smartRecyclerView.onFetchDataFinish(it,true)
+            }
+        }
+    }
+
+    override fun loadMoreNeed(): Boolean {
+        return false
+    }
+
+    override fun refreshNeed(): Boolean {
+        return false
+    }
+}

+ 11 - 0
room/src/main/java/com/swago/room/hongbao/RedEnvelopResultDialog.kt

@@ -33,6 +33,7 @@ class RedEnvelopResultDialog : BaseXDFragment<DialogRedEnvelopeResultBinding>()
     private var name = ""
 
     var openGiftDialog:(()->Unit)? = null
+    var openRedDetailDialog:(()->Unit)? = null
     var addSenderMsgToRoomChatList: ((roomChatMsgBean: RoomChatMsgBean) -> Unit)? = null
 
     companion object {
@@ -72,6 +73,13 @@ class RedEnvelopResultDialog : BaseXDFragment<DialogRedEnvelopeResultBinding>()
                     dismissAllowingStateLoss()
                 }
             })
+
+            binding.tvReceiveDetail.setOnClickListener(object:NoDoubleClickListener(){
+                override fun onClick() {
+                    openRedDetailDialog?.invoke()
+                    dismissAllowingStateLoss()
+                }
+            })
         }
     }
 
@@ -82,6 +90,7 @@ class RedEnvelopResultDialog : BaseXDFragment<DialogRedEnvelopeResultBinding>()
             binding.tvCongratulation.text = AppContext.getContext().resources.getString(R.string.congratulation)
             binding.tvReceive.text = AppContext.getContext().resources.getString(R.string.receive_red_envelope_coin)
             binding.tvToSendGift.visibility = View.VISIBLE
+            binding.tvReceiveDetail.visibility = View.VISIBLE
             val content =  AppContext.getContext().resources.getString(R.string.thank_for_boss).format(it,name)
             UserInfo.getUserInfo()?.let {
                 val roomChatMsgBean = RoomChatMsgBean()
@@ -144,6 +153,7 @@ class RedEnvelopResultDialog : BaseXDFragment<DialogRedEnvelopeResultBinding>()
                     binding.tvCongratulation.text = AppContext.getContext().resources.getString(R.string.sorry_fail_to_get)
                     binding.tvReceive.text = AppContext.getContext().resources.getString(R.string.konw)
                     binding.tvToSendGift.visibility = View.GONE
+                    binding.tvReceiveDetail.visibility = View.GONE
                 }
 
                 540 -> {
@@ -152,6 +162,7 @@ class RedEnvelopResultDialog : BaseXDFragment<DialogRedEnvelopeResultBinding>()
                     binding.tvCongratulation.text = AppContext.getContext().resources.getString(R.string.already_receive_red_envelope)
                     binding.tvReceive.text = AppContext.getContext().resources.getString(R.string.konw)
                     binding.tvToSendGift.visibility = View.GONE
+                    binding.tvReceiveDetail.visibility = View.GONE
                 }
             }
         }

+ 22 - 0
room/src/main/java/com/swago/room/hongbao/RedReceivedAdapter.kt

@@ -0,0 +1,22 @@
+package com.swago.room.hongbao
+
+import com.chad.library.adapter.base.BaseQuickAdapter
+import com.chad.library.adapter.base.BaseViewHolder
+import com.swago.baseswago.model.live.RedReceiveModel
+import com.swago.loadUrl
+import com.swago.room.R
+import de.hdodenhof.circleimageview.CircleImageView
+
+class RedReceivedAdapter :  BaseQuickAdapter<RedReceiveModel, BaseViewHolder>(R.layout.item_red_bag, arrayListOf()) {
+
+    override fun convert(helper: BaseViewHolder?, item: RedReceiveModel?) {
+        helper?.apply {
+            item?.let {
+                itemView.findViewById<CircleImageView>(R.id.ivAvatar).loadUrl(itemView.context,it.user_head_img_url)
+                setText(R.id.tvName,it.user_name)
+                setText(R.id.tvTime,it.created_at)
+                setText(R.id.tvCoin,it.package_coins)
+            }
+        }
+    }
+}

+ 1 - 1
room/src/main/java/com/swago/room/user/UserRoomFragment.kt

@@ -25,6 +25,7 @@ import com.swago.room.dialog.ShareDialog
 import com.swago.room.enum.RoomType
 import com.swago.room.game.GameListDialog
 import com.swago.room.gift.GiftDialog
+import com.swago.room.hongbao.RedDetailListDialog
 import com.swago.room.hongbao.RedEnvelopBroadcastDialog
 import com.swago.room.hongbao.RedEnvelopeDialog
 import com.swago.room.inter.IFooter
@@ -87,7 +88,6 @@ class UserRoomFragment : BaseComFragment<FragmentBaseComBinding>() {
             } else {
                 openSendMessageDialog()
             }
-
         }
 
         footerView.openMessageFun = {

+ 19 - 0
room/src/main/java/com/swago/room/vm/RoomOtherVm.kt

@@ -10,6 +10,7 @@ import com.swago.baseswago.inter.ApiManager
 import com.swago.baseswago.model.RedEnvelope
 import com.swago.baseswago.model.live.ErrorModel
 import com.swago.baseswago.model.live.RankListModel
+import com.swago.baseswago.model.live.RedReceiveModel
 import com.swago.baseswago.model.live.ShareConfig
 import com.swago.baseswago.model.live.game.GameListModel
 import com.swago.baseswago.util.*
@@ -173,4 +174,22 @@ class RoomOtherVm (application: Application) : BaseViewModel(application){
         }
     }
 
+    /**
+     * 红包领取详情
+     */
+    val redListLiveData by lazy {
+        MutableLiveData<List<RedReceiveModel>?>()
+    }
+
+    fun getRedReceivedList(package_id:String){
+        requestData2 {
+            requestData {
+                val data =  ApiManager.roomApi.getRedReceivedList(package_id)
+                redListLiveData.value = data.list
+            }
+            requestError {
+                redListLiveData.value = null
+            }
+        }
+    }
 }

+ 87 - 0
room/src/main/res/layout/dialog_red_detail_list.xml

@@ -0,0 +1,87 @@
+<?xml version="1.0" encoding="utf-8"?>
+<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    xmlns:tools="http://schemas.android.com/tools"
+    tools:background="#000"
+    xmlns:app="http://schemas.android.com/apk/res-auto">
+
+    
+    <androidx.constraintlayout.widget.ConstraintLayout
+        android:id="@+id/cl"
+        app:layout_constraintBottom_toBottomOf="parent"
+        android:layout_width="match_parent"
+        app:layout_constraintDimensionRatio="h,360,541"
+        android:layout_height="0dp">
+
+        <ImageView
+            android:id="@+id/iv"
+            app:layout_constraintBottom_toBottomOf="parent"
+            android:background="@mipmap/bg_red_bag_list"
+            android:layout_width="match_parent"
+            android:layout_height="500dp"/>
+
+        <TextView
+            android:id="@+id/tvTitle"
+            android:textSize="17dp"
+            android:textColor="#fff"
+            android:layout_marginTop="14dp"
+            android:text="@string/red_bag_detail"
+            app:layout_constraintTop_toTopOf="parent"
+            app:layout_constraintStart_toStartOf="parent"
+            app:layout_constraintEnd_toEndOf="parent"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"/>
+        
+        <de.hdodenhof.circleimageview.CircleImageView
+            android:id="@+id/ivAvatar"
+            app:layout_constraintStart_toStartOf="parent"
+            app:layout_constraintEnd_toEndOf="parent"
+            app:layout_constraintTop_toTopOf="parent"
+            android:layout_marginTop="60dp"
+            android:layout_width="64dp"
+            android:layout_height="64dp"/>
+
+        <TextView
+            android:id="@+id/tvName"
+            android:textSize="14dp"
+            android:textColor="#131B23"
+            android:layout_marginTop="8dp"
+            app:layout_constraintStart_toStartOf="parent"
+            app:layout_constraintEnd_toEndOf="parent"
+            app:layout_constraintTop_toBottomOf="@+id/ivAvatar"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"/>
+
+        <com.swago.baseswago.cusview.SwagoLevelView
+            android:id="@+id/tvLevel"
+            app:layout_constraintStart_toStartOf="parent"
+            app:layout_constraintEnd_toEndOf="parent"
+            app:layout_constraintTop_toBottomOf="@+id/tvName"
+            android:layout_marginTop="8dp"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"/>
+
+        <ImageView
+            android:id="@+id/ivClose"
+            android:src="@mipmap/close"
+            app:layout_constraintEnd_toEndOf="parent"
+            app:layout_constraintTop_toTopOf="parent"
+            android:layout_marginEnd="16dp"
+            android:layout_marginTop="12dp"
+            android:layout_width="24dp"
+            android:layout_height="24dp"/>
+
+        <com.swago.baseswago.cusview.SwagoRecyclerView
+            android:id="@+id/swagoRv"
+            android:layout_marginTop="18dp"
+            app:layout_constraintTop_toBottomOf="@+id/tvLevel"
+            app:layout_constraintBottom_toBottomOf="@+id/iv"
+            android:layout_width="match_parent"
+            android:layout_height="0dp"/>
+
+
+    </androidx.constraintlayout.widget.ConstraintLayout>
+
+
+</androidx.constraintlayout.widget.ConstraintLayout>

+ 19 - 2
room/src/main/res/layout/dialog_red_envelope_result.xml

@@ -107,8 +107,25 @@
             android:gravity="center_vertical"
             android:visibility="gone"
             tools:visibility="visible"
-            app:layout_constraintStart_toStartOf="parent"
-            app:layout_constraintEnd_toEndOf="parent"
+            app:layout_constraintStart_toStartOf="@+id/ivBg"
+            app:layout_constraintEnd_toStartOf="@+id/tvReceiveDetail"
+            app:layout_constraintBottom_toBottomOf="parent"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"/>
+
+        <com.swago.baseswago.cusview.MediumTextView
+            android:id="@+id/tvReceiveDetail"
+            android:text="查看领取详情"
+            android:textColor="#fff"
+            android:textSize="12dp"
+            android:drawableEnd="@mipmap/icon_arrow_right"
+            android:layout_marginBottom="20dp"
+            android:drawablePadding="3dp"
+            android:gravity="center_vertical"
+            android:visibility="gone"
+            tools:visibility="visible"
+            app:layout_constraintStart_toEndOf="@+id/tvToSendGift"
+            app:layout_constraintEnd_toEndOf="@+id/ivBg"
             app:layout_constraintBottom_toBottomOf="parent"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"/>

+ 77 - 0
room/src/main/res/layout/item_red_bag.xml

@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="utf-8"?>
+<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="64dp"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:tools="http://schemas.android.com/tools">
+    
+    <de.hdodenhof.circleimageview.CircleImageView
+        android:id="@+id/ivAvatar"
+        android:layout_marginStart="16dp"
+        app:layout_constraintTop_toTopOf="parent"
+        app:layout_constraintBottom_toBottomOf="parent"
+        app:layout_constraintStart_toStartOf="parent"
+        android:layout_width="44dp"
+        android:layout_height="44dp"/>
+
+    <TextView
+        android:id="@+id/tvName"
+        android:textColor="#131B23"
+        android:textSize="16dp"
+        android:maxLines="1"
+        tools:text="Name"
+        android:layout_marginStart="12dp"
+        android:layout_marginTop="13dp"
+        app:layout_constraintTop_toTopOf="parent"
+        app:layout_constraintStart_toEndOf="@+id/ivAvatar"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"/>
+
+    <TextView
+        android:id="@+id/tvTime"
+        android:textColor="#435568"
+        android:textSize="14dp"
+        android:maxLines="1"
+        tools:text="time"
+        android:layout_marginStart="12dp"
+        android:layout_marginBottom="12dp"
+        app:layout_constraintBottom_toBottomOf="parent"
+        app:layout_constraintStart_toEndOf="@+id/ivAvatar"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"/>
+
+    <TextView
+        android:id="@+id/tvCoin"
+        android:drawableStart="@mipmap/icon_coin"
+        android:textColor="#131B23"
+        android:textSize="16dp"
+        android:maxLines="1"
+        tools:text="6065"
+        android:textStyle="bold"
+        android:layout_marginEnd="16dp"
+        android:layout_marginTop="13dp"
+        android:drawablePadding="2dp"
+        app:layout_constraintTop_toTopOf="parent"
+        app:layout_constraintEnd_toEndOf="parent"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"/>
+
+    <TextView
+        android:id="@+id/tvLucky"
+        android:drawableStart="@mipmap/ic_lucky_best"
+        android:textColor="#FB8C4E"
+        android:textSize="10dp"
+        android:maxLines="1"
+        android:text="@string/lucky_best"
+        android:textStyle="bold"
+        android:gravity="center"
+        android:layout_marginEnd="16dp"
+        android:layout_marginBottom="11dp"
+        android:drawablePadding="2dp"
+        android:visibility="gone"
+        app:layout_constraintBottom_toBottomOf="parent"
+        app:layout_constraintEnd_toEndOf="parent"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"/>
+
+</androidx.constraintlayout.widget.ConstraintLayout>

BIN
room/src/main/res/mipmap-xxhdpi/bg_red_bag_list.webp