|
@@ -67,11 +67,15 @@ import com.hncx.xxm.room.widget.dialog.UserInfoDialog;
|
|
|
import com.hncx.xxm.utils.HNCXImageLoadUtils;
|
|
|
import com.netease.nim.uikit.common.util.sys.ScreenUtil;
|
|
|
import com.netease.nimlib.sdk.msg.model.RecentContact;
|
|
|
+import com.shanp.youqi.base.rx.EventSubscriber;
|
|
|
+import com.shanp.youqi.base.rx.RxBus;
|
|
|
import com.shanp.youqi.base.util.GsonUtil;
|
|
|
import com.shanp.youqi.common.anim.ObjectAnimatorAssist;
|
|
|
import com.shanp.youqi.common.app.Route.ARouterFun;
|
|
|
import com.shanp.youqi.common.base.BaseDialogFragment;
|
|
|
import com.shanp.youqi.core.config.C;
|
|
|
+import com.shanp.youqi.core.event.IMReceivedMessageEvent;
|
|
|
+import com.shanp.youqi.core.memory.AppManager;
|
|
|
import com.shanp.youqi.core.utils.SP;
|
|
|
import com.shanp.youqi.room.activity.RoomRankActivity;
|
|
|
import com.shanp.youqi.room.config.AccompanyConstants;
|
|
@@ -152,6 +156,8 @@ import io.reactivex.android.schedulers.AndroidSchedulers;
|
|
|
import io.reactivex.disposables.Disposable;
|
|
|
import io.reactivex.functions.Consumer;
|
|
|
import io.reactivex.schedulers.Schedulers;
|
|
|
+import io.rong.imlib.RongIMClient;
|
|
|
+import io.rong.imlib.model.Conversation;
|
|
|
|
|
|
import static com.tongdaxing.xchat_core.im.custom.bean.IMCustomAttachment.CUSTOM_MSG_HEADER_TYPE_REMOVE_MSG_FILTER_CLOSE;
|
|
|
import static com.tongdaxing.xchat_core.im.custom.bean.IMCustomAttachment.CUSTOM_MSG_HEADER_TYPE_REMOVE_MSG_FILTER_OPEN;
|
|
@@ -202,6 +208,7 @@ public class HNCXHomePartyRoomFragment extends HNCXBaseMvpFragment<IHomePartyVie
|
|
|
private AnimatorSet animatorSet;
|
|
|
|
|
|
private boolean messageListDialogIsShowing = false;
|
|
|
+ private EventSubscriber<IMReceivedMessageEvent> messageEventEventSubscriber;
|
|
|
|
|
|
@Override
|
|
|
public int getRootLayoutId() {
|
|
@@ -270,6 +277,9 @@ public class HNCXHomePartyRoomFragment extends HNCXBaseMvpFragment<IHomePartyVie
|
|
|
}
|
|
|
}
|
|
|
setFloatEnterRoomRefreshHomeownerCharmApi();
|
|
|
+ if (AppManager.get().isConnectRongCloud()) {
|
|
|
+ refreshUnreadMessage();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// todo 魅力值。下个版本回滚,此接口不需要调用
|
|
@@ -1225,6 +1235,45 @@ public class HNCXHomePartyRoomFragment extends HNCXBaseMvpFragment<IHomePartyVie
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取未读数
|
|
|
+ */
|
|
|
+ public void refreshUnreadMessage() {
|
|
|
+ disposeMsg();
|
|
|
+ messageEventEventSubscriber = new EventSubscriber<IMReceivedMessageEvent>() {
|
|
|
+ @Override
|
|
|
+ public void onReceive(IMReceivedMessageEvent imReceivedMessageEvent) {
|
|
|
+ super.onReceive(imReceivedMessageEvent);
|
|
|
+ getUnreadCount();
|
|
|
+ }
|
|
|
+ };
|
|
|
+ RxBus.get().toFlowable(IMReceivedMessageEvent.class).subscribe(messageEventEventSubscriber);
|
|
|
+ getUnreadCount();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void getUnreadCount() {
|
|
|
+ if (!AppManager.get().isConnectRongCloud()) return;
|
|
|
+ RongIMClient.getInstance().getUnreadCount(new RongIMClient.ResultCallback<Integer>() {
|
|
|
+ @Override
|
|
|
+ public void onSuccess(Integer count) {
|
|
|
+ if (count != null) {
|
|
|
+ gameBinding.bottomView.showMsgCount(count);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onError(RongIMClient.ErrorCode errorCode) {
|
|
|
+ }
|
|
|
+ }, Conversation.ConversationType.PRIVATE);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void disposeMsg() {
|
|
|
+ if (messageEventEventSubscriber != null) {
|
|
|
+ messageEventEventSubscriber.dispose();
|
|
|
+ messageEventEventSubscriber = null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//------------------------------IShareCoreClient----------------------------------
|
|
|
@CoreEvent(coreClientClass = IShareCoreClient.class)
|
|
|
public void onShareRoom() {
|
|
@@ -1243,6 +1292,7 @@ public class HNCXHomePartyRoomFragment extends HNCXBaseMvpFragment<IHomePartyVie
|
|
|
|
|
|
@Override
|
|
|
public void onDestroyView() {
|
|
|
+ disposeMsg();
|
|
|
super.onDestroyView();
|
|
|
releaseView();
|
|
|
isShowing = false;
|
|
@@ -2182,6 +2232,7 @@ public class HNCXHomePartyRoomFragment extends HNCXBaseMvpFragment<IHomePartyVie
|
|
|
@Override
|
|
|
public void onHidden() {
|
|
|
messageListDialogIsShowing = false;
|
|
|
+ getUnreadCount();
|
|
|
}
|
|
|
}).show(getChildFragmentManager());
|
|
|
// ARouterFun.startIMMain();
|