From fced114686ad3f372f0b3c2674e41db6449c4395 Mon Sep 17 00:00:00 2001 From: Max Date: Mon, 18 Mar 2024 14:05:29 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E7=A7=BB=E9=99=A4AVRoomActivity=E4=B8=AD?= =?UTF-8?q?=E7=9A=84=E5=85=A8=E6=9C=8D=E7=A4=BC=E7=89=A9=E9=A3=98=E5=B1=8F?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E5=88=B0BaseActivity?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/avroom/activity/AVRoomActivity.java | 76 ---------- .../com/nnbc123/app/base/BaseActivity.java | 59 +++++++- .../AllServiceGiftLevelCeremonyDialog.java | 77 ----------- .../dialog_gift_all_service_ceremony.xml | 130 ------------------ gradle.properties | 4 +- 5 files changed, 56 insertions(+), 290 deletions(-) delete mode 100644 app/src/main/java/com/nnbc123/app/ui/widget/dialog/AllServiceGiftLevelCeremonyDialog.java delete mode 100644 app/src/main/res/layout/dialog_gift_all_service_ceremony.xml diff --git a/app/src/main/java/com/nnbc123/app/avroom/activity/AVRoomActivity.java b/app/src/main/java/com/nnbc123/app/avroom/activity/AVRoomActivity.java index fd5e17d8d..e1588e8e3 100644 --- a/app/src/main/java/com/nnbc123/app/avroom/activity/AVRoomActivity.java +++ b/app/src/main/java/com/nnbc123/app/avroom/activity/AVRoomActivity.java @@ -2,15 +2,12 @@ package com.nnbc123.app.avroom.activity; import static android.view.View.VISIBLE; -import static com.nnbc123.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_ALL_SERVICE_GIFT; -import static com.nnbc123.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_HEADER_TYPE_GIFT; import static com.nnbc123.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_LUCKY_GIFT; import static com.nnbc123.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_LUCKY_GIFT_SERVER_NOTIFY; import static com.nnbc123.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_ROOM_PK; import static com.nnbc123.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_ROOM_PK_NOTIFY; import android.annotation.SuppressLint; -import android.app.Dialog; import android.content.Context; import android.content.Intent; import android.graphics.drawable.Drawable; @@ -65,7 +62,6 @@ import com.nnbc123.app.ui.user.UserInfoActivity; import com.nnbc123.app.ui.utils.ImageLoadUtils; import com.nnbc123.app.ui.webview.CommonWebViewActivity; import com.nnbc123.app.ui.widget.NobleOpenNoticeView; -import com.nnbc123.app.ui.widget.dialog.AllServiceGiftLevelDialog; import com.nnbc123.app.ui.widget.dialog.MonsterDialog; import com.nnbc123.app.ui.widget.marqueeview.Utils; import com.nnbc123.app.utils.UserUtils; @@ -89,7 +85,6 @@ import com.nnbc123.core.monsterhunting.bean.MonsterHuntingResult; import com.nnbc123.core.monsterhunting.bean.MonsterInfo; import com.nnbc123.core.monsterhunting.bean.MonsterProtocol; import com.nnbc123.core.monsterhunting.manager.MonsterDataManager; -import com.nnbc123.core.noble.AllServiceGiftProtocol; import com.nnbc123.core.noble.NobleInfo; import com.nnbc123.core.noble.NobleResourceType; import com.nnbc123.core.noble.NobleUtil; @@ -116,7 +111,6 @@ import com.nnbc123.core.utils.LogUtils; import com.nnbc123.core.utils.StringUtils; import com.nnbc123.library.base.factory.CreatePresenter; import com.nnbc123.library.rxbus.RxBus; -import com.nnbc123.library.utils.JavaUtil; import com.nnbc123.library.utils.SingleToastUtil; import com.nnbc123.library.utils.UIUtils; import com.opensource.svgaplayer.SVGADrawable; @@ -134,7 +128,6 @@ import java.lang.ref.WeakReference; import java.net.MalformedURLException; import java.net.URL; import java.util.ArrayList; -import java.util.LinkedList; import java.util.List; import java.util.Map; @@ -194,8 +187,6 @@ public class AVRoomActivity extends BaseMvpActivity giftList; private boolean isResume = true; @Nullable private SingleRoomTipDialog singleRoomTipDialog; @@ -498,9 +489,6 @@ public class AVRoomActivity extends BaseMvpActivity(); - } - int second2 = baseProtocol.getSecond(); - AllServiceGiftProtocol.DataBean data = JSON.parseObject(String.valueOf(baseProtocol.getData()), AllServiceGiftProtocol.DataBean.class); - if (data == null || data.getGiftUrl() == null || data.isCeremonyGift()) - return; - giftList.add(data); - if (second2 == CUSTOM_MSG_ALL_SERVICE_GIFT) { - if (giftDialog != null && giftDialog.isShowing()) { - // 如果当前以及有礼物弹窗在展示,则需要等到他 dismiss 后再显示下一个 - AllServiceGiftProtocol.DataBean dataBean = giftList.peekFirst(); - if (dataBean != null) { - return; - } else { - giftDialog.dismiss(); - } - } else { - showGiftDialog(); - } - } - break; case CUSTOM_MSG_LUCKY_GIFT: if (baseProtocol.getSecond() == CUSTOM_MSG_LUCKY_GIFT_SERVER_NOTIFY) { RoomReceivedLuckyGiftAttachment attachment = new RoomReceivedLuckyGiftAttachment(CUSTOM_MSG_LUCKY_GIFT_SERVER_NOTIFY); @@ -1233,40 +1191,6 @@ public class AVRoomActivity extends BaseMvpActivity { - giftList.pollFirst(); - AllServiceGiftProtocol.DataBean dataBean = giftList.peekFirst(); - if (dataBean != null) { - if (isValid()) { - showGiftDialog(); - } else { - giftList.clear(); - } - } - }); - giftDialog.show(); - } - - private AllServiceGiftLevelDialog generateAllServiceGiftDialog(Context context, AllServiceGiftProtocol.DataBean dataBean) { - return new AllServiceGiftLevelDialog(context, dataBean); -// switch (JavaUtil.str2int(dataBean.getLevelNum())) { -// default: -// case AllServiceGiftDialog.ALL_SERVICE_GIFT_LEVEL_1: -// return new AllServiceGiftLevelOneDialog(context, dataBean); -// -// case AllServiceGiftDialog.ALL_SERVICE_GIFT_LEVEL_2: -// -// return new AllServiceGiftLevelTwoDialog(context, dataBean); -// -// case AllServiceGiftDialog.ALL_SERVICE_GIFT_LEVEL_3: -// return new AllServiceGiftLevelThreeDialog(context, dataBean); -// } - } - - @Override protected void onPause() { super.onPause(); diff --git a/app/src/main/java/com/nnbc123/app/base/BaseActivity.java b/app/src/main/java/com/nnbc123/app/base/BaseActivity.java index f9767b42f..a98596667 100644 --- a/app/src/main/java/com/nnbc123/app/base/BaseActivity.java +++ b/app/src/main/java/com/nnbc123/app/base/BaseActivity.java @@ -4,6 +4,7 @@ import static com.nnbc123.core.Constants.DEBUG_MAX_UID; import static com.nnbc123.core.im.custom.bean.CustomAttachment.CUSTOM_MESS_HEAD_NOBLE; import static com.nnbc123.core.im.custom.bean.CustomAttachment.CUSTOM_MESS_SUB_OPENNOBLE; import static com.nnbc123.core.im.custom.bean.CustomAttachment.CUSTOM_MESS_SUB_RENEWNOBLE; +import static com.nnbc123.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_ALL_SERVICE_GIFT; import static com.nnbc123.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_HEADER_TYPE_GIFT; import static com.nnbc123.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_RED_PACKAGE; import static com.nnbc123.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_RED_PACKAGE_RECEIVE_ALL_DIAMOND; @@ -13,6 +14,7 @@ import static com.nnbc123.library.utils.UIUtils.getActivityByContext; import android.annotation.SuppressLint; import android.app.ActivityManager; +import android.app.Dialog; import android.content.ComponentName; import android.content.Context; import android.content.Intent; @@ -69,7 +71,7 @@ import com.nnbc123.app.ui.login.LoginPhoneActivity; import com.nnbc123.app.ui.pay.ChargeActivity; import com.nnbc123.app.ui.setting.ResetPasswordActivity; import com.nnbc123.app.ui.widget.DefaultToolBar; -import com.nnbc123.app.ui.widget.dialog.AllServiceGiftLevelCeremonyDialog; +import com.nnbc123.app.ui.widget.dialog.AllServiceGiftLevelDialog; import com.nnbc123.app.ui.widget.dialog.AllServiceVipLevelUPDialog; import com.nnbc123.app.ui.widget.dialog.GameInviteDialog; import com.nnbc123.app.ui.widget.dialog.OpenNobleGlobalNoticeDialog; @@ -114,6 +116,7 @@ import java.lang.ref.WeakReference; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.util.ArrayList; +import java.util.LinkedList; import java.util.List; import io.reactivex.Observable; @@ -145,6 +148,8 @@ public abstract class BaseActivity extends RxAppCompatActivity private OpenNobleGlobalNoticeDialog mNoticeDialog; private boolean isShowingChargeDialog; + private Dialog giftDialog; + private LinkedList giftList; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -340,7 +345,14 @@ public abstract class BaseActivity extends RxAppCompatActivity mNoticeDialog.dismiss(); mNoticeDialog = null; } - + if (giftDialog != null && giftDialog.isShowing()) { + giftDialog.setOnDismissListener(null); + giftDialog.dismiss(); + giftDialog = null; + } + if (giftList != null) { + giftList.clear(); + } super.onDestroy(); LogUtil.i(this.getClass().getName(), "onDestroy"); /* ImageLoadUtils.clearMemory(this);*/ @@ -508,7 +520,6 @@ public abstract class BaseActivity extends RxAppCompatActivity .compose(bindUntilEvent(ActivityEvent.PAUSE)) .observeOn(AndroidSchedulers.mainThread()) .subscribe(this::onRoomEventReceived); - } @Override @@ -930,15 +941,53 @@ public abstract class BaseActivity extends RxAppCompatActivity UserUtils.getUserInfo() == null) return; AllServiceGiftProtocol.DataBean data = JSON.parseObject(String.valueOf(baseProtocol.getData()), AllServiceGiftProtocol.DataBean.class); - if (data == null || data.getGiftUrl() == null || !data.isCeremonyGift()) + if (data == null || data.getGiftUrl() == null) return; - new AllServiceGiftLevelCeremonyDialog(context, data).show(); + if (giftList == null) { + giftList = new LinkedList<>(); + } + int second2 = baseProtocol.getSecond(); + if (second2 == CUSTOM_MSG_ALL_SERVICE_GIFT) { + giftList.add(data); + if (giftDialog != null && giftDialog.isShowing()) { + // 如果当前以及有礼物弹窗在展示,则需要等到他 dismiss 后再显示下一个 + AllServiceGiftProtocol.DataBean dataBean = giftList.peekFirst(); + if (dataBean != null) { + return; + } else { + giftDialog.dismiss(); + } + } else { + showGiftDialog(); + } + } break; default: break; } } + private void showGiftDialog() { + if (giftList.size() == 0) return; + giftDialog = generateAllServiceGiftDialog(this, giftList.peekFirst()); + giftDialog.setOnDismissListener(dialog -> { + giftList.pollFirst(); + AllServiceGiftProtocol.DataBean dataBean = giftList.peekFirst(); + if (dataBean != null) { + if (isValid()) { + showGiftDialog(); + } else { + giftList.clear(); + } + } + }); + giftDialog.show(); + } + + private AllServiceGiftLevelDialog generateAllServiceGiftDialog(Context context, AllServiceGiftProtocol.DataBean dataBean) { + return new AllServiceGiftLevelDialog(context, dataBean); + } + public void onGrabApprenticesEvent(GrabApprenticesEvent event) { if (!isTopActivity()) return; if (dialog != null && dialog.isAdded()) { diff --git a/app/src/main/java/com/nnbc123/app/ui/widget/dialog/AllServiceGiftLevelCeremonyDialog.java b/app/src/main/java/com/nnbc123/app/ui/widget/dialog/AllServiceGiftLevelCeremonyDialog.java deleted file mode 100644 index c83148169..000000000 --- a/app/src/main/java/com/nnbc123/app/ui/widget/dialog/AllServiceGiftLevelCeremonyDialog.java +++ /dev/null @@ -1,77 +0,0 @@ -package com.nnbc123.app.ui.widget.dialog; - -import android.content.Context; -import android.graphics.Color; -import android.graphics.Point; -import android.graphics.drawable.ColorDrawable; -import android.os.Bundle; -import android.view.Gravity; -import android.view.LayoutInflater; -import android.view.View; -import android.view.Window; -import android.view.WindowManager; - -import androidx.databinding.DataBindingUtil; - - -import com.nnbc123.core.manager.AvRoomDataManager; -import com.nnbc123.core.noble.AllServiceGiftProtocol; -import com.nnbc123.app.R; -import com.nnbc123.app.avroom.activity.AVRoomActivity; -import com.nnbc123.app.databinding.DialogGiftAllServiceCeremonyBinding; - -import java.util.concurrent.TimeUnit; - -import io.reactivex.Observable; - -/** - * Created by MadisonRong on 11/05/2018. - */ - -public class AllServiceGiftLevelCeremonyDialog extends AllServiceGiftDialog { - - private DialogGiftAllServiceCeremonyBinding binding; - - public AllServiceGiftLevelCeremonyDialog(Context context, AllServiceGiftProtocol.DataBean dataBean) { - super(context, R.style.FullScreenDialog, dataBean); - } - - @Override - protected void onCreate(Bundle savedInstanceState) { - requestWindowFeature(Window.FEATURE_NO_TITLE); - View inflate = LayoutInflater.from(getContext()).inflate(R.layout.dialog_gift_all_service_ceremony, null); - setContentView(inflate.getRootView()); - setCancelable(true); - setCanceledOnTouchOutside(true); - binding = DataBindingUtil.bind(inflate); - - Window window = getWindow(); - Point point = new Point(); - if (window != null) { - window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); - WindowManager.LayoutParams windowParams = window.getAttributes(); - windowParams.width = WindowManager.LayoutParams.MATCH_PARENT; - windowParams.height = WindowManager.LayoutParams.WRAP_CONTENT; - windowParams.dimAmount = 0.0f; - windowParams.gravity = Gravity.TOP; - windowParams.x = 0; - windowParams.y = 0; - window.addFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL); - window.setAttributes(windowParams); - window.setWindowAnimations(R.style.anim_fade); - window.getWindowManager().getDefaultDisplay().getSize(point); - } - if (dataBean != null) { - // 设置定时器 - Observable.timer((long) dataBean.getNotifyStaySecond(), TimeUnit.SECONDS) - .subscribe(aLong -> { - dismiss(); - }); - binding.setGiftBean(dataBean); - binding.tvGoRoom.setVisibility(dataBean.getRoomUid() == 0 - || (AvRoomDataManager.get().mCurrentRoomInfo != null && dataBean.getRoomUid() == AvRoomDataManager.get().mCurrentRoomInfo.getUid()) - ? View.GONE : View.VISIBLE); - binding.tvGoRoom.setOnClickListener(view -> AVRoomActivity.start(getContext(), dataBean.getRoomUid())); - } - } -} diff --git a/app/src/main/res/layout/dialog_gift_all_service_ceremony.xml b/app/src/main/res/layout/dialog_gift_all_service_ceremony.xml deleted file mode 100644 index baf710ff6..000000000 --- a/app/src/main/res/layout/dialog_gift_all_service_ceremony.xml +++ /dev/null @@ -1,130 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 2ed5532ba..00cbb0a41 100644 --- a/gradle.properties +++ b/gradle.properties @@ -28,5 +28,5 @@ COMPILE_SDK_VERSION=32 MIN_SDK_VERSION=21 TARGET_SDK_VERSION=32 -version_name=2.0.0 -version_code=2000 \ No newline at end of file +version_name=2.1.1 +version_code=2101 \ No newline at end of file