feat:完成房间内福袋飘窗UI调整

This commit is contained in:
Max
2024-01-02 15:29:26 +08:00
parent 24ccadc593
commit 072c837c99
6 changed files with 108 additions and 51 deletions

View File

@@ -19,6 +19,7 @@ import android.view.animation.AnimationUtils
import android.widget.FrameLayout
import android.widget.ImageView
import android.widget.TextView
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.content.ContextCompat
import androidx.core.text.HtmlCompat
import com.coorchice.library.SuperTextView
@@ -285,6 +286,9 @@ class RoomEffectView @JvmOverloads constructor(
if (binding.flPlayNotify.childCount != 0) {
return@subscribe
}
if (binding.flLuckyBagNotify.childCount != 0) {
return@subscribe
}
when (messagesPlay[0].event) {
RoomEvent.BOX_NOTIFY -> {//寻爱
@@ -653,6 +657,13 @@ class RoomEffectView @JvmOverloads constructor(
val message = roomPlayBean.chatRoomMessage
val attachment = message.attachment as? RoomReceivedLuckyGiftAttachment ?: return
val noticeInfo = attachment.luckyBagNoticeInfo ?: return
val roomView = LayoutInflater.from(mContext)
.inflate(R.layout.layout_room_lucky_bag_notify, null)
val bagImageView = roomView.findViewById<ImageView>(R.id.iv_bag)
bagImageView.load(noticeInfo.luckyBagGiftPic)
val giftImageView = roomView.findViewById<ImageView>(R.id.iv_gift)
giftImageView.load(noticeInfo.giftPic)
val messageTextView = roomView.findViewById<TextView>(R.id.tv_message)
val text = SpannableBuilder()
.append(
ResUtil.getString(R.string.avroom_widget_roomeffectview_04),
@@ -686,56 +697,24 @@ class RoomEffectView @JvmOverloads constructor(
noticeInfo.giftName,
ForegroundColorSpan(resources.getColor(R.color.notice_nick))
)
val svgaImageView = SVGAImageView(mContext)
svgaImageView.loops = 1
svgaImageView.clearsAfterStop = true
shareParser().decodeFromAssets(
"svga/lucky_gift_notify.svga",
object : SVGAParser.ParseCompletion {
override fun onComplete(videoItem: SVGAVideoEntity) {
binding.flPlayNotify.addView(svgaImageView)
val dynamicEntity = SVGADynamicEntity()
val textPaint = TextPaint()
textPaint.color = Color.WHITE //字體顏色
textPaint.textSize = 24f //字體大小
dynamicEntity.setDynamicText(
StaticLayout(
text.build(),
0,
text.build().length,
textPaint,
0,
Layout.Alignment.ALIGN_CENTER,
1.0f,
0.0f,
false
), "fdpp_copywriting"
)
if (AvRoomDataManager.get().roomUid == noticeInfo.roomUid) {
dynamicEntity.setHidden(true, "img_206")
} else {
svgaImageView.setOnClickListener {
//跳轉房間要移除監聽,不然可能NPE
svgaImageView.callback = null
messageTextView.text = text.build()
roomView.setOnClickListener {
AVRoomActivity.start(mContext, noticeInfo.roomUid)
}
}
val drawable = SVGADrawable(videoItem, dynamicEntity)
svgaImageView.setImageDrawable(drawable)
svgaImageView.stepToFrame(0, true)
}
override fun onError() {}
})
svgaImageView.callback = object : SimpleSvgaCallback() {
override fun onFinished() {
binding.flPlayNotify.post {
binding.flPlayNotify.removeView(svgaImageView)
animationPlay = AnimationUtils.loadAnimation(mContext, R.anim.anim_box_notify)
binding.flLuckyBagNotify.addView(roomView)
roomView.startAnimation(animationPlay)
binding.flLuckyBagNotify.postDelayed(
{
animationPlay = AnimationUtils.loadAnimation(mContext, R.anim.anim_box_notify_close)
roomView.startAnimation(animationPlay)
},
SHOW_TIME.toLong()
)
binding.flLuckyBagNotify.postDelayed({
binding.flLuckyBagNotify.removeView(roomView)
isPlayAnim = false
}
}
}
}, CLOSE_TIME.toLong())
}
private fun showLuckySeaNotify(roomPlayBean: RoomPlayBean) {

View File

@@ -52,6 +52,13 @@
app:layout_constraintDimensionRatio="75:11"
app:layout_constraintTop_toTopOf="parent" />
<FrameLayout
android:id="@+id/fl_lucky_bag_notify"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintDimensionRatio="375:71" />
<FrameLayout
android:id="@+id/fl_lucky_gift_notify"
android:layout_width="match_parent"

View File

@@ -0,0 +1,69 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:background="@color/background_color_black"
tools:layout_height="80dp">
<com.opensource.svgaplayer.SVGAImageView
android:id="@+id/svga_imageview"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:autoPlay="true"
app:layout_constraintTop_toTopOf="parent"
app:source="svga/lucky_gift_notify.svga" />
<androidx.constraintlayout.widget.Guideline
android:id="@+id/line_start"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.024" />
<androidx.constraintlayout.widget.Guideline
android:id="@+id/line_end"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.976" />
<ImageView
android:id="@+id/iv_bag"
android:layout_width="0dp"
android:layout_height="0dp"
android:scaleType="fitCenter"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintDimensionRatio="1:1"
app:layout_constraintHeight_percent="0.845"
app:layout_constraintStart_toEndOf="@id/line_start"
app:layout_constraintTop_toTopOf="parent"
tools:src="@drawable/default_cover" />
<TextView
android:id="@+id/tv_message"
android:layout_width="0dp"
android:layout_height="match_parent"
android:ellipsize="end"
android:gravity="center"
android:maxLines="2"
android:textColor="@color/white"
android:textSize="@dimen/dp_12"
app:layout_constraintEnd_toStartOf="@id/iv_gift"
app:layout_constraintStart_toEndOf="@id/iv_bag"
tools:text="Message" />
<ImageView
android:id="@+id/iv_gift"
android:layout_width="0dp"
android:layout_height="0dp"
android:scaleType="fitCenter"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintDimensionRatio="1:1"
app:layout_constraintEnd_toStartOf="@id/line_end"
app:layout_constraintHeight_percent="0.845"
app:layout_constraintTop_toTopOf="parent"
tools:src="@drawable/default_cover" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -13,4 +13,6 @@ public class LuckyBagNoticeInfo implements Serializable {
private String giftName;
private String roomTitle;
private String goldPrice;
private String luckyBagGiftPic;
private String giftPic;
}

View File

@@ -31,8 +31,8 @@ COMPILE_SDK_VERSION=33
MIN_SDK_VERSION=21
TARGET_SDK_VERSION=33
version_name=2.2.0
version_code=2200
version_name=2.5.0
version_code=2500
#systemProp.https.proxyHost=127.0.0.1
#systemProp.https.proxyPort=7890