修复礼物弹框闪退问题

This commit is contained in:
zlzw 2023-12-01 13:11:08 +08:00
parent 9dba41c22f
commit b8264997f4

View File

@ -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<LiveGiftBean> 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 (