修复信息红点显示错误问题

This commit is contained in:
zlzw 2023-04-08 16:11:41 +08:00
parent 9707898af9
commit 90fee86c19
4 changed files with 70 additions and 6 deletions

View File

@ -48,6 +48,7 @@ import com.yunbao.common.bean.LinkMicUserBean;
import com.yunbao.common.bean.LiveBean;
import com.yunbao.common.bean.LiveGiftBean;
import com.yunbao.common.bean.LiveUserGiftBean;
import com.yunbao.common.bean.LiveUserMailBoxModel;
import com.yunbao.common.bean.SlideInfoModel;
import com.yunbao.common.bean.UserBean;
import com.yunbao.common.dialog.EffectsSettingsDialog;
@ -62,6 +63,7 @@ import com.yunbao.common.http.CommonHttpConsts;
import com.yunbao.common.http.CommonHttpUtil;
import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.http.HttpClient;
import com.yunbao.common.http.live.LiveNetManager;
import com.yunbao.common.http.main.MainNetManager;
import com.yunbao.common.interfaces.CommonCallback;
import com.yunbao.common.manager.IMLoginManager;
@ -427,6 +429,7 @@ public class LiveAudienceActivity extends LiveActivity {
bundle.putString(Constants.LIVE_UID, mLiveUid);
bundle.putString(Constants.LIVE_STREAM, mStream);
fragment.setArguments(bundle);
fragment.setOnDismissListener(dialog -> checkMsgRed());
fragment.show(((LiveAudienceActivity) mContext).getSupportFragmentManager(), "LiveGiftDialogFragment");
});
}
@ -443,6 +446,7 @@ public class LiveAudienceActivity extends LiveActivity {
bundle.putString(Constants.LIVE_STREAM, mStream);
bundle.putString(Constants.LIVE_WISH_GIFTID, giftId);
fragment.setArguments(bundle);
fragment.setOnDismissListener(dialog -> checkMsgRed());
fragment.show(((LiveAudienceActivity) mContext).getSupportFragmentManager(), "LiveGiftDialogFragment");
}
@ -462,6 +466,7 @@ public class LiveAudienceActivity extends LiveActivity {
bundle.putString("by", "1");
}
fragment.setArguments(bundle);
fragment.setOnDismissListener(dialog -> checkMsgRed());
fragment.show(((LiveAudienceActivity) mContext).getSupportFragmentManager(), "LiveGiftDialogFragment");
});
@ -986,6 +991,7 @@ public class LiveAudienceActivity extends LiveActivity {
bundle.putString(Constants.LIVE_UID, mLiveUid);
bundle.putString(Constants.LIVE_STREAM, mStream);
liveGiftDialogFragment.setArguments(bundle);
liveGiftDialogFragment.setOnDismissListener(dialog -> checkMsgRed());
liveGiftDialogFragment.show(((LiveAudienceActivity) mContext).getSupportFragmentManager(), "LiveGiftDialogFragment");
break;
case CURRENT_ACTIVITY:
@ -1298,7 +1304,7 @@ public class LiveAudienceActivity extends LiveActivity {
break;
case WISH_LIST_PROGRESS:
if (manager != null) {
manager.wishListProgress(event.getWishListProgress(), event.getUname(),event.getLiveType());
manager.wishListProgress(event.getWishListProgress(), event.getUname(), event.getLiveType());
}
break;
case XYD_COMPLETE:
@ -1467,5 +1473,36 @@ public class LiveAudienceActivity extends LiveActivity {
}
/**
* 检查消息有未读就要显示红点
*/
private void checkMsgRed() {
LiveNetManager.get(mContext)
.getContactMsg(new com.yunbao.common.http.base.HttpCallback<List<LiveUserMailBoxModel>>() {
@Override
public void onSuccess(List<LiveUserMailBoxModel> data) {
Log.i(TAG, "onSuccess: " + data.size());
for (LiveUserMailBoxModel datum : data) {
Log.i(TAG, "for data : " + datum);
}
setData(data);
}
@Override
public void onError(String error) {
Log.e(TAG, "onError: " + error);
setData(new ArrayList<>());
}
void setData(List<LiveUserMailBoxModel> data) {
for (LiveUserMailBoxModel model : data) {
if (model.getIsRead() == 0) {
showMsgRed(0);
return;
}
}
showMsgRed(-1);
}
});
}
}

View File

@ -2,6 +2,7 @@ package com.yunbao.live.adapter;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Build;
import android.util.Log;
import android.view.LayoutInflater;
@ -30,6 +31,7 @@ public class LiveUserAnchorMailBoxAdapter extends RecyclerView.Adapter<LiveUserA
private Context mContext;
private List<LiveUserMailBoxModel> list;
OnItemClickListener<LiveUserMailBoxModel> onItemClickListener;
DialogInterface.OnDismissListener onWebDismissListener;
public LiveUserAnchorMailBoxAdapter(Context mContext) {
this.mContext = mContext;
@ -49,6 +51,11 @@ public class LiveUserAnchorMailBoxAdapter extends RecyclerView.Adapter<LiveUserA
this.onItemClickListener = onItemClickListener;
}
public LiveUserAnchorMailBoxAdapter setOnWebDismissListener(DialogInterface.OnDismissListener onWebDismissListener) {
this.onWebDismissListener = onWebDismissListener;
return this;
}
@NonNull
@Override
public MailBoxViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
@ -129,7 +136,16 @@ public class LiveUserAnchorMailBoxAdapter extends RecyclerView.Adapter<LiveUserA
@Override
public void onClick(View v) {
new LiveUserAnchorMailBoxWebInfoPopDialog(mContext, box.getAnchorName(), box.getUrl()).showDialog();
new LiveUserAnchorMailBoxWebInfoPopDialog(mContext, box.getAnchorName(), box.getUrl())
.setOnDismissListener(dialog -> {
if (onWebDismissListener != null) {
onWebDismissListener.onDismiss(dialog);
}
})
.showDialog();
if (onItemClickListener != null) {
onItemClickListener.onItemClick(box, 0);
}
}
}
}

View File

@ -1,6 +1,7 @@
package com.yunbao.live.dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.util.Log;
import android.view.View;
@ -58,6 +59,7 @@ public class LiveUserAnchorMailBoxPopDialog extends AbsDialogPopupWindow {
list.setVisibility(GONE);
}
});
adapter.setOnWebDismissListener(dialog -> initData());
initData();
}
@ -96,7 +98,7 @@ public class LiveUserAnchorMailBoxPopDialog extends AbsDialogPopupWindow {
protected void onDismiss() {
super.onDismiss();
for (LiveUserMailBoxModel model : adapter.getList()) {
if(model.getIsRead()==0){
if (model.getIsRead() == 0) {
return;
}
}

View File

@ -1,6 +1,7 @@
package com.yunbao.live.dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Build;
import android.webkit.WebSettings;
import android.webkit.WebView;
@ -10,7 +11,6 @@ import android.widget.TextView;
import androidx.annotation.NonNull;
import com.lxj.xpopup.XPopup;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.CommonAppContext;
import com.yunbao.common.dialog.AbsDialogPopupWindow;
import com.yunbao.common.event.JavascriptInterfaceEvent;
@ -29,6 +29,7 @@ public class LiveUserAnchorMailBoxWebInfoPopDialog extends AbsDialogPopupWindow
String anchorName;
String url;
DialogInterface.OnDismissListener dismissListener;
public LiveUserAnchorMailBoxWebInfoPopDialog(@NonNull Context context) {
super(context);
@ -45,6 +46,11 @@ public class LiveUserAnchorMailBoxWebInfoPopDialog extends AbsDialogPopupWindow
}
public LiveUserAnchorMailBoxWebInfoPopDialog setOnDismissListener(DialogInterface.OnDismissListener dismissListener) {
this.dismissListener = dismissListener;
return this;
}
@Override
public int bindLayoutId() {
return R.layout.dialog_live_user_mailbox_web;
@ -92,6 +98,9 @@ public class LiveUserAnchorMailBoxWebInfoPopDialog extends AbsDialogPopupWindow
public void dismiss() {
super.dismiss();
Bus.getOff(this);
if(dismissListener!=null) {
dismissListener.onDismiss(null);
}
}
@Subscribe(threadMode = ThreadMode.MAIN)