MM 新增世界聊天
This commit is contained in:
@@ -38,7 +38,10 @@ import com.dskj.rbchat.utils.GsonUtils;
|
||||
import com.dskj.rbchat.utils.LogUtils;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.netease.nimlib.sdk.NIMClient;
|
||||
import com.netease.nimlib.sdk.RequestCallback;
|
||||
import com.netease.nimlib.sdk.msg.MsgService;
|
||||
import com.netease.nimlib.sdk.team.TeamService;
|
||||
import com.netease.nimlib.sdk.team.model.Team;
|
||||
import com.netease.yunxin.kit.alog.ALog;
|
||||
import com.netease.yunxin.kit.chatkit.model.ConversationInfo;
|
||||
import com.netease.yunxin.kit.chatkit.repo.ContactRepo;
|
||||
@@ -53,7 +56,11 @@ import com.netease.yunxin.kit.corekit.event.EventNotify;
|
||||
import com.netease.yunxin.kit.corekit.im.IMKitClient;
|
||||
import com.netease.yunxin.kit.corekit.im.provider.FetchCallback;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
@@ -151,6 +158,7 @@ public class ChatTabFragment extends BaseFragment {
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
getServicesData();
|
||||
getGroupIdsData();
|
||||
initView();
|
||||
// NetworkUtils.registerNetworkStatusChangedListener(networkStateListener);
|
||||
EventCenter.registerEventNotify(editConversation);
|
||||
@@ -172,6 +180,7 @@ public class ChatTabFragment extends BaseFragment {
|
||||
}
|
||||
|
||||
BindBean bindBean;
|
||||
|
||||
private void bindInfo() {
|
||||
Api.getInstance().bindInfo(IMKitClient.account())
|
||||
.subscribeOn(Schedulers.io())
|
||||
@@ -224,6 +233,9 @@ public class ChatTabFragment extends BaseFragment {
|
||||
|
||||
int verifyCount = 0;
|
||||
int notifyCount = 0;
|
||||
public ArrayList<String> groupIds = new ArrayList<>(); //官方群聊
|
||||
public List<Team> teamInfos = new ArrayList<>();
|
||||
|
||||
private void getNotifiesCount() {
|
||||
notifyCount = 0;
|
||||
String time = DataUtils.getCurrentTimeType(DataUtils.get(getActivity(), "notify_message_time_" + IMKitClient.account(), IMUIKitConfig.NOTIFY_MESSAGE_START_TIME));
|
||||
@@ -237,6 +249,25 @@ public class ChatTabFragment extends BaseFragment {
|
||||
int count = feedbackResp.data.getSystemMsgCount();
|
||||
int activityMsgCount = feedbackResp.data.getActivityMsgCount();
|
||||
int msgcount = DataUtils.get(getActivity(), "activity_message_count", 0);
|
||||
if (groupIds.size() == 0) {
|
||||
String groupId = feedbackResp.data.getGroupId();
|
||||
if (!TextUtils.isEmpty(groupId)) {
|
||||
try {
|
||||
JSONArray array = new JSONArray(groupId);
|
||||
if (array.length() > 0) {
|
||||
String values = array.getString(0);
|
||||
if (!TextUtils.isEmpty(values)) {
|
||||
String[] groupIdStr = values.split(",");
|
||||
groupIds.clear();
|
||||
groupIds.addAll(Arrays.asList(groupIdStr));
|
||||
queryTeamInfo();
|
||||
}
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (activityMsgCount > msgcount) {
|
||||
DataUtils.set(getActivity(), "activity_message_count", activityMsgCount);
|
||||
}
|
||||
@@ -254,6 +285,28 @@ public class ChatTabFragment extends BaseFragment {
|
||||
});
|
||||
}
|
||||
|
||||
private void queryTeamInfo() {
|
||||
for (String groupId : groupIds) {
|
||||
NIMClient.getService(TeamService.class).searchTeam(groupId).setCallback(new RequestCallback<Team>() {
|
||||
@Override
|
||||
public void onSuccess(Team result) {
|
||||
teamInfos.add(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailed(int code) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onException(Throwable exception) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void getServicesData() {
|
||||
String tagString = DataUtils.get(IMApplication.getAppContext(), IMUIKitConfig.SERVICES_IDS_TAG + "_" + IMKitClient.account(), "");
|
||||
if (!TextUtils.isEmpty(tagString)) {
|
||||
@@ -263,6 +316,27 @@ public class ChatTabFragment extends BaseFragment {
|
||||
}
|
||||
}
|
||||
|
||||
private void getGroupIdsData() {
|
||||
String tagString = DataUtils.get(IMApplication.getAppContext(), IMUIKitConfig.SHIJIECHAT_IDS_TAG, "");
|
||||
if (!TextUtils.isEmpty(tagString)) {
|
||||
try {
|
||||
JSONArray array = new JSONArray(tagString);
|
||||
if (array.length() > 0) {
|
||||
String values = array.getString(0);
|
||||
if (!TextUtils.isEmpty(values)) {
|
||||
String[] groupIdStr = values.split(",");
|
||||
groupIds.clear();
|
||||
groupIds.addAll(Arrays.asList(groupIdStr));
|
||||
queryTeamInfo();
|
||||
}
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public Comparator<ConversationInfo> conversationComparator =
|
||||
(bean1, bean2) -> {
|
||||
@@ -304,7 +378,7 @@ public class ChatTabFragment extends BaseFragment {
|
||||
viewBinding.layoutChatfmFollow.setOnClickListener(this::chatClick);
|
||||
|
||||
viewBinding.viewSettingclick.setOnClickListener(view -> {
|
||||
startActivity(new Intent(getActivity(), EditChatRecordlistActivity.class));
|
||||
startActivity(new Intent(getActivity(), EditChatRecordlistActivity.class).putExtra("groupIds", groupIds));
|
||||
});
|
||||
viewBinding.viewAddclick.setOnClickListener(view -> {
|
||||
startCreateGroup();
|
||||
|
||||
@@ -38,6 +38,7 @@ import com.dskj.rbchat.login.LoginActivity;
|
||||
import com.dskj.rbchat.login.PhoneLoginActivity;
|
||||
import com.dskj.rbchat.login.RegisterActivity;
|
||||
import com.dskj.rbchat.model.LoginBean;
|
||||
import com.dskj.rbchat.model.NotifyCountBean;
|
||||
import com.dskj.rbchat.network.Api;
|
||||
import com.dskj.rbchat.network.BaseObserver;
|
||||
import com.dskj.rbchat.network.Result;
|
||||
@@ -61,6 +62,11 @@ import com.netease.yunxin.kit.common.ui.utils.ToastX;
|
||||
import com.netease.yunxin.kit.corekit.im.IMKitClient;
|
||||
import com.netease.yunxin.kit.corekit.im.login.LoginCallback;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -100,6 +106,7 @@ public class WelcomeActivity extends BaseActivity {
|
||||
getScheme(uri);
|
||||
// initClip();
|
||||
//activityWelcomeBinding.bigBg.setBackgroundResource(R.color.color_white);
|
||||
getNotifiesCount();
|
||||
if (TextUtils.isEmpty(NIMClient.getCurrentAccount())) {
|
||||
startLogin();
|
||||
} else {
|
||||
@@ -134,6 +141,31 @@ public class WelcomeActivity extends BaseActivity {
|
||||
|
||||
}
|
||||
|
||||
private void getNotifiesCount(){
|
||||
Api.getInstance().notifiesmessageCountNew(IMKitClient.account(), DataUtils.getCurrentTimeType(System.currentTimeMillis()))
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new BaseObserver<>() {
|
||||
@Override
|
||||
public void onSuccess(Result<NotifyCountBean> feedbackResp) {
|
||||
LogUtils.i("获取到的错误:" + feedbackResp + "" + feedbackResp.data);
|
||||
|
||||
String groupId = feedbackResp.data.getGroupId();
|
||||
if (!TextUtils.isEmpty(groupId)) {
|
||||
DataUtils.set(WelcomeActivity.this, IMUIKitConfig.SHIJIECHAT_IDS_TAG, groupId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onError(int code, String msg) {
|
||||
LogUtils.i("获取到的错误:" + code + "" + msg);
|
||||
// WidgetUtils.showToast(getActivity(), msg, WidgetUtils.ToastType.ERROR);
|
||||
LogUtils.i("获取到的错误:" + code + "" + msg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void showIsLogin(boolean isLogin) {
|
||||
|
||||
//加载动画
|
||||
@@ -328,6 +360,7 @@ public class WelcomeActivity extends BaseActivity {
|
||||
loginBean.setIsBiz(feedbackResp.data.getUser().getIsBiz());
|
||||
loginBean.setCashFeeRate(feedbackResp.data.getCashFeeRate());
|
||||
loginBean.setSilverFeeRate(feedbackResp.data.getSilverFeeRate());
|
||||
loginBean.setMmSilverFeeRate(feedbackResp.data.getMmSilverFeeRate());
|
||||
DataUtils.set(WelcomeActivity.this, "login_bean", GsonUtils.beanToJSONString(loginBean));
|
||||
new Handler().postDelayed(() -> loginIM(account, token), 3000);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user