Browse Source

feat: 排行榜

tongmengxiao 1 month ago
parent
commit
bb6c812b70

+ 5 - 0
baseswago/src/main/java/com/swago/baseswago/PersonDataDFragment.kt

@@ -68,6 +68,11 @@ class PersonDataDFragment : BaseXDFragment<DialogPersonDataBinding>() {
 
             UserInfo.getUserInfo()?.let {
                 if (it.id == uid){
+                    SwagoRoomManager.iRoomInfo?.let {
+                        if (it.getRoomType() == 2){
+                            binding.ivGift.visibility = View.GONE
+                        }
+                    }
 //                    binding.ivGift.visibility = View.GONE
                     binding.tvAt.visibility = View.GONE
                     binding.llChat.visibility = View.GONE

+ 2 - 0
baseswago/src/main/java/com/swago/baseswago/constant/UrlConstant.kt

@@ -81,6 +81,8 @@ object UrlConstant {
     val TOP_UP = "${BASE_WEB_URL}/recharge/detail"
     val WITHDRAW = "${BASE_WEB_URL}/withdrawal" //主播家族长跳这个
     val WITHDRAW_CUSTOMER = "${BASE_WEB_URL}/withdrawal/customer"//所有用户都跳跳这个 1.2.0版本改的
+    //排行榜
+    val RANKING = "${BASE_WEB_URL}/goldCoinRank"
 
     var appGameRootPath =
         AppContext.getContext().getExternalFilesDir("")?.absolutePath + File.separator + "gameFile"

+ 5 - 5
home/src/main/java/com/swago/home/HomeFragment.kt

@@ -98,21 +98,21 @@ class HomeFragment : BaseXFragment<FragmentHomeBinding>() {
         binding.ivRanking.setOnClickListener(object :NoDoubleClickListener(){
             override fun onClick() {
                 ARouter.getInstance().build(ARouteConstant.Base.webView)
-                    .withString("url", UrlConstant.USER_AGREEMENT)
+                    .withString("url", UrlConstant.RANKING)
                     .navigation()
             }
         })
 
-        binding.mtvLive.setOnClickListener(object :NoDoubleClickListener(){
+        binding.ivLive.setOnClickListener(object :NoDoubleClickListener(){
             override fun onClick() {
-                binding.mtvLive.isEnabled = false
+                binding.ivLive.isEnabled = false
                 PermissionX.init(this@HomeFragment)
                     .permissions(Manifest.permission.CAMERA, Manifest.permission.RECORD_AUDIO)
                     .request { allGranted, grantedList, deniedList ->
                         if (allGranted) {
                             ARouter.getInstance().build(ARouteConstant.Room.anchor).navigation()
                         } else {
-                            binding.mtvLive.isEnabled = true
+                            binding.ivLive.isEnabled = true
                             Toast.makeText(
                                 AppContext.getContext(),
                                 "These permissions are denied: $deniedList",
@@ -160,6 +160,6 @@ class HomeFragment : BaseXFragment<FragmentHomeBinding>() {
 
     override fun onResume() {
         super.onResume()
-        binding.mtvLive.isEnabled = true
+        binding.ivLive.isEnabled = true
     }
 }

+ 7 - 17
home/src/main/res/layout/fragment_home.xml

@@ -49,24 +49,14 @@
         android:layout_width="match_parent"
         android:layout_height="0dp"/>
 
-    <com.swago.baseswago.cusview.MediumTextView
-        android:id="@+id/mtv_live"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
+    <ImageView
+        android:id="@+id/iv_live"
+        android:layout_width="55dp"
+        android:layout_height="55dp"
         app:layout_constraintBottom_toBottomOf="parent"
         app:layout_constraintRight_toRightOf="parent"
-        android:layout_marginRight="10dp"
-        android:layout_marginBottom="10dp"
-        android:gravity="center_vertical"
-        android:drawablePadding="4dp"
-        android:paddingStart="16dp"
-        android:paddingEnd="16dp"
-        android:paddingTop="10dp"
-        android:paddingBottom="10dp"
-        android:textSize="14dp"
-        android:background="@drawable/shape_9b20fc_20"
-        android:text="@string/live"
-        android:textColor="@color/_ffffff"
-        android:drawableStart="@mipmap/ic_voice"/>
+        android:layout_marginRight="12dp"
+        android:layout_marginBottom="12dp"
+        android:background="@mipmap/ic_voice"/>
 
 </androidx.constraintlayout.widget.ConstraintLayout>

BIN
home/src/main/res/mipmap-xxhdpi/ic_voice.png


+ 5 - 1
login/src/main/java/com/swago/login/LoginActivity.kt

@@ -41,9 +41,13 @@ class LoginActivity : BaseXActivity<ActivityLoginBinding>() {
 
     }
 
+    override fun onResume() {
+        super.onResume()
+        loginVm.getApiDomain()
+    }
+
     override fun initOther() {
         IMMessageManager.groupMessageParser.clear()
-        loginVm.getApiDomain()
         GoogleLogin.init(this)
         FBLogin.init(object : IFacebook {
             override fun getToken(token: String) {

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

@@ -4,7 +4,9 @@ import com.swago.baseswago.baseroom.IRoomActiveListener
 import com.swago.baseswago.baseroom.IRoomInfo
 import com.swago.baseswago.baseroom.SwagoRoomManager
 import com.swago.baseswago.model.live.gift.IMGiftModel
+import com.swago.baseswago.util.AppContext
 import com.swago.baseswago.util.LogUtil
+import com.swago.room.sound.SoundPoolPlayer
 import kotlinx.coroutines.*
 import java.util.*
 import kotlin.collections.ArrayList
@@ -25,6 +27,8 @@ class GiftDanDaoManager  : IRoomActiveListener {
 
     fun init(){
         SwagoRoomManager.addListener(this)
+        SoundPoolPlayer.init(AppContext.getContext())
+
     }
 
     override fun changeRoom(iRoomInfo: IRoomInfo) {
@@ -54,6 +58,7 @@ class GiftDanDaoManager  : IRoomActiveListener {
         loopJob?.cancel()
         loopJob = null
         SwagoRoomManager.removeListener(this)
+        SoundPoolPlayer.release()
     }
 
 
@@ -63,7 +68,9 @@ class GiftDanDaoManager  : IRoomActiveListener {
             initQueue()
             loopJob?.start()
         }
-
+        if (imGiftModel.multiple >= 500){
+            SoundPoolPlayer.playSound()
+        }
     }
 
     private fun initQueue(){

+ 0 - 4
room/src/main/java/com/swago/room/piaotiao/WaftView.kt

@@ -42,7 +42,6 @@ class WaftView : FrameLayout {
 
     private fun initView(context: Context) {
         binding = ViewWaftBinding.inflate(LayoutInflater.from(context), this, true)
-        SoundPoolPlayer.init(context)
     }
 
 
@@ -123,7 +122,6 @@ class WaftView : FrameLayout {
                     val multiple = "<font color='#FFDB43'>${next.multiple}</font>"
                     binding?.ll?.setBackgroundResource(R.mipmap.waft_big_prize)
                     binding?.marqueeTextView?.text = Html.fromHtml("\u200E${AppContext.getContext().resources.getString(R.string.big_prize).format(sendName,giftName,multiple)}")
-                    SoundPoolPlayer.playSound()
                 }else{
                     val sendName = "<font color='#FFDB43'>${next.senderName}</font>"
                     val giftName = "<font color='#FFDB43'>${localName}</font>"
@@ -168,8 +166,6 @@ class WaftView : FrameLayout {
         imGiftModelList.clear()
         animatorSet = null
         binding?.ll?.visibility = View.INVISIBLE
-        SoundPoolPlayer.release()
-
     }
 
 }

+ 14 - 0
room/src/main/java/com/swago/room/sound/SoundPoolPlayer.kt

@@ -1,28 +1,42 @@
 package com.swago.room.sound
 
 import android.content.Context
+import android.content.Context.VIBRATOR_SERVICE
 import android.media.SoundPool
+import android.os.Vibrator
+import androidx.core.content.ContextCompat.getSystemService
 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
+
+
     fun init(context:Context){
         if (soundPool == null) {
             soundPool = SoundPool.Builder().setMaxStreams(MAX_STREAMS).build()
             //加载音效
             soundId = soundPool!!.load(context, R.raw.gift_sound, 1)
         }
+        if (vibrator == null){
+            vibrator = context.getSystemService(VIBRATOR_SERVICE) as Vibrator
+
+        }
     }
 
     fun playSound(){
         soundPool?.play(soundId,1f,1f,1,0,1f)
+        vibrator?.vibrate(500)
     }
 
     fun release(){
         soundPool?.release()
         soundPool=null
+        vibrator?.cancel()
+
     }
 
 }

+ 1 - 1
room/src/main/res/layout/layout_user_header_view.xml

@@ -269,6 +269,6 @@
         android:text="id"
         android:layout_marginRight="12dp"
         android:textSize="@dimen/sp_12"
-        android:textColor="#33000000"/>
+        android:textColor="#66ffffff"/>
 
 </androidx.constraintlayout.widget.ConstraintLayout>

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