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 (