Merge branch 'peko_feature/notify' into peko_test/2.5.0

This commit is contained in:
Max
2024-01-03 19:41:38 +08:00
8 changed files with 198 additions and 136 deletions

View File

@@ -285,6 +285,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,89 +656,66 @@ 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),
noticeInfo.nick.subAndReplaceDot(6),
ForegroundColorSpan(ContextCompat.getColor(context, R.color.color_FFF45E))
)
.append(
ResUtil.getString(R.string.avroom_widget_roomeffectview_027),
ForegroundColorSpan(Color.WHITE)
)
.append(
noticeInfo.nick.subAndReplaceDot(6) + " ",
ForegroundColorSpan(resources.getColor(R.color.notice_nick))
noticeInfo.luckyBagName,
ForegroundColorSpan(ContextCompat.getColor(context, R.color.color_FFF45E))
)
.append(
ResUtil.getString(R.string.avroom_widget_roomeffectview_05),
ResUtil.getString(R.string.avroom_widget_roomeffectview_028),
ForegroundColorSpan(Color.WHITE)
)
.append(
noticeInfo.luckyBagName + " ",
ForegroundColorSpan(resources.getColor(R.color.notice_nick))
noticeInfo.goldPrice + ResUtil.getString(R.string.diamond_name),
ForegroundColorSpan(ContextCompat.getColor(context, R.color.notice_nick))
)
.append(
ResUtil.getString(R.string.avroom_widget_roomeffectview_06),
ForegroundColorSpan(Color.WHITE)
)
.append(
noticeInfo.goldPrice + " ",
ForegroundColorSpan(resources.getColor(R.color.notice_nick))
)
.append(
ResUtil.getString(R.string.avroom_widget_roomeffectview_07),
ResUtil.getString(R.string.avroom_widget_roomeffectview_029),
ForegroundColorSpan(Color.WHITE)
)
.append(
noticeInfo.giftName,
ForegroundColorSpan(resources.getColor(R.color.notice_nick))
ForegroundColorSpan(ContextCompat.getColor(context, R.color.notice_nick))
)
if (noticeInfo.giftNum > 1) {
text.append(
"" + noticeInfo.giftNum,
ForegroundColorSpan(ContextCompat.getColor(context, R.color.white))
)
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
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)
isPlayAnim = false
}
}
}
messageTextView.text = text.build()
roomView.setOnClickListener {
AVRoomActivity.start(mContext, noticeInfo.roomUid)
}
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

@@ -20,9 +20,14 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.core.content.ContextCompat;
import androidx.core.text.HtmlCompat;
@@ -35,6 +40,7 @@ import com.yizhuan.erban.R;
import com.yizhuan.erban.avroom.activity.AVRoomActivity;
import com.yizhuan.erban.common.svga.SimpleSvgaCallback;
import com.yizhuan.erban.databinding.DialogAllPlayEffectBinding;
import com.yizhuan.erban.ui.utils.ImageLoadUtilsV2;
import com.yizhuan.erban.ui.webview.CommonWebViewActivity;
import com.yizhuan.erban.utils.RegexUtil;
import com.yizhuan.erban.utils.SpannableBuilder;
@@ -49,11 +55,18 @@ import com.yizhuan.xchat_android_core.treasurefairy.FairyMsgInfoBean;
import com.yizhuan.xchat_android_library.utils.ResUtil;
import com.yizhuan.xchat_android_library.utils.StringUtils;
import java.util.concurrent.TimeUnit;
import io.reactivex.Observable;
import io.reactivex.disposables.CompositeDisposable;
public class AllPlayEffectDialog extends BaseDialog {
private final PlayEffectInfo playEffectInfo;
private DialogAllPlayEffectBinding binding;
private CompositeDisposable disposable = null;
public AllPlayEffectDialog(Context context, @NonNull PlayEffectInfo playEffectInfo) {
super(context, R.style.FullScreenDialog);
this.playEffectInfo = playEffectInfo;
@@ -61,6 +74,7 @@ public class AllPlayEffectDialog extends BaseDialog {
@Override
protected void onCreate(Bundle savedInstanceState) {
disposable = new CompositeDisposable();
requestWindowFeature(Window.FEATURE_NO_TITLE);
binding = DialogAllPlayEffectBinding.inflate(LayoutInflater.from(getContext()));
setContentView(binding.getRoot());
@@ -260,93 +274,63 @@ public class AllPlayEffectDialog extends BaseDialog {
}
}
private void showLuckyBagNotify(LuckyBagNoticeInfo luckyBagNoticeInfo) {
private void showLuckyBagNotify(LuckyBagNoticeInfo noticeInfo) {
View roomView = LayoutInflater.from(getContext())
.inflate(R.layout.layout_room_lucky_bag_notify, null);
roomView.setOnClickListener(view -> goRoom(noticeInfo.getRoomTitle(),noticeInfo.getRoomUid()));
ImageView bagImageView = roomView.findViewById(R.id.iv_bag);
ImageLoadUtilsV2.loadImage(bagImageView, noticeInfo.getLuckyBagGiftPic());
ImageView giftImageView = roomView.findViewById(R.id.iv_gift);
ImageLoadUtilsV2.loadImage(giftImageView, noticeInfo.getGiftPic());
TextView messageTextView = roomView.findViewById(R.id.tv_message);
SpannableBuilder text = new SpannableBuilder()
.append(
ResUtil.getString(R.string.avroom_widget_roomeffectview_04),
subAndReplaceDot(noticeInfo.getNick(), 6),
new ForegroundColorSpan(ContextCompat.getColor(getContext(), R.color.color_FFF45E))
)
.append(
ResUtil.getString(R.string.avroom_widget_roomeffectview_027),
new ForegroundColorSpan(Color.WHITE)
)
.append(
subAndReplaceDot(luckyBagNoticeInfo.getNick(), 6) + " ",
new ForegroundColorSpan(ContextCompat.getColor(getContext(),R.color.notice_nick))
noticeInfo.getLuckyBagName(),
new ForegroundColorSpan(ContextCompat.getColor(getContext(), R.color.color_FFF45E))
)
.append(
ResUtil.getString(R.string.avroom_widget_roomeffectview_05),
ResUtil.getString(R.string.avroom_widget_roomeffectview_028),
new ForegroundColorSpan(Color.WHITE)
)
.append(
luckyBagNoticeInfo.getLuckyBagName() + " ",
noticeInfo.getGoldPrice() + ResUtil.getString(R.string.diamond_name),
new ForegroundColorSpan(ContextCompat.getColor(getContext(), R.color.notice_nick))
)
.append(
ResUtil.getString(R.string.avroom_widget_roomeffectview_06),
ResUtil.getString(R.string.avroom_widget_roomeffectview_029),
new ForegroundColorSpan(Color.WHITE)
)
.append(
luckyBagNoticeInfo.getGoldPrice() + " ",
new ForegroundColorSpan(ContextCompat.getColor(getContext(), R.color.notice_nick))
)
.append(
ResUtil.getString(R.string.avroom_widget_roomeffectview_07),
new ForegroundColorSpan(Color.WHITE)
)
.append(
luckyBagNoticeInfo.getGiftName(),
noticeInfo.getGiftName(),
new ForegroundColorSpan(ContextCompat.getColor(getContext(), R.color.notice_nick))
);
SVGAImageView svgaImageView = new SVGAImageView(getContext());
svgaImageView.setLoops(1);
svgaImageView.setClearsAfterDetached(true);
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT);
svgaImageView.setLayoutParams(params);
svgaImageView.setCallback(new SimpleSvgaCallback() {
@Override
public void onFinished() {
closeSelf();
}
});
binding.flSvgaNotify.addView(svgaImageView);
try {
SVGAParser.Companion.shareParser().decodeFromAssets("svga/lucky_gift_notify.svga", new SVGAParser.ParseCompletion() {
@Override
public void onComplete(@NonNull SVGAVideoEntity svgaVideoEntity) {
SVGADynamicEntity dynamicEntity = new SVGADynamicEntity();
TextPaint textPaint = new TextPaint();
textPaint.setColor(Color.WHITE);//字体颜色
textPaint.setTextSize(24);//字体大小
dynamicEntity.setDynamicText(new StaticLayout(
text.build(),
0,
text.build().length(),
textPaint,
0,
Layout.Alignment.ALIGN_CENTER,
1.0f,
0.0f,
false
), "fdpp_copywriting");
svgaImageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//跳轉房間要移除監聽,不然可能NPE
svgaImageView.setCallback(null);
AVRoomActivity.start(getContext(), luckyBagNoticeInfo.getRoomUid());
}
});
SVGADrawable drawable = new SVGADrawable(svgaVideoEntity, dynamicEntity);
svgaImageView.setImageDrawable(drawable);
svgaImageView.stepToFrame(0, true);
}
@Override
public void onError() {
closeSelf();
}
}, null);
} catch (Exception e) {
e.printStackTrace();
closeSelf();
if (noticeInfo.getGiftNum() > 1) {
text.append(
"" + noticeInfo.getGiftNum(),
new ForegroundColorSpan(ContextCompat.getColor(getContext(), R.color.white))
);
}
messageTextView.setText(text.build());
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT);
ConstraintLayout.LayoutParams layoutParams = (ConstraintLayout.LayoutParams) binding.flSvgaNotify.getLayoutParams();
layoutParams.dimensionRatio = "375:71";
binding.flSvgaNotify.setLayoutParams(layoutParams);
binding.flSvgaNotify.addView(roomView,params);
Animation animation = AnimationUtils.loadAnimation(getContext(), R.anim.anim_box_notify);
roomView.startAnimation(animation);
disposable.add(Observable.timer(6500, TimeUnit.MILLISECONDS).subscribe(aLong -> {
Animation animation1 = AnimationUtils.loadAnimation(getContext(), R.anim.anim_box_notify_close);
roomView.startAnimation(animation1);
}));
disposable.add(Observable.timer(7000, TimeUnit.MILLISECONDS).subscribe(aLong -> closeSelf()));
}
private void showNotifyH5BySvga(NotifyH5Info info) {
@@ -510,18 +494,32 @@ public class AllPlayEffectDialog extends BaseDialog {
}
private String subAndReplaceDot(String nick, int maxLength) {
if(nick.length() > maxLength){
return nick.substring(0,maxLength)+"...";
}else {
if (nick.length() > maxLength) {
return nick.substring(0, maxLength) + "...";
} else {
return nick;
}
}
private void closeSelf() {
try {
if (disposable != null) {
disposable.dispose();
}
dismiss();
} catch (Exception e) {
e.printStackTrace();
}
}
private void goRoom(String roomTitle, long roomUid) {
if (roomUid <= 0L) {
return;
}
if (AllServiceGiftGoRoomTipsDialog.Companion.isNeedTips()) {
new AllServiceGiftGoRoomTipsDialog(getContext(), roomTitle, roomUid).show();
} else {
AVRoomActivity.start(getContext(), roomUid);
}
}
}

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

@@ -555,6 +555,7 @@
<color name="color_fe5d7f">#fe5d7f</color>
<color name="color_2D93FF">#2D93FF</color>
<color name="color_FFF45E">#FFF45E</color>
<!-- PekoUI规范 start-->

View File

@@ -1808,6 +1808,9 @@
<string name="avroom_widget_roomeffectview_024">svga解析失敗</string>
<string name="avroom_widget_roomeffectview_025">恭喜</string>
<string name="avroom_widget_roomeffectview_026">恭喜&lt;font color=&quot;#FFEE8F&quot;&gt;%s&lt;/font&gt;在幸運塔羅中運氣爆發,獲得&lt;font color=&quot;#FFEE8F&quot;&gt;%d&lt;/font&gt;钻石!</string>
<string name="avroom_widget_roomeffectview_027">運氣爆表!在</string>
<string name="avroom_widget_roomeffectview_028">中開出了\n價值</string>
<string name="avroom_widget_roomeffectview_029"></string>
<string name="avroom_widget_roomranknavigatoradapter_01">貢獻榜</string>
<string name="avroom_widget_roomranknavigatoradapter_02">魅力榜</string>
<string name="erban_base_baseactivity_01">請稍後...</string>

View File

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