diff --git a/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java b/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java index cf0a289d3..fe3e1a885 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java @@ -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>() { + @Override + public void onSuccess(List 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 data) { + for (LiveUserMailBoxModel model : data) { + if (model.getIsRead() == 0) { + showMsgRed(0); + return; + } + } + showMsgRed(-1); + } + }); + } } diff --git a/live/src/main/java/com/yunbao/live/adapter/LiveUserAnchorMailBoxAdapter.java b/live/src/main/java/com/yunbao/live/adapter/LiveUserAnchorMailBoxAdapter.java index 9503f63fb..825ae16bf 100644 --- a/live/src/main/java/com/yunbao/live/adapter/LiveUserAnchorMailBoxAdapter.java +++ b/live/src/main/java/com/yunbao/live/adapter/LiveUserAnchorMailBoxAdapter.java @@ -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 list; OnItemClickListener onItemClickListener; + DialogInterface.OnDismissListener onWebDismissListener; public LiveUserAnchorMailBoxAdapter(Context mContext) { this.mContext = mContext; @@ -49,6 +51,11 @@ public class LiveUserAnchorMailBoxAdapter extends RecyclerView.Adapter { + if (onWebDismissListener != null) { + onWebDismissListener.onDismiss(dialog); + } + }) + .showDialog(); + if (onItemClickListener != null) { + onItemClickListener.onItemClick(box, 0); + } } } } diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveUserAnchorMailBoxPopDialog.java b/live/src/main/java/com/yunbao/live/dialog/LiveUserAnchorMailBoxPopDialog.java index 1b15d422d..6ef819417 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveUserAnchorMailBoxPopDialog.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveUserAnchorMailBoxPopDialog.java @@ -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,8 +98,8 @@ public class LiveUserAnchorMailBoxPopDialog extends AbsDialogPopupWindow { protected void onDismiss() { super.onDismiss(); for (LiveUserMailBoxModel model : adapter.getList()) { - if(model.getIsRead()==0){ - return; + if (model.getIsRead() == 0) { + return; } } Bus.get().post(new LiveAudienceEvent() diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveUserAnchorMailBoxWebInfoPopDialog.java b/live/src/main/java/com/yunbao/live/dialog/LiveUserAnchorMailBoxWebInfoPopDialog.java index 807d50fa5..4543e2f9b 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveUserAnchorMailBoxWebInfoPopDialog.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveUserAnchorMailBoxWebInfoPopDialog.java @@ -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; @@ -58,7 +64,7 @@ public class LiveUserAnchorMailBoxWebInfoPopDialog extends AbsDialogPopupWindow textView = findViewById(R.id.title); textView.setText(String.format(WordUtil.getString(R.string.live_user_mailbox_web_title), anchorName)); mWebView.addJavascriptInterface(JavascriptInterfaceUtils.getInstance() - .setDialogClose(true) + .setDialogClose(true) .setmContext(CommonAppContext.getTopActivity(), mWebView), "androidObject"); mWebView.getSettings().setJavaScriptEnabled(true); mWebView.getSettings().setDomStorageEnabled(true); @@ -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)