diff --git a/app/src/main/java/com/yizhuan/erban/avroom/fragment/HomePartyFragment.java b/app/src/main/java/com/yizhuan/erban/avroom/fragment/HomePartyFragment.java index 72000041b..3064a1292 100644 --- a/app/src/main/java/com/yizhuan/erban/avroom/fragment/HomePartyFragment.java +++ b/app/src/main/java/com/yizhuan/erban/avroom/fragment/HomePartyFragment.java @@ -32,6 +32,7 @@ import com.yizhuan.erban.avroom.activity.RoomOnlineUserActivity; import com.yizhuan.erban.avroom.adapter.SelectGameAdapter; import com.yizhuan.erban.avroom.dialog.ExitRoomPopupWindow; import com.yizhuan.erban.avroom.widget.GiftV2View; +import com.yizhuan.erban.avroom.widget.RoomEffectView; import com.yizhuan.erban.base.BaseFragment; import com.yizhuan.erban.databinding.FragmentChatroomGameMainBinding; import com.yizhuan.erban.friend.view.SelectFriendActivity; @@ -62,10 +63,8 @@ import com.yizhuan.xchat_android_core.share.ShareModel; import com.yizhuan.xchat_android_core.super_admin.util.SuperAdminUtil; import com.yizhuan.xchat_android_core.user.UserModel; import com.yizhuan.xchat_android_core.user.bean.UserInfo; -import com.yizhuan.xchat_android_core.utils.LogUtils; import com.yizhuan.xchat_android_core.utils.Logger; import com.yizhuan.xchat_android_library.utils.JavaUtil; -import com.yizhuan.xchat_android_library.utils.LogUtil; import com.yizhuan.xchat_android_library.utils.ResUtil; import com.yizhuan.xchat_android_library.utils.SingleToastUtil; @@ -80,6 +79,7 @@ import cn.sharesdk.framework.Platform; import io.reactivex.SingleObserver; import io.reactivex.disposables.Disposable; import io.reactivex.functions.Action; +import kotlin.jvm.functions.Function0; /** * 轰趴房 @@ -100,6 +100,7 @@ public class HomePartyFragment extends BaseFragment implements View.OnClickListe private ImageView ivRoomShare; private GiftV2View giftView; private ViewStub mVsGift2View; + private RoomEffectView mRoomEffectView; private SVGAImageView svgaRoomBg; private String[] bgPicture = new String[]{""}; @@ -180,6 +181,7 @@ public class HomePartyFragment extends BaseFragment implements View.OnClickListe mIvGoodNumber = mView.findViewById(R.id.iv_good_number); ivFollowRoom = mView.findViewById(R.id.iv_follow_room); svgaRoomBg = mView.findViewById(R.id.svga_image_view_bg); + mRoomEffectView = mView.findViewById(R.id.room_effect_view); } /** @@ -211,6 +213,13 @@ public class HomePartyFragment extends BaseFragment implements View.OnClickListe ivRoomShare.setOnClickListener(this); gameMainBinding.llRoomInfo.setOnClickListener(this); gameMainBinding.ivBack.setOnClickListener(this); + + mRoomEffectView.setOnPlayAnimCallback(new Function0() { + @Override + public Boolean invoke() { + return getIsAnim(); + } + }); } @SuppressLint("CheckResult") @@ -348,15 +357,23 @@ public class HomePartyFragment extends BaseFragment implements View.OnClickListe /** * 获取礼物飘屏是否展示 + * * @return */ - private boolean getIsAnim(){ - if(giftView != null){ - return giftView.getIsAnim(); + private boolean getIsAnim() { + if (giftView != null) { + return giftView.getIsPlayAnim(); } return false; } + /** + * 获取玩法飘屏是否展示 + */ + private boolean getIsPlayAnim() { + return mRoomEffectView.getIsPlayAnim(); + } + private void onReceiveLuckyGiftToMultiMsg(LuckyBagGifts giftMultiReceiverInfo) { if (giftMultiReceiverInfo == null || !isResumed()) return; if (giftView == null) { diff --git a/app/src/main/java/com/yizhuan/erban/avroom/widget/GiftEffectView.java b/app/src/main/java/com/yizhuan/erban/avroom/widget/GiftEffectView.java index 43782773f..5ea618308 100644 --- a/app/src/main/java/com/yizhuan/erban/avroom/widget/GiftEffectView.java +++ b/app/src/main/java/com/yizhuan/erban/avroom/widget/GiftEffectView.java @@ -72,6 +72,7 @@ public class GiftEffectView extends RelativeLayout implements SVGACallback { private GiftEffectListener giftEffectListener; private EffectHandler effectHandler; private boolean isAnim; + private boolean isPlayAnim; private boolean isHideCarEffect; public GiftEffectView(Context context) { @@ -93,6 +94,10 @@ public class GiftEffectView extends RelativeLayout implements SVGACallback { return isAnim; } + public boolean isPlayAnim() { + return isPlayAnim; + } + public void setGiftEffectListener(GiftEffectListener giftEffectListener) { this.giftEffectListener = giftEffectListener; } @@ -135,6 +140,7 @@ public class GiftEffectView extends RelativeLayout implements SVGACallback { giftNumber.setText("X" + giftEffectInfo.getGiftNum()); giftName.setText(giftInfo.getGiftName()); container.setVisibility(VISIBLE); + isPlayAnim = true; if (giftEffectInfo.getGiftReceiveType() == GiftEffectInfo.GIFT_RECEIVE_TYPE_SINGLE) { GiftReceiver giftReceiver = giftEffectInfo.getTargetUsers().get(0); ImageLoadUtils.loadAvatar(receiverAvatar.getContext(), giftReceiver.getAvatar(), receiverAvatar); @@ -177,6 +183,9 @@ public class GiftEffectView extends RelativeLayout implements SVGACallback { } else { imgBg.setImageResource(R.drawable.icon_gift_effect_bg_3); } + } else { + isPlayAnim = false; + container.setVisibility(INVISIBLE); } effectHandler.sendEmptyMessageDelayed(0, 4000); if (giftInfo.getOtherViewType() == 1 && !TextUtils.isEmpty(giftInfo.getViewUrl())) { @@ -245,6 +254,7 @@ public class GiftEffectView extends RelativeLayout implements SVGACallback { } if (giftEffectListener != null) { isAnim = false; + isPlayAnim = false; giftEffectListener.onGiftEffectEnd(); } } diff --git a/app/src/main/java/com/yizhuan/erban/avroom/widget/GiftV2View.java b/app/src/main/java/com/yizhuan/erban/avroom/widget/GiftV2View.java index 9f6542d31..09c1f352c 100644 --- a/app/src/main/java/com/yizhuan/erban/avroom/widget/GiftV2View.java +++ b/app/src/main/java/com/yizhuan/erban/avroom/widget/GiftV2View.java @@ -554,8 +554,8 @@ public class GiftV2View extends FrameLayout implements GiftEffectView.GiftEffect * * @return */ - public boolean getIsAnim() { - return giftEffectView.isAnim(); + public boolean getIsPlayAnim() { + return giftEffectView.isPlayAnim(); } private void drawMagicView(Point senderPoint, Point receivePoint, MagicReceivedInfo magicReceivedInfo) { 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 010f23774..373dec225 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 @@ -39,6 +39,7 @@ import com.yizhuan.erban.ui.utils.loadAnim import com.yizhuan.erban.ui.webview.CommonWebViewActivity import com.yizhuan.erban.ui.widget.SimpleAnimListener import com.yizhuan.erban.ui.widget.drawgift.DrawGiftPlayHelper +import com.yizhuan.erban.ui.widget.magicindicator.buildins.UIUtil import com.yizhuan.erban.utils.MsgBuilder import com.yizhuan.erban.utils.SpannableBuilder import com.yizhuan.xchat_android_constants.XChatConstants @@ -128,6 +129,14 @@ class RoomEffectView @JvmOverloads constructor( private val drawGiftPlayHelper: DrawGiftPlayHelper by lazy { DrawGiftPlayHelper(context as Activity) } + private var isPlayAnim = false + + private var onPlayAnimCallback: (() -> Boolean)? = null + + fun setOnPlayAnimCallback(onPlayAnimCallback: (() -> Boolean)) { + this.onPlayAnimCallback = onPlayAnimCallback + } + private fun loopCarAnim() { if (context.isDestroyed()) return isSvgaPlaying = false @@ -248,29 +257,64 @@ class RoomEffectView @JvmOverloads constructor( .subscribe { if (binding.flPlayNotify.childCount == 0) { when (messagesPlay[0].event) { - RoomEvent.BOX_NOTIFY -> { + RoomEvent.BOX_NOTIFY -> {//寻爱 if ((mContext as AVRoomActivity).isTopActivity) { + isPlayAnim = true + val isPlay = onPlayAnimCallback?.invoke() ?: false + if (isPlay) { + margin(binding.clNotify, 0, UIUtil.dip2px(context, 180.0), 0, 0) + } else { + margin(binding.clNotify, 0, UIUtil.dip2px(context, 60.0), 0, 0) + } showBoxNotify( messagesPlay.removeAt(0) ) } } - RoomEvent.BOX_NOTIFY_SVGA -> { + RoomEvent.BOX_NOTIFY_SVGA -> {//寻爱 if ((mContext as AVRoomActivity).isTopActivity) { + isPlayAnim = true + val isPlay = onPlayAnimCallback?.invoke() ?: false + if (isPlay) { + margin(binding.clNotify, 0, UIUtil.dip2px(context, 180.0), 0, 0) + } else { + margin(binding.clNotify, 0, UIUtil.dip2px(context, 60.0), 0, 0) + } showBoxNotifyBySVGA(messagesPlay.removeAt(0)) } } - RoomEvent.RECEIVE_ROOM_LUCKY_BAG_NOTICE, RoomEvent.RECEIVE_SERVICE_LUCKY_BAG_NOTICE -> { + RoomEvent.RECEIVE_ROOM_LUCKY_BAG_NOTICE, RoomEvent.RECEIVE_SERVICE_LUCKY_BAG_NOTICE -> {//福袋 + isPlayAnim = true + val isPlay = onPlayAnimCallback?.invoke() ?: false + if (isPlay) { + margin(binding.clNotify, 0, UIUtil.dip2px(context, 180.0), 0, 0) + } else { + margin(binding.clNotify, 0, UIUtil.dip2px(context, 60.0), 0, 0) + } showLuckyBagNotify( messagesPlay.removeAt(0) ) } - RoomEvent.LUCKY_SEA_GIFT_ROOM_NOTIFY -> { + RoomEvent.LUCKY_SEA_GIFT_ROOM_NOTIFY -> {//星级厨房 + isPlayAnim = true + val isPlay = onPlayAnimCallback?.invoke() ?: false + if (isPlay) { + margin(binding.clNotify, 0, UIUtil.dip2px(context, 180.0), 0, 0) + } else { + margin(binding.clNotify, 0, UIUtil.dip2px(context, 60.0), 0, 0) + } showLuckySeaNotify( messagesPlay.removeAt(0) ) } - RoomEvent.LUCKY_SEA_GIFT_SERVER_NOTIFY -> { + RoomEvent.LUCKY_SEA_GIFT_SERVER_NOTIFY -> {//星级厨房 + isPlayAnim = true + val isPlay = onPlayAnimCallback?.invoke() ?: false + if (isPlay) { + margin(binding.clNotify, 0, UIUtil.dip2px(context, 180.0), 0, 0) + } else { + margin(binding.clNotify, 0, UIUtil.dip2px(context, 60.0), 0, 0) + } showLuckySeaNotifyBySVGA( messagesPlay.removeAt(0) ) @@ -279,7 +323,14 @@ class RoomEffectView @JvmOverloads constructor( RoomEvent.FAIRY_DRAW_GIFT_L5, RoomEvent.FAIRY_CONVERT_L1, RoomEvent.FAIRY_CONVERT_L2, - RoomEvent.FAIRY_CONVERT_L3 -> { + RoomEvent.FAIRY_CONVERT_L3 -> {//夺宝 + isPlayAnim = true + val isPlay = onPlayAnimCallback?.invoke() ?: false + if (isPlay) { + margin(binding.clNotify, 0, UIUtil.dip2px(context, 180.0), 0, 0) + } else { + margin(binding.clNotify, 0, UIUtil.dip2px(context, 60.0), 0, 0) + } showFairyNotify( messagesPlay.removeAt(0) ) @@ -306,7 +357,10 @@ class RoomEffectView @JvmOverloads constructor( binding.flPlayNotify.addView(textView) textView.startAnimation(animationPlay) binding.flPlayNotify.postDelayed( - { binding.flPlayNotify.removeView(textView) }, + { + binding.flPlayNotify.removeView(textView) + isPlayAnim = false + }, SHOW_TIME.toLong() ) } @@ -330,9 +384,8 @@ class RoomEffectView @JvmOverloads constructor( svgaImageView.callback = object : SimpleSvgaCallback() { override fun onFinished() { binding.flPlayNotify.post { - binding.flPlayNotify.removeView( - svgaImageView - ) + binding.flPlayNotify.removeView(svgaImageView) + isPlayAnim = false } } } @@ -542,6 +595,7 @@ class RoomEffectView @JvmOverloads constructor( override fun onFinished() { binding.flPlayNotify.post { binding.flPlayNotify.removeView(svgaImageView) + isPlayAnim = false } } } @@ -588,7 +642,10 @@ class RoomEffectView @JvmOverloads constructor( binding.flPlayNotify.addView(textView) textView.startAnimation(animationPlay) binding.flPlayNotify.postDelayed( - { binding.flPlayNotify.removeView(textView) }, + { + binding.flPlayNotify.removeView(textView) + isPlayAnim = false + }, SHOW_TIME.toLong() ) } @@ -634,9 +691,8 @@ class RoomEffectView @JvmOverloads constructor( svgaImageView.callback = object : SimpleSvgaCallback() { override fun onFinished() { binding.flPlayNotify.post { - binding.flPlayNotify.removeView( - svgaImageView - ) + binding.flPlayNotify.removeView(svgaImageView) + isPlayAnim = false } } } @@ -709,7 +765,10 @@ class RoomEffectView @JvmOverloads constructor( binding.flPlayNotify.addView(textView) textView.startAnimation(animationPlay) binding.flPlayNotify.postDelayed( - { binding.flPlayNotify.removeView(textView) }, + { + binding.flPlayNotify.removeView(textView) + isPlayAnim = false + }, SHOW_TIME.toLong() ) } @@ -745,7 +804,10 @@ class RoomEffectView @JvmOverloads constructor( svgaImageView.layoutParams = params svgaImageView.callback = object : SimpleSvgaCallback() { override fun onFinished() { - binding.flPlayNotify.post { binding.flPlayNotify.removeView(svgaImageView) } + binding.flPlayNotify.post { + binding.flPlayNotify.removeView(svgaImageView) + isPlayAnim = false + } } } binding.flPlayNotify.addView(svgaImageView) @@ -1594,6 +1656,10 @@ class RoomEffectView @JvmOverloads constructor( }, SHOW_TIME.toLong()) } + fun getIsPlayAnim(): Boolean { + return isPlayAnim + } + override fun onDetachedFromWindow() { super.onDetachedFromWindow() boxDisposable?.dispose() @@ -1606,6 +1672,7 @@ class RoomEffectView @JvmOverloads constructor( disposableRoomPK?.dispose() disposableSingleRoomPK?.dispose() disposableGiftCompound?.dispose() + isPlayAnim = false } } \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_chatroom_game_main.xml b/app/src/main/res/layout/fragment_chatroom_game_main.xml index 7ed9672f7..33dcf9a2a 100644 --- a/app/src/main/res/layout/fragment_chatroom_game_main.xml +++ b/app/src/main/res/layout/fragment_chatroom_game_main.xml @@ -228,6 +228,7 @@ tools:visibility="gone" /> diff --git a/gradle.properties b/gradle.properties index 1f51d0191..d654420d9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -29,8 +29,8 @@ COMPILE_SDK_VERSION=32 MIN_SDK_VERSION=21 TARGET_SDK_VERSION=32 -version_name=1.9.0 -version_code=190 +version_name=1.9.2 +version_code=192 #systemProp.https.proxyHost=127.0.0.1 #systemProp.https.proxyPort=9999 \ No newline at end of file