Browse Source

feat: house go live and no face dialog

tongmengxiao 6 months ago
parent
commit
8ed64a3d90

+ 11 - 1
room/src/main/java/com/swago/room/anchor/AnchorRoomActivity.kt

@@ -47,6 +47,7 @@ import com.swago.room.dialog.AnchorCloseDialog
 import com.swago.room.dialog.CanStartLiveDialog
 import com.swago.room.dialog.ForceCloseRoomDialog
 import com.swago.room.dialog.LiveRestrictionsDialog
+import com.swago.room.dialog.NoFaceShowDialog
 import com.swago.room.enum.RoomType
 import com.swago.room.lianmai.LianMaiManager
 import com.swago.room.lianmai.LianMaiVm
@@ -87,6 +88,7 @@ class AnchorRoomActivity : AbsAnchorActivity<ActivityAnchorRoomBinding, IRoomInf
     private var anchorRoomFragment: AnchorRoomFragment? = null
 
     private var anchorCloseDialog: AnchorCloseDialog? = null
+    private var noFaceShowDialog: NoFaceShowDialog? = null
 
     //开播类型  0视频房 1语音房
     private var roomType = RoomType.VIDEO
@@ -343,8 +345,14 @@ class AnchorRoomActivity : AbsAnchorActivity<ActivityAnchorRoomBinding, IRoomInf
             binding.cbPassword.text = if (isChecked)  "Password ·NO" else "Password ·OFF"
             checkPassword = isChecked
         }
-        countDownTimer = object : CountDownTimer(liveNoFaceTime, liveNoFaceTime) {
+        countDownTimer = object : CountDownTimer(liveNoFaceTime, 60000) {
             override fun onTick(millisUntilFinished: Long) {
+                LogUtil.d("millisUntilFinished${millisUntilFinished / 1000}")
+                if (millisUntilFinished/1000 == 60L ){
+                    LogUtil.d("millisUntilFinished:show")
+                    noFaceShowDialog = NoFaceShowDialog.newInstance()
+                    noFaceShowDialog?.show(supportFragmentManager , "NoFaceShowDialog")
+                }
             }
 
             override fun onFinish() {
@@ -411,6 +419,7 @@ class AnchorRoomActivity : AbsAnchorActivity<ActivityAnchorRoomBinding, IRoomInf
 
     override fun onDestroy() {
         anchorCloseDialog = null
+        noFaceShowDialog = null
         PKStateManager.removePKListener(this)
         AudioRoomManager.removeListener(this)
         agoraService?.let { stopService(it) }
@@ -467,6 +476,7 @@ class AnchorRoomActivity : AbsAnchorActivity<ActivityAnchorRoomBinding, IRoomInf
         } else {
             startFaceShowTimer = true
             countDownTimer.cancel()
+            noFaceShowDialog?.dismissAllowingStateLoss()
         }
     }
 

+ 2 - 1
room/src/main/java/com/swago/room/base/BaseComFragment.kt

@@ -58,6 +58,7 @@ import com.swago.room.databinding.FragmentBaseComBinding
 import com.swago.room.dialog.AudienceListDialog
 import com.swago.room.dialog.FanClubAnchorDialog
 import com.swago.room.dialog.FanClubForUserDialog
+import com.swago.room.dialog.HouseGoLiveDialog
 import com.swago.room.dialog.JoinFanClubDialog
 import com.swago.room.dialog.LevelUpDialog
 import com.swago.room.dialog.MessageListDialog
@@ -579,7 +580,7 @@ abstract class BaseComFragment<T : FragmentBaseComBinding> : BaseXFragment<T>(),
         }
 
         msgVm.openHouseOpenLiveDialog = {
-
+            HouseGoLiveDialog.newInstance(it.anchorAvatar).show(parentFragmentManager,"HouseGoLiveDialog")
         }
 
         msgVm.changeNameChangeFun = {

+ 46 - 0
room/src/main/java/com/swago/room/dialog/HouseGoLiveDialog.kt

@@ -0,0 +1,46 @@
+package com.swago.room.dialog
+
+import android.os.Bundle
+import android.os.CountDownTimer
+import android.view.Gravity
+import com.swago.baseswago.R
+import com.swago.baseswago.dialog.BaseXDFragment
+import com.swago.baseswago.util.AppContext
+import com.swago.room.databinding.DialogHouseGoLiveBinding
+
+class HouseGoLiveDialog : BaseXDFragment<DialogHouseGoLiveBinding>() {
+    var goLive:(()->Unit)? = null
+
+    init {
+        setGravity(Gravity.CENTER)
+        setDimAmount(0.5f)
+        setCanCancel(false)
+    }
+
+
+    companion object {
+        fun newInstance(avatar: String): HouseGoLiveDialog {
+            val args = Bundle()
+            args.putString("avatar", avatar)
+            val fragment = HouseGoLiveDialog()
+            fragment.arguments = args
+            return fragment
+        }
+    }
+
+    override fun initOther() {
+        arguments?.let {
+            val msg = it.getString("avatar", "")
+            binding.tvHint.text = msg
+        }
+
+        binding.tvGoLive.setOnClickListener {
+            goLive?.invoke()
+        }
+    }
+
+    override fun initLiveData() {
+
+    }
+
+}

+ 53 - 0
room/src/main/java/com/swago/room/dialog/NoFaceShowDialog.kt

@@ -0,0 +1,53 @@
+package com.swago.room.dialog
+
+import android.os.Bundle
+import android.os.CountDownTimer
+import android.view.Gravity
+import com.swago.baseswago.R
+import com.swago.baseswago.dialog.BaseXDFragment
+import com.swago.baseswago.util.AppContext
+import com.swago.room.databinding.DialogHouseGoLiveBinding
+import com.swago.room.databinding.DialogNoFaceShowBinding
+
+class NoFaceShowDialog : BaseXDFragment<DialogNoFaceShowBinding>() {
+
+    private lateinit var countDownTimer: CountDownTimer
+    private val totalTimeInMillis: Long = 60000
+
+    init {
+        setGravity(Gravity.CENTER)
+        setDimAmount(0.5f)
+        setCanCancel(false)
+    }
+
+
+    companion object {
+        fun newInstance(): NoFaceShowDialog {
+            val args = Bundle()
+            val fragment = NoFaceShowDialog()
+            fragment.arguments = args
+            return fragment
+        }
+    }
+
+    override fun initOther() {
+        countDownTimer = object : CountDownTimer(totalTimeInMillis, 1000) {
+            override fun onTick(millisUntilFinished: Long) {
+                val secondsRemaining = millisUntilFinished / 1000
+                binding.tvTime.text =
+                   "00:${secondsRemaining}"
+            }
+
+            override fun onFinish() {
+            }
+
+        }
+        countDownTimer.start()
+
+    }
+
+    override fun initLiveData() {
+
+    }
+
+}

+ 75 - 0
room/src/main/res/layout/dialog_house_go_live.xml

@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="utf-8"?>
+<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    app:layout_constraintTop_toTopOf="parent"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:tools="http://schemas.android.com/tools">
+
+
+    <androidx.constraintlayout.widget.ConstraintLayout
+        android:background="@drawable/shape_white_20"
+        app:layout_constraintTop_toTopOf="parent"
+        android:layout_marginStart="40dp"
+        android:layout_marginEnd="40dp"
+        android:paddingBottom="30dp"
+        android:layout_marginTop="@dimen/dp_40"
+        app:layout_constraintBottom_toBottomOf="parent"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content">
+
+
+    <com.swago.baseswago.cusview.BoldTextView
+        android:id="@+id/tv_close_title"
+        android:text="@string/living_room_already_be_closed"
+        android:textColor="#0F172A"
+        android:textSize="18sp"
+        android:textStyle="bold"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintTop_toTopOf="parent"
+        android:layout_marginTop="40dp"/>
+
+    <com.swago.baseswago.cusview.MediumTextView
+        android:id="@+id/tv_hint"
+        android:text="Please contact customer service if you have any questions."
+        android:textColor="#0F172A"
+        android:textSize="14sp"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintStart_toStartOf="parent"
+        android:layout_marginTop="16dp"
+        android:gravity="center"
+        app:layout_constraintTop_toBottomOf="@+id/tv_close_title"/>
+
+    <com.swago.baseswago.cusview.BoldTextView
+        android:id="@+id/tv_go_live"
+        android:layout_width="match_parent"
+        android:layout_height="44dp"
+        android:layout_marginTop="20dp"
+        app:layout_constraintTop_toBottomOf="@+id/tv_hint"
+        app:layout_constraintEnd_toEndOf="parent"
+        android:layout_marginEnd="20dp"
+        android:textColor="#fff"
+        android:textSize="@dimen/sp_16"
+        android:text="@string/start_live"
+        android:gravity="center"
+        android:layout_marginBottom="30dp"
+        android:layout_marginStart="30dp"
+        android:background="@drawable/shape_ff56b7_37"/>
+
+    </androidx.constraintlayout.widget.ConstraintLayout>
+
+
+    <de.hdodenhof.circleimageview.CircleImageView
+        android:id="@+id/ivAvatar"
+        android:layout_width="80dp"
+        android:layout_height="80dp"
+        app:layout_constraintTop_toTopOf="parent"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintEnd_toEndOf="parent"/>
+
+</androidx.constraintlayout.widget.ConstraintLayout>

+ 84 - 0
room/src/main/res/layout/dialog_no_face_show.xml

@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="utf-8"?>
+<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    app:layout_constraintTop_toTopOf="parent"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:tools="http://schemas.android.com/tools">
+
+
+    <androidx.constraintlayout.widget.ConstraintLayout
+        android:background="@drawable/shape_white_20"
+        app:layout_constraintTop_toTopOf="parent"
+        android:layout_marginStart="40dp"
+        android:layout_marginEnd="40dp"
+        android:paddingBottom="30dp"
+        android:layout_marginTop="@dimen/dp_40"
+        app:layout_constraintBottom_toBottomOf="parent"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content">
+
+
+    <com.swago.baseswago.cusview.BoldTextView
+        android:id="@+id/tv_close_title"
+        android:text="@string/living_room_already_be_closed"
+        android:textColor="#0F172A"
+        android:textSize="18sp"
+        android:textStyle="bold"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintTop_toTopOf="parent"
+        android:layout_marginTop="40dp"/>
+
+    <com.swago.baseswago.cusview.MediumTextView
+        android:id="@+id/tv_hint"
+        android:text="Please contact customer service if you have any questions."
+        android:textColor="#0F172A"
+        android:textSize="14sp"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintStart_toStartOf="parent"
+        android:layout_marginTop="12dp"
+        android:gravity="center"
+        app:layout_constraintTop_toBottomOf="@+id/tv_close_title"/>
+
+    <com.swago.baseswago.cusview.BoldTextView
+        android:id="@+id/tv_time"
+        android:layout_width="match_parent"
+        android:layout_height="44dp"
+        android:layout_marginTop="12dp"
+        app:layout_constraintTop_toBottomOf="@+id/tv_hint"
+        app:layout_constraintEnd_toEndOf="parent"
+        android:layout_marginEnd="20dp"
+        android:textColor="#DC2626"
+        android:textSize="26sp"
+        android:text="00:00"
+        android:gravity="center"
+        android:layout_marginBottom="30dp"
+        android:layout_marginStart="30dp"/>
+
+    </androidx.constraintlayout.widget.ConstraintLayout>
+
+    <ImageView
+        android:id="@+id/iv_bg"
+        android:layout_width="match_parent"
+        android:layout_height="100dp"
+        android:background="@mipmap/bg_close_live"
+        android:layout_marginStart="40dp"
+        android:layout_marginEnd="40dp"
+        android:layout_marginTop="@dimen/dp_40"
+        app:layout_constraintTop_toTopOf="parent"/>
+
+    <ImageView
+        android:id="@+id/ivAvatar"
+        android:layout_width="80dp"
+        android:layout_height="80dp"
+        android:src="@mipmap/ic_no_face"
+        app:layout_constraintTop_toTopOf="parent"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintEnd_toEndOf="parent"/>
+
+</androidx.constraintlayout.widget.ConstraintLayout>

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