ソースを参照

feat: pk优化;2C

tongmengxiao 5 ヶ月 前
コミット
71bfabb64c

BIN
baseswago/src/main/res/mipmap-xxhdpi/icon_audioing.png


BIN
baseswago/src/main/res/mipmap-xxhdpi/icon_living.png


+ 2 - 2
home/src/main/res/layout/item_home.xml

@@ -18,7 +18,7 @@
         android:layout_marginEnd="8dp"
         android:layout_marginTop="8dp"
         app:layout_constraintTop_toTopOf="parent"
-        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintRight_toRightOf="parent"
         android:layout_width="18dp"
         android:layout_height="18dp"/>
 
@@ -29,7 +29,7 @@
         android:layout_marginTop="8dp"
         android:layout_marginStart="8dp"
         app:layout_constraintTop_toTopOf="parent"
-        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintLeft_toLeftOf="parent"
         android:src="@mipmap/ic_live_lock"
         android:visibility="gone"/>
 

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

@@ -668,6 +668,10 @@ abstract class BaseComFragment<T : FragmentBaseComBinding> : BaseXFragment<T>(),
                 }
             }.show(childFragmentManager, "RedEnvelopResultDialog")
         }
+        pkVm.pkState = { pkState ->
+            binding.bannerView.visibility = if (pkState) View.INVISIBLE else View.VISIBLE
+            binding.videoPlayBannerView.visibility = if (pkState) View.INVISIBLE else View.VISIBLE
+        }
     }
 
     fun openShareDialog() {

+ 1 - 1
room/src/main/java/com/swago/room/pk/PKAudienceAdapter.kt

@@ -15,7 +15,7 @@ class PKAudienceAdapter : BaseQuickAdapter<PKSeat,BaseViewHolder>(R.layout.item_
                 itemView.findViewById<CircleImageView>(R.id.ivAvatar).loadUrl(itemView.context,it.userAvatar)
                 when(layoutPosition){
                     0 -> {
-                        setImageResource(R.id.ivPosition,R.mipmap.first)
+                        setImageResource(R.id.ivPosition,R.mipmap.icon_pk_mvp)
                     }
                     1 -> {
                         setImageResource(R.id.ivPosition,R.mipmap.second)

+ 11 - 17
room/src/main/java/com/swago/room/pk/PKLayoutView.kt

@@ -51,6 +51,9 @@ class PKLayoutView : ConstraintLayout, IRoomActiveListener, IPKListener,
     //主播获取PK信息
     var doGetPKInfoFun:(()->Unit)? = null
 
+    //跳转到对方Pk直播间
+    var doOtherRoomFun:((startPKModel: StartPKModel?)->Unit)? = null
+
     constructor(context: Context) : this(context, null)
     constructor(context: Context, attrs: AttributeSet?) : this(context, attrs, 0)
     constructor(context: Context, attrs: AttributeSet?, defStyle: Int) : super(
@@ -70,9 +73,9 @@ class PKLayoutView : ConstraintLayout, IRoomActiveListener, IPKListener,
         svgParserProgress = SVGAParser(context)
         playProgress("laugh.svga")
         binding?.let {
-            it.rvSelf.layoutManager = LinearLayoutManager(context)
+            it.rvSelf.layoutManager = LinearLayoutManager(context,LinearLayoutManager.HORIZONTAL,false)
             it.rvSelf.adapter = selfAdapter
-            it.rvPeer.layoutManager = LinearLayoutManager(context)
+            it.rvPeer.layoutManager = LinearLayoutManager(context,LinearLayoutManager.HORIZONTAL,false)
             it.rvPeer.adapter = peerAdapter
 
             selfAdapter.setOnItemClickListener { _, _, position ->
@@ -81,6 +84,9 @@ class PKLayoutView : ConstraintLayout, IRoomActiveListener, IPKListener,
             peerAdapter.setOnItemClickListener { _, _, position ->
 
             }
+            it.clPeer.setOnClickListener {
+                doOtherRoomFun?.invoke(startPKModel)
+            }
         }
     }
 
@@ -90,7 +96,7 @@ class PKLayoutView : ConstraintLayout, IRoomActiveListener, IPKListener,
             svgProcessLayoutParams.startToStart = R.id.view
             svgProcessLayoutParams.topToBottom = R.id.view
             svgProcessLayoutParams.topMargin = DpPxUtil.dip2px(-3f)
-            svgProcessLayoutParams.marginStart = DpPxUtil.getScreenWidth()/2
+            svgProcessLayoutParams.marginStart = DpPxUtil.getScreenWidth()/2- DpPxUtil.dip2px(10f)
             svgProgress.layoutParams = svgProcessLayoutParams
         }
 
@@ -254,13 +260,7 @@ class PKLayoutView : ConstraintLayout, IRoomActiveListener, IPKListener,
                 val svgProcessLayoutParams = ConstraintLayout.LayoutParams(DpPxUtil.dip2px(20f),DpPxUtil.dip2px(20f))
                 svgProcessLayoutParams.startToStart = R.id.view
                 svgProcessLayoutParams.topToBottom = R.id.view
-                if (mProgress>50){
-                    svgProcessLayoutParams.marginStart = DpPxUtil.getScreenWidth()/100*mProgress + DpPxUtil.dip2px(10f)
-                }else if(mProgress<50){
-                    svgProcessLayoutParams.marginStart = DpPxUtil.getScreenWidth()/100*mProgress - DpPxUtil.dip2px(10f)
-                }else{
-                    svgProcessLayoutParams.marginStart = DpPxUtil.getScreenWidth()/100*mProgress
-                }
+                svgProcessLayoutParams.marginStart = (DpPxUtil.getScreenWidth()/100f*mProgress).toInt() - DpPxUtil.dip2px(10f)
 
                 svgProcessLayoutParams.topMargin = DpPxUtil.dip2px(-3f)
                 svgProgress.layoutParams = svgProcessLayoutParams
@@ -288,13 +288,7 @@ class PKLayoutView : ConstraintLayout, IRoomActiveListener, IPKListener,
                 val svgProcessLayoutParams = ConstraintLayout.LayoutParams(DpPxUtil.dip2px(20f),DpPxUtil.dip2px(20f))
                 svgProcessLayoutParams.startToStart = R.id.view
                 svgProcessLayoutParams.topToBottom = R.id.view
-                if (mProgress>50){
-                    svgProcessLayoutParams.marginStart = DpPxUtil.getScreenWidth()/100*mProgress + DpPxUtil.dip2px(10f)
-                }else if(mProgress<50){
-                    svgProcessLayoutParams.marginStart = DpPxUtil.getScreenWidth()/100*mProgress - DpPxUtil.dip2px(10f)
-                }else{
-                    svgProcessLayoutParams.marginStart = DpPxUtil.getScreenWidth()/100*mProgress
-                }
+                svgProcessLayoutParams.marginStart = (DpPxUtil.getScreenWidth()/100f*mProgress).toInt() - DpPxUtil.dip2px(10f)
                 svgProcessLayoutParams.topMargin = DpPxUtil.dip2px(-3f)
                 svgProgress.layoutParams = svgProcessLayoutParams
             }

+ 3 - 0
room/src/main/java/com/swago/room/pk/PkVm.kt

@@ -17,6 +17,7 @@ import com.swago.room.R
 
 class PkVm(application: Application) : AbsMsgVm(application) {
     //接口调用
+    var pkState: ((startPk: Boolean) -> Unit)? = null
 
     /**
      * pK搜索对应主播
@@ -234,6 +235,7 @@ class PkVm(application: Application) : AbsMsgVm(application) {
                             PKStateManager.pkIPKListenerList.forEach { ipkListener ->
                                 ipkListener.startPK(it, true)
                             }
+                            pkState?.invoke(true)
                         }
                     }
                 }
@@ -279,6 +281,7 @@ class PkVm(application: Application) : AbsMsgVm(application) {
                             PKStateManager.pkIPKListenerList.forEach { ipkListener ->
                                 ipkListener.stopPK(it)
                             }
+                            pkState?.invoke(false)
                         }
                     }
                 }

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

@@ -63,6 +63,13 @@ class UserRoomFragment : BaseComFragment<FragmentBaseComBinding>() {
                 dialog.show(childFragmentManager, "BenefitBagDialog")
             }
         })
+
+        binding.pkLayoutView.doOtherRoomFun = {model ->
+            model?.let {
+                goToTargetRoom(it.oppositeUserId)
+            }
+
+        }
     }
 
 

+ 3 - 3
room/src/main/res/layout/item_pk_seat.xml

@@ -1,11 +1,11 @@
 <?xml version="1.0" encoding="utf-8"?>
 <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="28dp"
-    android:layout_height="28dp"
+    android:layout_width="36dp"
+    android:layout_height="36dp"
     xmlns:app="http://schemas.android.com/apk/res-auto">
 
     <de.hdodenhof.circleimageview.CircleImageView
-        android:layout_margin="2dp"
+        android:layout_margin="4dp"
         android:id="@+id/ivAvatar"
         app:civ_border_width="2dp"
         app:civ_border_color="#F8DC93"

+ 3 - 3
room/src/main/res/layout/layout_pk_view.xml

@@ -93,7 +93,7 @@
             app:layout_constraintEnd_toEndOf="parent"
             app:layout_constraintStart_toEndOf="@+id/ivPeerAvatar"
             app:layout_constraintBottom_toBottomOf="parent"
-            android:layout_width="0dp"
+            android:layout_width="wrap_content"
             android:layout_height="wrap_content"/>
 
     </androidx.constraintlayout.widget.ConstraintLayout>
@@ -150,7 +150,7 @@
         android:layout_marginTop="10dp"
         app:layout_constraintStart_toStartOf="parent"
         android:layout_width="wrap_content"
-        android:layout_height="28dp"/>
+        android:layout_height="36dp"/>
 
     <androidx.recyclerview.widget.RecyclerView
         android:id="@+id/rvPeer"
@@ -158,7 +158,7 @@
         android:layout_marginTop="10dp"
         app:layout_constraintEnd_toEndOf="parent"
         android:layout_width="wrap_content"
-        android:layout_height="28dp"/>
+        android:layout_height="36dp"/>
 
 
     <androidx.constraintlayout.widget.ConstraintLayout

BIN
room/src/main/res/mipmap-xxhdpi/icon_pk_mvp.png