From b8264997f4634db7ec1095f5d0e9986b07d2ea9f Mon Sep 17 00:00:00 2001 From: zlzw <583819556@qq.com> Date: Fri, 1 Dec 2023 13:11:08 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=A4=BC=E7=89=A9=E5=BC=B9?= =?UTF-8?q?=E6=A1=86=E9=97=AA=E9=80=80=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/yunbao/live/dialog/LiveGiftPopup.java | 32 +++++++++++++++---- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveGiftPopup.java b/live/src/main/java/com/yunbao/live/dialog/LiveGiftPopup.java index 5c98a21d6..b3e9a331a 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveGiftPopup.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveGiftPopup.java @@ -127,10 +127,15 @@ public class LiveGiftPopup extends AbsDialogFragment { private MarqueeTextView giftDescription, namingName; private boolean isPk; + private FragmentTransaction transaction=null; + @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); + if(transaction==null){ + transaction=getChildFragmentManager().beginTransaction(); + } Bus.getOn(this); initView(); initDate(); @@ -234,7 +239,9 @@ public class LiveGiftPopup extends AbsDialogFragment { giftTitleAdapter.uncheck(); liveWrap.setAlpha(1.0f); liveWrap.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD); - FragmentTransaction transaction = getChildFragmentManager().beginTransaction(); + if(transaction==null){ + transaction=getTransaction(); + } transaction.replace(R.id.context_layout_gift, LiveParcelFragment.newInstance(mStream, mLiveUid)); transaction.commit(); isWrap = true; @@ -470,11 +477,13 @@ public class LiveGiftPopup extends AbsDialogFragment { List liveGiftBeans = JSONArray.parseArray(giftJson, LiveGiftBean.class); for (LiveGiftBean model : liveGiftBeans) { if (TextUtils.equals(model.getId() + "", mWishGiftId)) { - FragmentTransaction transaction = getChildFragmentManager().beginTransaction(); + if(transaction==null){ + transaction=getTransaction(); + } transaction.replace(R.id.context_layout_gift, LiveGiftFragment.newInstance(giftJson, liveGiftList.getJSONObject(i).getString("name"), mStream, mLiveUid, mWishGiftId)); - transaction.commit(); + transaction.commitAllowingStateLoss(); giftTitleAdapter.setTitleIndex(i); break; } @@ -484,11 +493,13 @@ public class LiveGiftPopup extends AbsDialogFragment { JSONObject obj2 = liveGiftList.getJSONObject(0); String giftJson = obj2.getString("giftlist"); - FragmentTransaction transaction = getChildFragmentManager().beginTransaction(); + if(transaction==null){ + transaction=getTransaction(); + } transaction.replace(R.id.context_layout_gift, LiveGiftFragment.newInstance(giftJson, liveGiftList.getJSONObject(0).getString("name"), mStream, mLiveUid, mWishGiftId)); - transaction.commit(); + transaction.commitAllowingStateLoss(); } @@ -875,8 +886,9 @@ public class LiveGiftPopup extends AbsDialogFragment { giftNumberLayout.setVisibility(View.INVISIBLE); JSONObject obj2 = liveGiftList.getJSONObject(event.getmPosition()); String giftJson = obj2.getString("giftlist"); - - FragmentTransaction transaction = getChildFragmentManager().beginTransaction(); + if(transaction==null){ + transaction=getTransaction(); + } transaction.replace(R.id.context_layout_gift, LiveGiftFragment.newInstance(giftJson, event.getGiftTitle(), mStream, mLiveUid, mWishGiftId)); transaction.commit(); isWrap = false; @@ -1433,6 +1445,12 @@ public class LiveGiftPopup extends AbsDialogFragment { } } } + private FragmentTransaction getTransaction(){ + if(transaction==null){ + transaction=getChildFragmentManager().beginTransaction(); + } + return transaction; + } private void updateOverlayVisibility() { /* if (