update
This commit is contained in:
parent
b35d5d242e
commit
0c7ae4e4f7
@ -27,6 +27,8 @@ import android.widget.LinearLayout;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
@ -128,6 +130,8 @@ public class LiveGiftPopup extends AbsDialogFragment {
|
||||
private boolean isPk;
|
||||
|
||||
private FragmentTransaction transaction=null;
|
||||
private FragmentManager fragmentManager;
|
||||
private Fragment contentFragment;
|
||||
|
||||
|
||||
@Override
|
||||
@ -239,11 +243,10 @@ public class LiveGiftPopup extends AbsDialogFragment {
|
||||
giftTitleAdapter.uncheck();
|
||||
liveWrap.setAlpha(1.0f);
|
||||
liveWrap.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD);
|
||||
if(transaction==null){
|
||||
transaction=getTransaction();
|
||||
}
|
||||
transaction.replace(R.id.context_layout_gift, LiveParcelFragment.newInstance(mStream, mLiveUid));
|
||||
transaction.commit();
|
||||
contentFragment=LiveParcelFragment.newInstance(mStream, mLiveUid);
|
||||
transaction.replace(R.id.context_layout_gift, contentFragment);
|
||||
transaction.commitAllowingStateLoss();
|
||||
isWrap = true;
|
||||
findViewById(R.id.red_point).setVisibility(View.GONE);
|
||||
}
|
||||
@ -477,12 +480,11 @@ public class LiveGiftPopup extends AbsDialogFragment {
|
||||
List<LiveGiftBean> liveGiftBeans = JSONArray.parseArray(giftJson, LiveGiftBean.class);
|
||||
for (LiveGiftBean model : liveGiftBeans) {
|
||||
if (TextUtils.equals(model.getId() + "", mWishGiftId)) {
|
||||
if(transaction==null){
|
||||
transaction=getTransaction();
|
||||
}
|
||||
transaction.replace(R.id.context_layout_gift, LiveGiftFragment.newInstance(giftJson,
|
||||
contentFragment=LiveGiftFragment.newInstance(giftJson,
|
||||
liveGiftList.getJSONObject(i).getString("name"),
|
||||
mStream, mLiveUid, mWishGiftId));
|
||||
mStream, mLiveUid, mWishGiftId);
|
||||
transaction.replace(R.id.context_layout_gift, contentFragment);
|
||||
transaction.commitAllowingStateLoss();
|
||||
giftTitleAdapter.setTitleIndex(i);
|
||||
break;
|
||||
@ -493,12 +495,11 @@ public class LiveGiftPopup extends AbsDialogFragment {
|
||||
|
||||
JSONObject obj2 = liveGiftList.getJSONObject(0);
|
||||
String giftJson = obj2.getString("giftlist");
|
||||
if(transaction==null){
|
||||
transaction=getTransaction();
|
||||
}
|
||||
transaction.replace(R.id.context_layout_gift, LiveGiftFragment.newInstance(giftJson,
|
||||
contentFragment= LiveGiftFragment.newInstance(giftJson,
|
||||
liveGiftList.getJSONObject(0).getString("name"),
|
||||
mStream, mLiveUid, mWishGiftId));
|
||||
mStream, mLiveUid, mWishGiftId);
|
||||
transaction.replace(R.id.context_layout_gift,contentFragment);
|
||||
transaction.commitAllowingStateLoss();
|
||||
}
|
||||
|
||||
@ -880,17 +881,17 @@ public class LiveGiftPopup extends AbsDialogFragment {
|
||||
*/
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onGiftTitleEvent(GiftTitleEvent event) {
|
||||
|
||||
liveWrap.setAlpha(0.5f);
|
||||
liveWrap.setTypeface(Typeface.SANS_SERIF, Typeface.NORMAL);
|
||||
liveGiftSend.setEnabled(false);
|
||||
giftNumberLayout.setVisibility(View.INVISIBLE);
|
||||
JSONObject obj2 = liveGiftList.getJSONObject(event.getmPosition());
|
||||
String giftJson = obj2.getString("giftlist");
|
||||
if(transaction==null){
|
||||
transaction=getTransaction();
|
||||
}
|
||||
transaction.replace(R.id.context_layout_gift, LiveGiftFragment.newInstance(giftJson, event.getGiftTitle(), mStream, mLiveUid, mWishGiftId));
|
||||
transaction.commit();
|
||||
contentFragment=LiveGiftFragment.newInstance(giftJson, event.getGiftTitle(), mStream, mLiveUid, mWishGiftId);
|
||||
transaction.replace(R.id.context_layout_gift, contentFragment);
|
||||
transaction.commitAllowingStateLoss();
|
||||
isWrap = false;
|
||||
if (giftSendLayout.getVisibility() == View.INVISIBLE) {
|
||||
hideLianBtn();
|
||||
@ -1446,9 +1447,14 @@ public class LiveGiftPopup extends AbsDialogFragment {
|
||||
}
|
||||
}
|
||||
private FragmentTransaction getTransaction(){
|
||||
if(transaction==null){
|
||||
transaction=getChildFragmentManager().beginTransaction();
|
||||
if(contentFragment!=null && transaction!=null){
|
||||
transaction.remove(contentFragment);
|
||||
contentFragment=null;
|
||||
}
|
||||
if(fragmentManager==null){
|
||||
fragmentManager=getChildFragmentManager();
|
||||
}
|
||||
transaction=fragmentManager.beginTransaction();
|
||||
return transaction;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user