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

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.LiveBean;
import com.yunbao.common.bean.LiveGiftBean; import com.yunbao.common.bean.LiveGiftBean;
import com.yunbao.common.bean.LiveUserGiftBean; import com.yunbao.common.bean.LiveUserGiftBean;
import com.yunbao.common.bean.LiveUserMailBoxModel;
import com.yunbao.common.bean.SlideInfoModel; import com.yunbao.common.bean.SlideInfoModel;
import com.yunbao.common.bean.UserBean; import com.yunbao.common.bean.UserBean;
import com.yunbao.common.dialog.EffectsSettingsDialog; 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.CommonHttpUtil;
import com.yunbao.common.http.HttpCallback; import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.http.HttpClient; import com.yunbao.common.http.HttpClient;
import com.yunbao.common.http.live.LiveNetManager;
import com.yunbao.common.http.main.MainNetManager; import com.yunbao.common.http.main.MainNetManager;
import com.yunbao.common.interfaces.CommonCallback; import com.yunbao.common.interfaces.CommonCallback;
import com.yunbao.common.manager.IMLoginManager; 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_UID, mLiveUid);
bundle.putString(Constants.LIVE_STREAM, mStream); bundle.putString(Constants.LIVE_STREAM, mStream);
fragment.setArguments(bundle); fragment.setArguments(bundle);
fragment.setOnDismissListener(dialog -> checkMsgRed());
fragment.show(((LiveAudienceActivity) mContext).getSupportFragmentManager(), "LiveGiftDialogFragment"); 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_STREAM, mStream);
bundle.putString(Constants.LIVE_WISH_GIFTID, giftId); bundle.putString(Constants.LIVE_WISH_GIFTID, giftId);
fragment.setArguments(bundle); fragment.setArguments(bundle);
fragment.setOnDismissListener(dialog -> checkMsgRed());
fragment.show(((LiveAudienceActivity) mContext).getSupportFragmentManager(), "LiveGiftDialogFragment"); fragment.show(((LiveAudienceActivity) mContext).getSupportFragmentManager(), "LiveGiftDialogFragment");
} }
@ -462,6 +466,7 @@ public class LiveAudienceActivity extends LiveActivity {
bundle.putString("by", "1"); bundle.putString("by", "1");
} }
fragment.setArguments(bundle); fragment.setArguments(bundle);
fragment.setOnDismissListener(dialog -> checkMsgRed());
fragment.show(((LiveAudienceActivity) mContext).getSupportFragmentManager(), "LiveGiftDialogFragment"); 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_UID, mLiveUid);
bundle.putString(Constants.LIVE_STREAM, mStream); bundle.putString(Constants.LIVE_STREAM, mStream);
liveGiftDialogFragment.setArguments(bundle); liveGiftDialogFragment.setArguments(bundle);
liveGiftDialogFragment.setOnDismissListener(dialog -> checkMsgRed());
liveGiftDialogFragment.show(((LiveAudienceActivity) mContext).getSupportFragmentManager(), "LiveGiftDialogFragment"); liveGiftDialogFragment.show(((LiveAudienceActivity) mContext).getSupportFragmentManager(), "LiveGiftDialogFragment");
break; break;
case CURRENT_ACTIVITY: case CURRENT_ACTIVITY:
@ -1298,7 +1304,7 @@ public class LiveAudienceActivity extends LiveActivity {
break; break;
case WISH_LIST_PROGRESS: case WISH_LIST_PROGRESS:
if (manager != null) { if (manager != null) {
manager.wishListProgress(event.getWishListProgress(), event.getUname(),event.getLiveType()); manager.wishListProgress(event.getWishListProgress(), event.getUname(), event.getLiveType());
} }
break; break;
case XYD_COMPLETE: 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.app.Dialog;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface;
import android.os.Build; import android.os.Build;
import android.util.Log; import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
@ -30,6 +31,7 @@ public class LiveUserAnchorMailBoxAdapter extends RecyclerView.Adapter<LiveUserA
private Context mContext; private Context mContext;
private List<LiveUserMailBoxModel> list; private List<LiveUserMailBoxModel> list;
OnItemClickListener<LiveUserMailBoxModel> onItemClickListener; OnItemClickListener<LiveUserMailBoxModel> onItemClickListener;
DialogInterface.OnDismissListener onWebDismissListener;
public LiveUserAnchorMailBoxAdapter(Context mContext) { public LiveUserAnchorMailBoxAdapter(Context mContext) {
this.mContext = mContext; this.mContext = mContext;
@ -49,6 +51,11 @@ public class LiveUserAnchorMailBoxAdapter extends RecyclerView.Adapter<LiveUserA
this.onItemClickListener = onItemClickListener; this.onItemClickListener = onItemClickListener;
} }
public LiveUserAnchorMailBoxAdapter setOnWebDismissListener(DialogInterface.OnDismissListener onWebDismissListener) {
this.onWebDismissListener = onWebDismissListener;
return this;
}
@NonNull @NonNull
@Override @Override
public MailBoxViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { public MailBoxViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
@ -129,7 +136,16 @@ public class LiveUserAnchorMailBoxAdapter extends RecyclerView.Adapter<LiveUserA
@Override @Override
public void onClick(View v) { 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; package com.yunbao.live.dialog;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface;
import android.util.Log; import android.util.Log;
import android.view.View; import android.view.View;
@ -58,6 +59,7 @@ public class LiveUserAnchorMailBoxPopDialog extends AbsDialogPopupWindow {
list.setVisibility(GONE); list.setVisibility(GONE);
} }
}); });
adapter.setOnWebDismissListener(dialog -> initData());
initData(); initData();
} }
@ -96,8 +98,8 @@ public class LiveUserAnchorMailBoxPopDialog extends AbsDialogPopupWindow {
protected void onDismiss() { protected void onDismiss() {
super.onDismiss(); super.onDismiss();
for (LiveUserMailBoxModel model : adapter.getList()) { for (LiveUserMailBoxModel model : adapter.getList()) {
if(model.getIsRead()==0){ if (model.getIsRead() == 0) {
return; return;
} }
} }
Bus.get().post(new LiveAudienceEvent() Bus.get().post(new LiveAudienceEvent()

View File

@ -1,6 +1,7 @@
package com.yunbao.live.dialog; package com.yunbao.live.dialog;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface;
import android.os.Build; import android.os.Build;
import android.webkit.WebSettings; import android.webkit.WebSettings;
import android.webkit.WebView; import android.webkit.WebView;
@ -10,7 +11,6 @@ import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import com.lxj.xpopup.XPopup; import com.lxj.xpopup.XPopup;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.CommonAppContext; import com.yunbao.common.CommonAppContext;
import com.yunbao.common.dialog.AbsDialogPopupWindow; import com.yunbao.common.dialog.AbsDialogPopupWindow;
import com.yunbao.common.event.JavascriptInterfaceEvent; import com.yunbao.common.event.JavascriptInterfaceEvent;
@ -29,6 +29,7 @@ public class LiveUserAnchorMailBoxWebInfoPopDialog extends AbsDialogPopupWindow
String anchorName; String anchorName;
String url; String url;
DialogInterface.OnDismissListener dismissListener;
public LiveUserAnchorMailBoxWebInfoPopDialog(@NonNull Context context) { public LiveUserAnchorMailBoxWebInfoPopDialog(@NonNull Context context) {
super(context); super(context);
@ -45,6 +46,11 @@ public class LiveUserAnchorMailBoxWebInfoPopDialog extends AbsDialogPopupWindow
} }
public LiveUserAnchorMailBoxWebInfoPopDialog setOnDismissListener(DialogInterface.OnDismissListener dismissListener) {
this.dismissListener = dismissListener;
return this;
}
@Override @Override
public int bindLayoutId() { public int bindLayoutId() {
return R.layout.dialog_live_user_mailbox_web; return R.layout.dialog_live_user_mailbox_web;
@ -58,7 +64,7 @@ public class LiveUserAnchorMailBoxWebInfoPopDialog extends AbsDialogPopupWindow
textView = findViewById(R.id.title); textView = findViewById(R.id.title);
textView.setText(String.format(WordUtil.getString(R.string.live_user_mailbox_web_title), anchorName)); textView.setText(String.format(WordUtil.getString(R.string.live_user_mailbox_web_title), anchorName));
mWebView.addJavascriptInterface(JavascriptInterfaceUtils.getInstance() mWebView.addJavascriptInterface(JavascriptInterfaceUtils.getInstance()
.setDialogClose(true) .setDialogClose(true)
.setmContext(CommonAppContext.getTopActivity(), mWebView), "androidObject"); .setmContext(CommonAppContext.getTopActivity(), mWebView), "androidObject");
mWebView.getSettings().setJavaScriptEnabled(true); mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setDomStorageEnabled(true); mWebView.getSettings().setDomStorageEnabled(true);
@ -92,6 +98,9 @@ public class LiveUserAnchorMailBoxWebInfoPopDialog extends AbsDialogPopupWindow
public void dismiss() { public void dismiss() {
super.dismiss(); super.dismiss();
Bus.getOff(this); Bus.getOff(this);
if(dismissListener!=null) {
dismissListener.onDismiss(null);
}
} }
@Subscribe(threadMode = ThreadMode.MAIN) @Subscribe(threadMode = ThreadMode.MAIN)