소스 검색

feat: 关闭直播

tongmengxiao 5 달 전
부모
커밋
4ab9071e15

+ 11 - 2
baseswago/src/main/java/com/swago/baseswago/model/live/AnchorClosedModel.kt

@@ -14,7 +14,10 @@ data class AnchorClosedModel(
     var user_account: String?,
     var user_head_img_url: String?,
     var user_name: String?,
-    var total_broadcast_time:Long=0
+    var total_broadcast_time:Long=0,
+    var today_total_time:Long=0,
+    var week_total_time :Long=0,
+    var week_valid_day :Int=0
 ) : Parcelable {
     constructor(parcel: Parcel) : this(
         parcel.readLong(),
@@ -23,7 +26,10 @@ data class AnchorClosedModel(
         parcel.readString(),
         parcel.readString(),
         parcel.readString(),
-        parcel.readLong()
+        parcel.readLong(),
+        parcel.readLong(),
+        parcel.readLong(),
+        parcel.readInt(),
     ) {
     }
 
@@ -35,6 +41,9 @@ data class AnchorClosedModel(
         parcel.writeString(user_head_img_url)
         parcel.writeString(user_name)
         parcel.writeLong(total_broadcast_time)
+        parcel.writeLong(today_total_time)
+        parcel.writeLong(week_total_time)
+        parcel.writeInt(week_valid_day)
     }
 
     override fun describeContents(): Int {

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

@@ -277,4 +277,15 @@
     <string name="enter_room_password">الرجاء إدخال كلمة المرور للغرفة</string>
     <string name="connect_error_retry">اتصال غير طبيعي، يرجى التحقق من اتصال الشبكة</string>
     <string name="close_account_connect_service">تم حظر حسابك، يرجى الاتصال بخدمة العملاء إذا كان لديك أي أسئلة!</string>
+    <string name="income_of_this_live">الماس من هذا الفيديو</string>
+    <string name="duration_of_this_live">مدة هذا الفيديو</string>
+    <string name="today_video_duration">مدة الفيديو اليوم</string>
+    <string name="number_of_viewers_of_this_show">عدد مشاهدي هذا العرض</string>
+    <string name="total_video_duration_this_week">إجمالي مدة الفيديو هذا الأسبوع</string>
+    <string name="video_valid_days_this_week">فيديو صالح أيام هذا الأسبوع</string>
+    <string name="income_of_this_audio">الماس من هذا الصوت</string>
+    <string name="duration_of_this_audio">مدة هذا الصوت</string>
+    <string name="today_audio_duration">مدة الصوت اليوم</string>
+    <string name="total_voice_time_this_week">إجمالي وقت الصوت هذا الأسبوع</string>
+    <string name="voice_valid_days_this_week">أيام صالحة صوت هذا الأسبوع</string>
 </resources>

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

@@ -281,4 +281,15 @@
     <string name="enter_room_password">Silakan masukkan kata sandi</string>
     <string name="connect_error_retry">Koneksi tidak normal, silakan periksa koneksi jaringan</string>
     <string name="close_account_connect_service">Akun Anda telah diblokir, silakan hubungi layanan pelanggan jika Anda memiliki pertanyaan!</string>
+    <string name="income_of_this_live">Pendapatan Kali ini</string>
+    <string name="duration_of_this_live">Durasi kali ini</string>
+    <string name="today_video_duration">Total durasivideo hari ini</string>
+    <string name="number_of_viewers_of_this_show">Jumlah Penonton kali Ini</string>
+    <string name="total_video_duration_this_week">Total durasi video minggu ini</string>
+    <string name="video_valid_days_this_week">valid hari video Minggu Ini</string>
+    <string name="income_of_this_audio">Pendapatan Kali ini</string>
+    <string name="duration_of_this_audio">Durasi kali ini</string>
+    <string name="today_audio_duration">Total durasi audio hari ini</string>
+    <string name="total_voice_time_this_week">Total durasi audio minggu ini</string>
+    <string name="voice_valid_days_this_week">valid hari audio Minggu Ini</string>
 </resources>

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

@@ -278,4 +278,15 @@
     <string name="enter_room_password">Silakan masukkan kata sandi</string>
     <string name="connect_error_retry">Koneksi tidak normal, silakan periksa koneksi jaringan</string>
     <string name="close_account_connect_service">Akun Anda telah diblokir, silakan hubungi layanan pelanggan jika Anda memiliki pertanyaan!</string>
+    <string name="income_of_this_live">Pendapatan Kali ini</string>
+    <string name="duration_of_this_live">Durasi kali ini</string>
+    <string name="today_video_duration">Total durasivideo hari ini</string>
+    <string name="number_of_viewers_of_this_show">Jumlah Penonton kali Ini</string>
+    <string name="total_video_duration_this_week">Total durasi video minggu ini</string>
+    <string name="video_valid_days_this_week">valid hari video Minggu Ini</string>
+    <string name="income_of_this_audio">Pendapatan Kali ini</string>
+    <string name="duration_of_this_audio">Durasi kali ini</string>
+    <string name="today_audio_duration">Total durasi audio hari ini</string>
+    <string name="total_voice_time_this_week">Total durasi audio minggu ini</string>
+    <string name="voice_valid_days_this_week">valid hari audio Minggu Ini</string>
 </resources>

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

@@ -277,4 +277,15 @@
     <string name="enter_room_password">请输入房间密码</string>
     <string name="connect_error_retry">连接异常,请检查网络连接</string>
     <string name="close_account_connect_service">您的账号已封禁,如有疑问请联系客服!</string>
+    <string name="income_of_this_live">本场收入</string>
+    <string name="duration_of_this_live">本场时长</string>
+    <string name="today_video_duration">本日视频时长</string>
+    <string name="number_of_viewers_of_this_show">本场观看人数</string>
+    <string name="total_video_duration_this_week">本周视频总时长</string>
+    <string name="video_valid_days_this_week">本周视频有效天</string>
+    <string name="income_of_this_audio">本场收入</string>
+    <string name="duration_of_this_audio">本场时长</string>
+    <string name="today_audio_duration">本日语音时长</string>
+    <string name="total_voice_time_this_week">本周语音总时长</string>
+    <string name="voice_valid_days_this_week">本周语音有效天</string>
 </resources>

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

@@ -299,4 +299,15 @@
     <string name="enter_room_password">Please enter room password</string>
     <string name="connect_error_retry">Abnormal connection, please check the network connection</string>
     <string name="close_account_connect_service">Your account has been blocked, please contact customer service if you have any questions!</string>
+    <string name="income_of_this_live">income of this live</string>
+    <string name="duration_of_this_live">Duration of this live</string>
+    <string name="today_video_duration">Today’s video duration</string>
+    <string name="number_of_viewers_of_this_show">Number of viewers of this show</string>
+    <string name="total_video_duration_this_week">Total video duration this week</string>
+    <string name="video_valid_days_this_week">Video valid days this week</string>
+    <string name="income_of_this_audio">income of this audio</string>
+    <string name="duration_of_this_audio">Duration of this audio</string>
+    <string name="today_audio_duration">Today’s audio duration</string>
+    <string name="total_voice_time_this_week">Total voice time this week</string>
+    <string name="voice_valid_days_this_week">Voice valid days this week</string>
 </resources>

+ 19 - 1
room/src/main/java/com/swago/room/dialog/AnchorCloseDialog.kt

@@ -11,6 +11,7 @@ import com.swago.baseswago.util.NoDoubleClickListener
 import com.swago.baseswago.util.TimeUtil
 import com.swago.room.R
 import com.swago.room.databinding.DialogAnchorCloseBinding
+import com.swago.room.enum.RoomType
 
 /**
  *@date 2021/11/28 21:13
@@ -41,6 +42,21 @@ class AnchorCloseDialog : BaseXDFragment<DialogAnchorCloseBinding>(){
 
 
     override fun initOther() {
+        SwagoRoomManager.iRoomInfo?.let {
+            if (it.getRoomType() == RoomType.VIDEO.type){
+                binding.tvIncome.text = getString(R.string.income_of_this_live)
+                binding.tvTime.text = getString(R.string.duration_of_this_live)
+                binding.tvTotalTime.text = getString(R.string.today_video_duration)
+                binding.tvWeekTime.text = getString(R.string.total_video_duration_this_week)
+                binding.tvWeekDayTime.text = getString(R.string.video_valid_days_this_week)
+            } else {
+                binding.tvIncome.text = getString(R.string.income_of_this_audio)
+                binding.tvTime.text = getString(R.string.duration_of_this_audio)
+                binding.tvTotalTime.text = getString(R.string.today_audio_duration)
+                binding.tvWeekTime.text = getString(R.string.total_voice_time_this_week)
+                binding.tvWeekDayTime.text = getString(R.string.voice_valid_days_this_week)
+            }
+        }
         arguments?.let {
             anchorCloseModel =  it.getParcelable("model")
             anchorCloseModel?.let {  anchorClosedModel ->
@@ -50,7 +66,9 @@ class AnchorCloseDialog : BaseXDFragment<DialogAnchorCloseBinding>(){
                 binding.tvIncomeValue.text = anchorClosedModel.income_coins
                 binding.tvWatcherValue.text = anchorClosedModel.total_member
                 binding.tvTimeValue.text = TimeUtil.convertMinSecond((anchorClosedModel.broadcast_time))
-                binding.tvTotalTimeValue.text = TimeUtil.convertMinSecond((anchorClosedModel.total_broadcast_time))
+                binding.tvTotalTimeValue.text = TimeUtil.convertMinSecond((anchorClosedModel.today_total_time))
+                binding.tvWeekTimeValue.text = TimeUtil.convertMinSecond((anchorClosedModel.week_total_time ))
+                binding.tvWeekDayValue.text = "${anchorClosedModel.week_valid_day}"
                 binding.tvName.text = anchorClosedModel.user_name
                 binding.tvId.text = "ID:${anchorClosedModel.user_account}"
             }

+ 8 - 4
room/src/main/java/com/swago/room/giftdandao/GiftDanDaoManager.kt

@@ -25,10 +25,11 @@ class GiftDanDaoManager  : IRoomActiveListener {
 
     //用来标记往哪个GiftDanDaoView添加数据
     private var giftDanDaoViewCount = 0
+    private var soundPoolPlayer:SoundPoolPlayer ?= null
 
     fun init(){
         SwagoRoomManager.addListener(this)
-        SoundPoolPlayer.init(AppContext.getContext() , R.raw.gift_sound)
+        soundPoolPlayer = SoundPoolPlayer()
 
     }
 
@@ -59,7 +60,7 @@ class GiftDanDaoManager  : IRoomActiveListener {
         loopJob?.cancel()
         loopJob = null
         SwagoRoomManager.removeListener(this)
-        SoundPoolPlayer.release()
+        soundPoolPlayer?.release()
     }
 
 
@@ -69,9 +70,12 @@ class GiftDanDaoManager  : IRoomActiveListener {
             initQueue()
             loopJob?.start()
         }
-        if (imGiftModel.multiple >= 500){
-            SoundPoolPlayer.playSound()
+        if (imGiftModel.multiple in 50..499){
+            soundPoolPlayer?.playSound(false, R.raw.gift_sound_50)
+        } else if (imGiftModel.multiple >= 500){
+            soundPoolPlayer?.playSound(true, R.raw.gift_sound)
         }
+
     }
 
     private fun initQueue(){

+ 23 - 20
room/src/main/java/com/swago/room/sound/SoundPoolPlayer.kt

@@ -3,39 +3,42 @@ package com.swago.room.sound
 import android.content.Context
 import android.content.Context.VIBRATOR_SERVICE
 import android.media.SoundPool
+import android.media.SoundPool.OnLoadCompleteListener
 import android.os.Vibrator
 import androidx.core.content.ContextCompat.getSystemService
+import com.swago.baseswago.cusview.SwagoRecyclerView
+import com.swago.baseswago.model.live.RoomUserModel
+import com.swago.baseswago.util.AppContext
 import com.swago.room.R
 
 
-object SoundPoolPlayer {
-    private const val MAX_STREAMS = 5
-    private var soundPool:SoundPool?=null
-    private var vibrator:Vibrator?=null
-    private var soundId:Int = 0
+class SoundPoolPlayer {
+    private val soundPool: SoundPool by lazy {
+         SoundPool.Builder().setMaxStreams(5).build()
+    }
+    private val vibrator: Vibrator by lazy {
+        mContext.getSystemService(VIBRATOR_SERVICE) as Vibrator
+    }
+    private var soundId: Int = 0
+    private var mContext:Context = AppContext.getContext()
 
 
-    fun init(context:Context , sound : Int){
-        if (soundPool == null) {
-            soundPool = SoundPool.Builder().setMaxStreams(MAX_STREAMS).build()
-            //加载音效
-            soundId = soundPool!!.load(context, sound, 1)
+    fun playSound(vibratorShow: Boolean ,sound: Int) {
+        //加载音效
+        soundId = soundPool.load(mContext, sound, 1)
+        soundPool.setOnLoadCompleteListener { soundPool, _, _ ->
+            soundPool.play(soundId, 1f, 1f, 1, 0, 1f)
         }
-        if (vibrator == null){
-            vibrator = context.getSystemService(VIBRATOR_SERVICE) as Vibrator
 
+        if (vibratorShow){
+            vibrator.vibrate(500)
         }
-    }
 
-    fun playSound(){
-        soundPool?.play(soundId,1f,1f,1,0,1f)
-        vibrator?.vibrate(500)
     }
 
-    fun release(){
-        soundPool?.release()
-        soundPool=null
-        vibrator?.cancel()
+    fun release() {
+        soundPool.release()
+        vibrator.cancel()
 
     }
 

+ 54 - 6
room/src/main/res/layout/dialog_anchor_close.xml

@@ -63,7 +63,7 @@
         android:id="@+id/tvIncome"
         android:textSize="16dp"
         android:textColor="#FFE398"
-        android:text="@string/income"
+        android:text="@string/income_of_this_live"
         android:layout_marginBottom="24dp"
         android:layout_marginStart="32dp"
         app:layout_constraintStart_toStartOf="parent"
@@ -90,7 +90,7 @@
         android:id="@+id/tvTime"
         android:textSize="16dp"
         android:textColor="#fff"
-        android:text="@string/live_time"
+        android:text="@string/duration_of_this_live"
         android:layout_marginBottom="24dp"
         android:layout_marginStart="32dp"
         app:layout_constraintStart_toStartOf="parent"
@@ -115,7 +115,7 @@
         android:id="@+id/tvTotalTime"
         android:textSize="16dp"
         android:textColor="#fff"
-        android:text="@string/live_all_time"
+        android:text="@string/today_video_duration"
         android:layout_marginBottom="24dp"
         android:layout_marginStart="32dp"
         app:layout_constraintStart_toStartOf="parent"
@@ -140,7 +140,56 @@
         android:id="@+id/tvWatcher"
         android:textSize="16dp"
         android:textColor="#fff"
-        android:text="@string/watcher_num"
+        android:text="@string/number_of_viewers_of_this_show"
+        android:layout_marginBottom="24dp"
+        android:layout_marginStart="32dp"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintBottom_toTopOf="@+id/tvWeekTime"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"/>
+
+    <com.swago.baseswago.cusview.MediumTextView
+        android:id="@+id/tvWatcherValue"
+        android:textSize="16dp"
+        android:textColor="#fff"
+        tools:text="100"
+        android:layout_marginBottom="24dp"
+        android:layout_marginEnd="32dp"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintBottom_toTopOf="@+id/tvWeekTime"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"/>
+
+    <com.swago.baseswago.cusview.MediumTextView
+        android:id="@+id/tvWeekTime"
+        android:textSize="16dp"
+        android:textColor="#fff"
+        android:text="@string/total_video_duration_this_week"
+        android:layout_marginBottom="24dp"
+        android:layout_marginStart="32dp"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintBottom_toTopOf="@+id/tvWeekDayTime"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"/>
+
+    <com.swago.baseswago.cusview.MediumTextView
+        android:id="@+id/tvWeekTimeValue"
+        android:textSize="16dp"
+        android:textColor="#fff"
+        tools:text="100"
+        android:layout_marginBottom="24dp"
+        android:layout_marginEnd="32dp"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintBottom_toTopOf="@+id/tvWeekDayTime"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"/>
+
+
+    <com.swago.baseswago.cusview.MediumTextView
+        android:id="@+id/tvWeekDayTime"
+        android:textSize="16dp"
+        android:textColor="#fff"
+        android:text="@string/video_valid_days_this_week"
         android:layout_marginBottom="100dp"
         android:layout_marginStart="32dp"
         app:layout_constraintStart_toStartOf="parent"
@@ -149,7 +198,7 @@
         android:layout_height="wrap_content"/>
 
     <com.swago.baseswago.cusview.MediumTextView
-        android:id="@+id/tvWatcherValue"
+        android:id="@+id/tvWeekDayValue"
         android:textSize="16dp"
         android:textColor="#fff"
         tools:text="100"
@@ -160,7 +209,6 @@
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"/>
 
-
     <com.swago.baseswago.cusview.BoldTextView
         android:id="@+id/tvClose"
         android:text="@string/sure_close"

+ 1 - 0
room/src/main/res/layout/view_user_join_room.xml

@@ -104,6 +104,7 @@
                 android:textSize="12dp"
                 android:textStyle="bold"
                 tools:text="swago"
+                android:gravity="start"
                 android:textColor="@color/white"
                 android:layout_width="0dp"
                 android:layout_height="wrap_content"/>

BIN
room/src/main/res/raw/gift_sound_50.mp3