Commit 75ab9224 by 王文龙

[fix]修复搜索去重,优化IM通道失败提示

parent 768ffddc
...@@ -12,7 +12,7 @@ android { ...@@ -12,7 +12,7 @@ android {
compileSdkVersion 29 compileSdkVersion 29
defaultConfig { defaultConfig {
applicationId "com.offcn.imclient" applicationId "com.offcn.imteacher"
minSdkVersion 19 minSdkVersion 19
targetSdkVersion 29 targetSdkVersion 29
versionCode 1 versionCode 1
...@@ -94,7 +94,7 @@ dependencies { ...@@ -94,7 +94,7 @@ dependencies {
implementation 'com.android.support:multidex:1.0.3' implementation 'com.android.support:multidex:1.0.3'
implementation("com.offcn.live:titleview:1.1.0-s1") implementation("com.offcn.live:titleview:1.1.0-s1")
implementation("com.offcn.live:imsdk-kit:1.0.0.24") implementation("com.offcn.live:imsdk-kit:1.0.0.28")
// DB // DB
implementation 'org.greenrobot:greendao:3.2.2' implementation 'org.greenrobot:greendao:3.2.2'
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
<category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.DEFAULT" />
<data <data
android:host="com.offcn.imclient" android:host="com.offcn.imteacher"
android:pathPrefix="/chatlist" android:pathPrefix="/chatlist"
android:scheme="offcn" /> android:scheme="offcn" />
</intent-filter> </intent-filter>
...@@ -64,7 +64,7 @@ ...@@ -64,7 +64,7 @@
<category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.DEFAULT" />
<data <data
android:host="com.offcn.imclient" android:host="com.offcn.imteacher"
android:pathPrefix="/chat/" android:pathPrefix="/chat/"
android:scheme="offcn" /> android:scheme="offcn" />
</intent-filter> </intent-filter>
......
...@@ -5,6 +5,8 @@ import org.greenrobot.greendao.annotation.Entity; ...@@ -5,6 +5,8 @@ import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Id; import org.greenrobot.greendao.annotation.Id;
import java.io.Serializable; import java.io.Serializable;
import java.util.Objects;
import org.greenrobot.greendao.annotation.Generated; import org.greenrobot.greendao.annotation.Generated;
@Entity @Entity
...@@ -157,4 +159,17 @@ public class UserBean implements Serializable { ...@@ -157,4 +159,17 @@ public class UserBean implements Serializable {
", group_name='" + group_name + '\'' + ", group_name='" + group_name + '\'' +
'}'; '}';
} }
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
UserBean userBean = (UserBean) o;
return user_id.equals(userBean.user_id);
}
@Override
public int hashCode() {
return Objects.hash(user_id);
}
} }
...@@ -126,7 +126,7 @@ public class ContactListFragment extends BaseFragment { ...@@ -126,7 +126,7 @@ public class ContactListFragment extends BaseFragment {
toId = stringBuilder.toString(); toId = stringBuilder.toString();
OIMSDK.getInstance().startChat(getActivity(), OIMSendTypeEnum.GROUP, toId, title, 0); OIMSDK.getInstance().startChat(getActivity(), OIMSendTypeEnum.GROUP, toId, title, 0);
} else { } else {
CommonUtils.showToast(getActivity(), "该课程下暂无学生"); CommonUtils.showToast(getActivity(), "暂无学员");
} }
} else { } else {
CommonUtils.showToast(getActivity(), "获取课程信息失败"); CommonUtils.showToast(getActivity(), "获取课程信息失败");
...@@ -177,7 +177,7 @@ public class ContactListFragment extends BaseFragment { ...@@ -177,7 +177,7 @@ public class ContactListFragment extends BaseFragment {
toId = stringBuilder.toString(); toId = stringBuilder.toString();
OIMSDK.getInstance().startChat(getActivity(), OIMSendTypeEnum.GROUP, toId, title, 0); OIMSDK.getInstance().startChat(getActivity(), OIMSendTypeEnum.GROUP, toId, title, 0);
} else { } else {
CommonUtils.showToast(getActivity(), "该课程下暂无学生"); CommonUtils.showToast(getActivity(), "暂无学员");
} }
} }
} }
......
...@@ -103,13 +103,17 @@ public class MainActivity extends BaseActivity { ...@@ -103,13 +103,17 @@ public class MainActivity extends BaseActivity {
LoginManager.logout(MainActivity.this); LoginManager.logout(MainActivity.this);
UserBeanDaoManager.getInstance().deleteAll(); UserBeanDaoManager.getInstance().deleteAll();
if (code == OIMCode.Code_IM_Error_NoExist
if (code == OIMCode.Code_IM_Disconnect_Kick) { || code == OIMCode.Code_IM_Error_TokenInvalid) {
CommonUtils.showToast(MainActivity.this, "请求失败,请重新登录");
startActivity(new Intent(MainActivity.this, LoginActivity.class));
AppManager.getAppManager().finishAllActivity();
} else if (code == OIMCode.Code_IM_Disconnect_Kick) {
Activity curActivity = AppManager.getAppManager().getCurrentActivity(); Activity curActivity = AppManager.getAppManager().getCurrentActivity();
if (curActivity != null) { if (curActivity != null) {
AlertDialog dialog = new AlertDialog.Builder(curActivity) AlertDialog dialog = new AlertDialog.Builder(curActivity)
.setTitle("下线通知") .setTitle("下线通知")
.setMessage(error) .setMessage("你的帐号已在另一台设备登录,如非本人操作,则密码可能已泄漏,为了你的帐号安全,建议尽快修改密码。")
.setPositiveButton("重新登录", new DialogInterface.OnClickListener() { .setPositiveButton("重新登录", new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
......
...@@ -2,12 +2,14 @@ package com.offcn.imclient.util; ...@@ -2,12 +2,14 @@ package com.offcn.imclient.util;
import android.content.Context; import android.content.Context;
import com.jyall.base.util.ValidateUtils;
import com.offcn.imclient.bean.UserBean; import com.offcn.imclient.bean.UserBean;
import com.offcn.imclient.greendao.gen.DaoSession; import com.offcn.imclient.greendao.gen.DaoSession;
import com.offcn.imclient.greendao.gen.UserBeanDao; import com.offcn.imclient.greendao.gen.UserBeanDao;
import org.greenrobot.greendao.query.QueryBuilder; import org.greenrobot.greendao.query.QueryBuilder;
import java.util.ArrayList;
import java.util.List; import java.util.List;
public class UserBeanDaoManager { public class UserBeanDaoManager {
...@@ -111,6 +113,7 @@ public class UserBeanDaoManager { ...@@ -111,6 +113,7 @@ public class UserBeanDaoManager {
} }
public List<UserBean> queryByNameOrMobile(String content) { public List<UserBean> queryByNameOrMobile(String content) {
List<UserBean> result = new ArrayList<>();
try { try {
QueryBuilder<UserBean> builder = manager.getDaoSession().queryBuilder(UserBean.class); QueryBuilder<UserBean> builder = manager.getDaoSession().queryBuilder(UserBean.class);
List<UserBean> list = builder.where( List<UserBean> list = builder.where(
...@@ -119,12 +122,19 @@ public class UserBeanDaoManager { ...@@ -119,12 +122,19 @@ public class UserBeanDaoManager {
UserBeanDao.Properties.Username.like("%" + content + "%") UserBeanDao.Properties.Username.like("%" + content + "%")
) )
) )
.distinct()
.list(); .list();
return list;
if (!ValidateUtils.isEmpty(list)) {
for (UserBean userBean : list) {
if (!result.contains(userBean)) {
result.add(userBean);
}
}
}
} catch (Exception e) { } catch (Exception e) {
return null;
} }
return result;
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment