Parcourir la source

feat:优化

tongmengxiao il y a 3 mois
Parent
commit
48ab2497e4

+ 25 - 30
app/src/main/java/com/swago/app/SplashActivity.kt

@@ -18,25 +18,22 @@ import com.swago.baseswago.constant.UrlConstant
 import com.swago.baseswago.model.ConfigModel
 import com.swago.baseswago.util.AppContext
 import com.swago.baseswago.util.FileUtil
+import com.swago.baseswago.util.NoDoubleClickListener
 import com.swago.baseswago.util.SpUtil
 import com.swago.loadNoPlaceUrl
-import com.swago.loadUrl
 import java.io.File
-import java.text.SimpleDateFormat
-import java.util.Date
-import java.util.Locale
 
 
 class SplashActivity : AppCompatActivity() {
 
     private val splashVm by viewModels<SplashVm>()
 
-    private val currentDate: String = SimpleDateFormat("yyyyMMdd", Locale.getDefault()).format(Date())
     private var mSplashImage:ImageView ?= null
     private var mSplashTime:TextView ?= null
     private lateinit var countDownTimer: CountDownTimer
     private val totalTimeInMillis: Long = 4000
     private var configModel:ConfigModel ?= null
+    private var isRunning = false
 
     override fun onCreate(savedInstanceState: Bundle?) {
         super.onCreate(savedInstanceState)
@@ -111,6 +108,7 @@ class SplashActivity : AppCompatActivity() {
             }
 
             override fun onFinish() {
+                isRunning = false
                 splashVm.loginByAuto()
             }
         }
@@ -119,41 +117,38 @@ class SplashActivity : AppCompatActivity() {
             if (it == null || TextUtils.isEmpty(it.rotation_img_url)){
                 splashVm.loginByAuto()
             } else {
-                var count = SpUtil.readInt("splashCount")
-                val lastDate = SpUtil.readString("lastShowDate")
-                configModel = it
-                if (currentDate == lastDate){
-                    if (count <= 3){
-                        count++
-                        countDownTimer.start()
+                mSplashImage?.loadNoPlaceUrl(this, it.rotation_img_url) { success ->
+                    if (success){
                         mSplashTime?.visibility = View.VISIBLE
-                        mSplashImage?.loadNoPlaceUrl(this, it.rotation_img_url)
-                        SpUtil.putInt("splashCount" , count)
+                        isRunning = true
+                        countDownTimer.start()
                     } else {
                         splashVm.loginByAuto()
                     }
-                } else {
-                    SpUtil.putInt("splashCount" , 1)
-                    SpUtil.putString("lastShowDate",currentDate)
-                    countDownTimer.start()
-                    mSplashTime?.visibility = View.VISIBLE
-                    mSplashImage?.loadNoPlaceUrl(this, it.rotation_img_url)
+
                 }
             }
         }
 
-        mSplashImage?.setOnClickListener {
-            configModel?.rotation_url?.let {
-                ARouter.getInstance().build(ARouteConstant.Base.webView)
-                    .withString("url", it)
-                    .navigation()
+        mSplashImage?.setOnClickListener(object :NoDoubleClickListener() {
+            override fun onClick() {
+                configModel?.rotation_url?.let {
+                    ARouter.getInstance().build(ARouteConstant.Base.webView)
+                        .withString("url", it)
+                        .navigation()
+                }
             }
-        }
+        })
 
-        mSplashTime?.setOnClickListener {
-            countDownTimer.cancel()
-            splashVm.loginByAuto()
-        }
+        mSplashTime?.setOnClickListener(object :NoDoubleClickListener(){
+            override fun onClick() {
+                countDownTimer.cancel()
+                if (isRunning){
+                    isRunning = false
+                    splashVm.loginByAuto()
+                }
+            }
+        })
     }
 
     override fun onDestroy() {

+ 1 - 0
baseswago/src/main/java/com/swago/baseswago/model/im/GamePrize.kt

@@ -5,4 +5,5 @@ class GamePrize:IPiaoTiao{
     val senderId:String=""
     val gameName:String=""
     val coin:String=""
+    val headSpecial:String=""
 }

+ 11 - 0
baseswago/src/main/java/com/swago/baseswago/model/live/gift/IMGiftModel.java

@@ -1,5 +1,7 @@
 package com.swago.baseswago.model.live.gift;
 
+import android.text.TextUtils;
+
 import com.swago.baseswago.model.im.IPiaoTiao;
 
 /**
@@ -53,6 +55,7 @@ public class IMGiftModel implements IPiaoTiao {
     private String giftEnName = "";
 
     private String giftIdName = "";
+    private String headSpecial = "";
 
     private String userWealthJingyanValue;
 
@@ -259,4 +262,12 @@ public class IMGiftModel implements IPiaoTiao {
     public void setAndroidHeadSpecial(String androidHeadSpecial) {
         this.androidHeadSpecial = androidHeadSpecial;
     }
+
+    public String getHeadSpecial() {
+        return TextUtils.isEmpty(headSpecial) ? androidHeadSpecial : headSpecial;
+    }
+
+    public void setHeadSpecial(String headSpecial) {
+        this.headSpecial = headSpecial;
+    }
 }

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

@@ -14,9 +14,13 @@ import android.widget.ImageView
 import androidx.annotation.DrawableRes
 import androidx.annotation.RequiresApi
 import com.bumptech.glide.Glide
+import com.bumptech.glide.load.DataSource
 import com.bumptech.glide.load.engine.DiskCacheStrategy
+import com.bumptech.glide.load.engine.GlideException
+import com.bumptech.glide.request.RequestListener
 import com.bumptech.glide.request.RequestOptions
 import com.bumptech.glide.request.target.CustomTarget
+import com.bumptech.glide.request.target.Target
 import com.bumptech.glide.request.transition.Transition
 import com.swago.baseswago.R
 import jp.wasabeef.glide.transformations.BlurTransformation
@@ -48,10 +52,33 @@ fun ImageView.loadUrl(context: Context,url:String){
         .into(this)
 }
 
-fun ImageView.loadNoPlaceUrl(context: Context,url:String){
+fun ImageView.loadNoPlaceUrl(context: Context,url:String,call: (success:Boolean) -> Unit){
     Glide.with(context)
         .load(url)
         .centerCrop()
+        .listener(object :RequestListener<Drawable>{
+            override fun onLoadFailed(
+                e: GlideException?,
+                model: Any?,
+                target: Target<Drawable>?,
+                isFirstResource: Boolean
+            ): Boolean {
+                call.invoke(false)
+                return false
+            }
+
+            override fun onResourceReady(
+                resource: Drawable?,
+                model: Any?,
+                target: Target<Drawable>?,
+                dataSource: DataSource?,
+                isFirstResource: Boolean
+            ): Boolean {
+                call.invoke(true)
+                return false
+            }
+
+        })
         .into(this)
 }
 

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

@@ -404,8 +404,9 @@ class AnchorRoomActivity : AbsAnchorActivity<ActivityAnchorRoomBinding, IRoomInf
             checkPassword = isChecked
         }
         binding.cbClarity.setOnCheckedChangeListener { _, isChecked ->
+            binding.cbClarity.text = if (isChecked)  getString(R.string.hd) else getString(R.string.sd)
             if (isChecked){
-                AgoraManager.setVideoConfiguration(VideoEncoderConfiguration.VD_960x720 ,VideoEncoderConfiguration.FRAME_RATE.FRAME_RATE_FPS_15)
+                AgoraManager.setVideoConfiguration(VideoEncoderConfiguration.VD_1280x720 ,VideoEncoderConfiguration.FRAME_RATE.FRAME_RATE_FPS_15)
             } else{
                 AgoraManager.setVideoConfiguration()
             }

+ 3 - 1
room/src/main/java/com/swago/room/giftdandao/GiftDanDaoView.kt

@@ -248,7 +248,9 @@ class GiftDanDaoView : FrameLayout {
                         iv.visibility = View.VISIBLE
                         tvWinPrize2.visibility = View.GONE
                         svgaWinPrize.visibility = View.GONE
-                        clPrize.visibility = View.GONE
+                        if (aniamtionScale?.isRunning == false){
+                            clPrize.visibility = View.GONE
+                        }
                         val layoutParams = tvWinPrize.layoutParams as ConstraintLayout.LayoutParams
                         layoutParams.marginStart = DpPxUtil.dip2px(10f)
                         tvWinPrize.layoutParams = layoutParams

+ 48 - 5
room/src/main/java/com/swago/room/piaotiao/WaftView.kt

@@ -10,7 +10,9 @@ import android.util.AttributeSet
 import android.view.LayoutInflater
 import android.view.View
 import android.widget.FrameLayout
-import android.widget.LinearLayout
+import com.opensource.svgaplayer.SVGADrawable
+import com.opensource.svgaplayer.SVGAParser
+import com.opensource.svgaplayer.SVGAVideoEntity
 import com.swago.baseswago.model.im.GamePrize
 import com.swago.baseswago.model.im.IPiaoTiao
 import com.swago.baseswago.model.im.PiaoTiaoRewardsData
@@ -19,10 +21,8 @@ import com.swago.baseswago.util.AppContext
 import com.swago.baseswago.util.DpPxUtil
 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.net.URL
 import java.util.*
 
 /**
@@ -35,7 +35,7 @@ class WaftView : FrameLayout {
 
     private val imGiftModelList = LinkedList<IPiaoTiao>()
     private var binding : ViewWaftBinding? = null
-
+    private var svgaParser:SVGAParser? = null
     constructor(context: Context) : super(context)
     constructor(context: Context, mAttributeSet: AttributeSet?) : super(context, mAttributeSet){
         initView(context)
@@ -43,6 +43,7 @@ class WaftView : FrameLayout {
 
     private fun initView(context: Context) {
         binding = ViewWaftBinding.inflate(LayoutInflater.from(context), this, true)
+        svgaParser = SVGAParser(context)
     }
 
 
@@ -121,6 +122,8 @@ class WaftView : FrameLayout {
                     val sendName = "<font color='#FFDB43'>${next.senderName}</font>"
                     val giftName = "<font color='#FFDB43'>${localName}</font>"
                     val multiple = "<font color='#FFDB43'>${next.multiple}</font>"
+                    binding?.ivFunction?.visibility = View.GONE
+                    binding?.ivAvatar?.visibility = View.VISIBLE
                     binding?.ll?.setBackgroundResource(R.mipmap.bg_waft_big_prize)
                     binding?.ivPrize?.setImageResource(R.mipmap.ic_waft_big_prize)
                     binding?.tvPrize?.text = "${next.multiple}"
@@ -130,17 +133,36 @@ class WaftView : FrameLayout {
                     val sendName = "<font color='#FFDB43'>${next.senderName}</font>"
                     val giftName = "<font color='#FFDB43'>${localName}</font>"
                     val receiverName = "<font color='#FFDB43'>${next.receiverName}</font>"
+                    binding?.ivFunction?.visibility = View.GONE
+                    binding?.ivAvatar?.visibility = View.VISIBLE
                     binding?.ll?.setBackgroundResource(R.mipmap.bg_waft_send)
                     binding?.ivPrize?.setImageResource(R.mipmap.ic_waft_send)
                     binding?.tvPrize?.text = ""
                     binding?.marqueeTextView?.text = Html.fromHtml("\u200E${AppContext.getContext().resources.getString(R.string.big_gift_msg).format(sendName,giftName,receiverName)}")
                 }
+                if (!next.headSpecial.isNullOrEmpty()){
+                    binding?.svgAvatar?.visibility = View.VISIBLE
+                    svgaParser?.decodeFromURL(URL(next.headSpecial), object : SVGAParser.ParseCompletion{
+                        override fun onComplete(videoItem: SVGAVideoEntity) {
+                            val drawable = SVGADrawable(videoItem)
+                            binding?.svgAvatar?.setImageDrawable(drawable)
+                            binding?.svgAvatar?.startAnimation()
+                        }
+
+                        override fun onError() {
+                        }
+                    })
+                } else {
+                    binding?.svgAvatar?.visibility = View.GONE
+                }
             }
 
             is GamePrize -> {
                 val sendName = "<font color='#FFDB43'>${next.senderName}</font>"
                 val gameName = "<font color='#FFDB43'>${next.gameName}</font>"
                 val coin = "<font color='#FFDB43'>${next.coin}</font>"
+                binding?.ivFunction?.visibility = View.GONE
+                binding?.ivAvatar?.visibility = View.VISIBLE
                 binding?.ll?.setBackgroundResource(R.mipmap.bg_waft_game)
                 binding?.tvPrize?.setBackgroundResource(R.mipmap.ic_waft_game)
                 binding?.tvPrize?.text = ""
@@ -152,12 +174,26 @@ class WaftView : FrameLayout {
                         binding?.marqueeTextView?.text = Html.fromHtml("\u200E${AppContext.getContext().resources.getString(R.string.game_prize).format(sendName,gameName,coin)}")
                     }
                 }
+                if (next.headSpecial.isNotEmpty()){
+                    svgaParser?.decodeFromURL(URL(next.headSpecial), object : SVGAParser.ParseCompletion{
+                        override fun onComplete(videoItem: SVGAVideoEntity) {
+                            val drawable = SVGADrawable(videoItem)
+                            binding?.svgAvatar?.setImageDrawable(drawable)
+                            binding?.svgAvatar?.startAnimation()
+                        }
+
+                        override fun onError() {
+                        }
+                    })
+                }
             }
             is PiaoTiaoRewardsData -> {
                 when(next.type) {
                     505 -> {
                         val sendName = "<font color='#FFDB43'>${next.userName}</font>"
                         val coin = "<font color='#FFDB43'>${next.sort}</font>"
+                        binding?.ivFunction?.visibility = View.VISIBLE
+                        binding?.ivAvatar?.visibility = View.GONE
                         binding?.ll?.setBackgroundResource(R.mipmap.bg_waft_function)
                         binding?.ivPrize?.setImageResource(R.mipmap.ic_waft_function)
                         binding?.tvPrize?.text = ""
@@ -166,6 +202,8 @@ class WaftView : FrameLayout {
                     506 -> {
                         val sendName = "<font color='#FFDB43'>${next.userName}</font>"
                         val coin = "<font color='#FFDB43'>${next.sort}</font>"
+                        binding?.ivFunction?.visibility = View.VISIBLE
+                        binding?.ivAvatar?.visibility = View.GONE
                         binding?.ll?.setBackgroundResource(R.mipmap.bg_waft_function)
                         binding?.ivPrize?.setImageResource(R.mipmap.ic_waft_function)
                         binding?.tvPrize?.text = ""
@@ -174,6 +212,8 @@ class WaftView : FrameLayout {
                     507 -> {
                         val sendName = "<font color='#FFDB43'>${next.userName}</font>"
                         val coin = "<font color='#FFDB43'>${next.winCoin}</font>"
+                        binding?.ivFunction?.visibility = View.VISIBLE
+                        binding?.ivAvatar?.visibility = View.GONE
                         binding?.ll?.setBackgroundResource(R.mipmap.bg_waft_function)
                         binding?.ivPrize?.setImageResource(R.mipmap.ic_waft_function)
                         binding?.tvPrize?.text = ""
@@ -181,6 +221,8 @@ class WaftView : FrameLayout {
                     }
                     508 -> {
                         val coin = "<font color='#FFDB43'>${next.actCoin}</font>"
+                        binding?.ivFunction?.visibility = View.VISIBLE
+                        binding?.ivAvatar?.visibility = View.GONE
                         binding?.ll?.setBackgroundResource(R.mipmap.bg_waft_function)
                         binding?.ivPrize?.setImageResource(R.mipmap.ic_waft_function)
                         binding?.tvPrize?.text = ""
@@ -196,6 +238,7 @@ class WaftView : FrameLayout {
 
 
         binding?.marqueeTextView?.post {
+            binding?.marqueeTextView?.stopScroll()
             binding?.marqueeTextView?.startScroll()
         }
         binding?.let {

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

@@ -170,7 +170,7 @@
                 android:textSize="14dp"
                 android:button="@null"
                 android:layout_marginTop="3dp"
-                android:text="@string/lock_room_off"
+                android:text="@string/sd"
                 android:drawablePadding="4dp"
                 android:gravity="center_horizontal"
                 android:background="@android:color/transparent"

+ 0 - 2
room/src/main/res/layout/view_item_gift.xml

@@ -227,7 +227,6 @@
             android:id="@+id/iv_prize_bg"
             android:layout_width="wrap_content"
             android:layout_height="match_parent"
-            android:src="@mipmap/gift_bg_prize_1000"
             android:scaleType="centerInside"
             android:layout_marginStart="40dp"
             android:layout_marginTop="30dp"
@@ -238,7 +237,6 @@
             android:id="@+id/iv_prize_frame"
             android:layout_width="wrap_content"
             android:layout_height="match_parent"
-            android:src="@mipmap/gift_prize_frame_1000"
             android:scaleType="centerInside"
             android:layout_marginTop="30dp"
             android:layout_alignParentTop="true"

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

@@ -33,7 +33,7 @@
         android:id="@+id/tvTime"
         android:textSize="10dp"
         android:textColor="#FD4B5E"
-        tools:text="00:29"
+        tools:text="00:59"
         android:gravity="center"
         android:layout_marginBottom="3dp"
         app:layout_constraintStart_toStartOf="parent"

+ 21 - 3
room/src/main/res/layout/view_waft.xml

@@ -18,18 +18,34 @@
         app:layout_constraintTop_toTopOf="parent"
         app:layout_constraintBottom_toBottomOf="parent"
         app:layout_constraintEnd_toEndOf="parent"
+        android:layout_marginEnd="10dp"
+        android:background="@mipmap/ic_waft_big_prize"/>
+    <ImageView
+        android:id="@+id/iv_function"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:visibility="gone"
+        tools:visibility="visible"
+        android:layout_marginStart="@dimen/dp_10"
+        app:layout_constraintTop_toTopOf="parent"
+        app:layout_constraintBottom_toBottomOf="parent"
+        app:layout_constraintStart_toStartOf="parent"
         android:background="@mipmap/ic_waft_big_prize"/>
 
     <TextView
         android:id="@+id/tv_prize"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
-        android:textSize="18sp"
-        tools:text="123"
+        android:textSize="22sp"
+        tools:text="1234"
         android:typeface="monospace"
         android:textStyle="bold"
         android:textColor="#FFF000"
         android:gravity="center"
+        android:shadowDx="6"
+        android:shadowDy="6"
+        android:shadowRadius="4"
+        android:shadowColor="#FF6D00"
         app:layout_constraintTop_toTopOf="parent"
         app:layout_constraintBottom_toBottomOf="parent"
         app:layout_constraintEnd_toEndOf="@+id/iv_prize"
@@ -41,6 +57,8 @@
         app:layout_constraintTop_toTopOf="parent"
         app:layout_constraintBottom_toBottomOf="parent"
         app:layout_constraintStart_toStartOf="parent"
+        android:visibility="gone"
+        tools:visibility="visible"
         android:layout_marginStart="18dp"
         android:layout_width="28dp"
         android:layout_height="28dp"/>
@@ -50,7 +68,7 @@
         android:layout_width="34dp"
         android:layout_height="34dp"
         android:visibility="visible"
-        android:layout_marginStart="18dp"
+        android:layout_marginStart="14dp"
         app:autoPlay="true"
         app:loopCount="0"
         app:layout_constraintStart_toStartOf="parent"