Browse Source

feat: gift id show

tongmengxiao 7 tháng trước cách đây
mục cha
commit
281668141d

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

@@ -68,7 +68,7 @@ class PersonDataDFragment : BaseXDFragment<DialogPersonDataBinding>() {
 
             UserInfo.getUserInfo()?.let {
                 if (it.id == uid){
-                    binding.ivGift.visibility = View.GONE
+//                    binding.ivGift.visibility = View.GONE
                     binding.tvAt.visibility = View.GONE
                     binding.llChat.visibility = View.GONE
                     binding.llToFollow.visibility = View.GONE

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

@@ -112,6 +112,25 @@ class HomeFragment : BaseXFragment<FragmentHomeBinding>() {
                     }
             }
         })
+        binding.ivLive.setOnClickListener(object :NoDoubleClickListener(){
+            override fun onClick() {
+                binding.tvStartLive.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.tvStartLive.isEnabled = true
+                            Toast.makeText(
+                                AppContext.getContext(),
+                                "These permissions are denied: $deniedList",
+                                Toast.LENGTH_LONG
+                            ).show()
+                        }
+                    }
+            }
+        })
 
         binding.viewPager.addOnPageChangeListener(object:ViewPager.OnPageChangeListener{
             override fun onPageScrolled(

+ 10 - 0
home/src/main/res/layout/fragment_home.xml

@@ -58,4 +58,14 @@
         android:layout_width="match_parent"
         android:layout_height="0dp"/>
 
+    <ImageView
+        android:id="@+id/ivLive"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:src="@drawable/ic_add_contact"
+        app:layout_constraintBottom_toBottomOf="parent"
+        app:layout_constraintRight_toRightOf="parent"
+        android:layout_marginRight="10dp"
+        android:layout_marginBottom="10dp"/>
+
 </androidx.constraintlayout.widget.ConstraintLayout>

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

@@ -43,6 +43,7 @@ class LoginActivity : BaseXActivity<ActivityLoginBinding>() {
 
     override fun initOther() {
         IMMessageManager.groupMessageParser.clear()
+        loginVm.getApiDomain()
         GoogleLogin.init(this)
         FBLogin.init(object : IFacebook {
             override fun getToken(token: String) {

+ 17 - 0
login/src/main/java/com/swago/login/LoginVm.kt

@@ -61,4 +61,21 @@ class LoginVm(application: Application) : BaseViewModel(application) {
             }
         }
     }
+    fun getApiDomain() {
+        val configModel = SpUtil.readString("configModel")
+        if (!configModel.isNullOrEmpty())
+            return
+        requestData2 {
+            requestData {
+                val data = ApiManager.configApi.getAppConfig()
+                SpUtil.putString("configModel", gson.toJson(data))
+                UrlConstant.setAgoraId(data.agoral_app_id)
+                UrlConstant.setImId(data.im_app_id)
+                UrlConstant.lottieDownloadUrl = data.special_zip_url
+            }
+
+            requestError {
+            }
+        }
+    }
 }

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

@@ -20,6 +20,7 @@ import com.swago.baseswago.util.SwagoInfo
 import com.swago.room.R
 import com.swago.room.databinding.ViewItemGiftBinding
 import com.swago.room.databinding.ViewWaftBinding
+import com.swago.room.sound.SoundPoolPlayer
 import com.swago.room.widget.MarqueeTextView
 import java.util.*
 
@@ -121,6 +122,10 @@ 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)}")
+                    with(SoundPoolPlayer){
+                        init(context)
+                        playSound()
+                    }
                 }else{
                     val sendName = "<font color='#FFDB43'>${next.senderName}</font>"
                     val giftName = "<font color='#FFDB43'>${localName}</font>"
@@ -165,6 +170,9 @@ class WaftView : FrameLayout {
         imGiftModelList.clear()
         animatorSet = null
         binding?.ll?.visibility = View.INVISIBLE
+        with( SoundPoolPlayer){
+            release()
+        }
     }
 
 }

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

@@ -0,0 +1,28 @@
+package com.swago.room.sound
+
+import android.content.Context
+import android.media.SoundPool
+import com.swago.room.R
+
+object SoundPoolPlayer {
+    private const val MAX_STREAMS = 5
+    private var soundPool:SoundPool?=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)
+        }
+    }
+
+    fun playSound(){
+        soundPool?.play(soundId,1f,1f,1,0,1f)
+    }
+
+    fun release(){
+        soundPool?.release()
+        soundPool=null
+    }
+
+}

+ 1 - 0
room/src/main/java/com/swago/room/widget/ComHeaderView.kt

@@ -155,6 +155,7 @@ class ComHeaderView  : ConstraintLayout, IRoomActiveListener, IHeader, RoomTimer
         binding.tvId.text = "Likes:${iRoomInfo.getLikeNum()}"
         binding.tvHot.text = iRoomInfo.getRoomHot()
         binding.tvIncome.text = iRoomInfo.getRoomIncome()
+        binding.tvRoomId.text = "ID:${iRoomInfo.getRoomId()}"
         localIncome = iRoomInfo.getRoomIncome().toLong()
 
         if (SwagoRoomManager.roleType == RoleType.anchor){

+ 11 - 0
room/src/main/res/layout/layout_user_header_view.xml

@@ -259,5 +259,16 @@
         android:layout_width="20dp"
         android:layout_height="20dp"/>
 
+    <TextView
+        android:id="@+id/tvRoomId"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        app:layout_constraintRight_toRightOf="parent"
+        app:layout_constraintTop_toBottomOf="@+id/cl"
+        android:layout_marginTop="12dp"
+        android:text="id"
+        android:layout_marginRight="12dp"
+        android:textSize="@dimen/sp_12"
+        android:textColor="#33000000"/>
 
 </androidx.constraintlayout.widget.ConstraintLayout>

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