diff --git a/app/src/main/assets/svga/lucky_gift_notify.svga b/app/src/main/assets/svga/lucky_gift_notify.svga index 2b9d5a578..7fb25561f 100644 Binary files a/app/src/main/assets/svga/lucky_gift_notify.svga and b/app/src/main/assets/svga/lucky_gift_notify.svga differ diff --git a/app/src/main/java/com/yizhuan/erban/avroom/widget/RoomEffectView.kt b/app/src/main/java/com/yizhuan/erban/avroom/widget/RoomEffectView.kt index 1016d2025..78046522d 100644 --- a/app/src/main/java/com/yizhuan/erban/avroom/widget/RoomEffectView.kt +++ b/app/src/main/java/com/yizhuan/erban/avroom/widget/RoomEffectView.kt @@ -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(R.id.iv_bag) + bagImageView.load(noticeInfo.luckyBagGiftPic) + val giftImageView = roomView.findViewById(R.id.iv_gift) + giftImageView.load(noticeInfo.giftPic) + val messageTextView = roomView.findViewById(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) { diff --git a/app/src/main/java/com/yizhuan/erban/ui/widget/dialog/AllPlayEffectDialog.java b/app/src/main/java/com/yizhuan/erban/ui/widget/dialog/AllPlayEffectDialog.java index 1373e36c9..79a8ec59c 100644 --- a/app/src/main/java/com/yizhuan/erban/ui/widget/dialog/AllPlayEffectDialog.java +++ b/app/src/main/java/com/yizhuan/erban/ui/widget/dialog/AllPlayEffectDialog.java @@ -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); + } + } } diff --git a/app/src/main/res/layout/layout_room_effect.xml b/app/src/main/res/layout/layout_room_effect.xml index 2cd67563b..626d78dc5 100644 --- a/app/src/main/res/layout/layout_room_effect.xml +++ b/app/src/main/res/layout/layout_room_effect.xml @@ -52,6 +52,13 @@ app:layout_constraintDimensionRatio="75:11" app:layout_constraintTop_toTopOf="parent" /> + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index d0539d873..94357e9f2 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -555,6 +555,7 @@ #fe5d7f #2D93FF + #FFF45E diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 4e5718e52..0c87e403c 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1808,6 +1808,9 @@ svga解析失敗 恭喜 恭喜<font color="#FFEE8F">%s</font>在幸運塔羅中運氣爆發,獲得<font color="#FFEE8F">%d</font>钻石! + 運氣爆表!在 + 中開出了\n價值 + 貢獻榜 魅力榜 請稍後... diff --git a/core/src/main/java/com/yizhuan/xchat_android_core/gift/bean/LuckyBagNoticeInfo.java b/core/src/main/java/com/yizhuan/xchat_android_core/gift/bean/LuckyBagNoticeInfo.java index 37fd5f7bf..3dcc98c32 100644 --- a/core/src/main/java/com/yizhuan/xchat_android_core/gift/bean/LuckyBagNoticeInfo.java +++ b/core/src/main/java/com/yizhuan/xchat_android_core/gift/bean/LuckyBagNoticeInfo.java @@ -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; + }