|
|
@@ -3,6 +3,7 @@ package com.core.xmpp;
|
|
|
import android.content.Context;
|
|
|
import android.content.Intent;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.android.volley.Response.ErrorListener;
|
|
|
import com.android.volley.VolleyError;
|
|
|
import com.common.LogUtil;
|
|
|
@@ -12,10 +13,12 @@ import com.core.broadcast.MsgBroadcast;
|
|
|
import com.core.model.AttentionUser;
|
|
|
import com.core.model.CircleMessage;
|
|
|
import com.core.model.Friend;
|
|
|
+import com.core.model.Hrorgs;
|
|
|
import com.core.net.volley.ArrayResult;
|
|
|
import com.core.net.volley.FastVolley;
|
|
|
import com.core.net.volley.Result;
|
|
|
import com.core.net.volley.StringJsonArrayRequest;
|
|
|
+import com.core.utils.sortlist.BaseSortModel;
|
|
|
import com.core.utils.sp.TableVersionSp;
|
|
|
import com.core.xmpp.dao.ChatMessageDao;
|
|
|
import com.core.xmpp.dao.CircleMessageDao;
|
|
|
@@ -121,25 +124,52 @@ public class FriendHelper {
|
|
|
MsgBroadcast.broadcastMsgNumReset(MyApplication.getInstance());
|
|
|
}
|
|
|
|
|
|
+ public static void addGoodFriend(Context context, Hrorgs.Employee employee) {
|
|
|
+ if (employee != null) {
|
|
|
+ Friend friend = new Friend();
|
|
|
+ friend.setTimeCreate((int) (System.currentTimeMillis() / 1000));
|
|
|
+ friend.setTimeSend((int) (System.currentTimeMillis() / 1000));
|
|
|
+ friend.setOwnerId(MyApplication.getInstance().getLoginUserId());
|
|
|
+ friend.setUserId(String.valueOf(employee.em_imid));
|
|
|
+ friend.setNickName(employee.em_name);
|
|
|
+ friend.setPhone(employee.em_mobile);
|
|
|
+ friend.setEmCode(employee.em_code);
|
|
|
+ friend.setRoomFlag(0);// 0朋友 1群组
|
|
|
+ friend.setStatus(Friend.STATUS_FRIEND);
|
|
|
+ BaseSortModel<Friend> mode = new BaseSortModel<>();
|
|
|
+ mode.setBean(friend);
|
|
|
+ addGoodFriend(context, friend);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 添加常用
|
|
|
+ * 1.拨打电话
|
|
|
+ * 2.发送聊天信息
|
|
|
*/
|
|
|
- public static void addGoodFriend(Context context,Friend friend) {
|
|
|
- if (friend != null && friend.getClickNum() < 10) {
|
|
|
- int lastMagSend = friend.getTimeSend();
|
|
|
- int defTime = ((int) System.currentTimeMillis() / 1000) - lastMagSend;
|
|
|
- if (defTime<86400){
|
|
|
- friend.setClickNum(10);
|
|
|
- boolean b=FriendDao.getInstance().createOrUpdateFriend(friend);
|
|
|
- if (b&&context!=null){
|
|
|
- Intent intent = new Intent("com.app.home.update");
|
|
|
- intent.putExtra("isGood", true);
|
|
|
- context.sendBroadcast(intent);
|
|
|
+ public static void addGoodFriend(Context context, Friend friend) {
|
|
|
+ if (friend != null) {
|
|
|
+ String ownId = MyApplication.getInstance().getLoginUserId();
|
|
|
+ LogUtil.i("ownId== " + ownId);
|
|
|
+ LogUtil.i("friendid== " + friend.getUserId());
|
|
|
+ Friend updateFriend = FriendDao.getInstance().getFriend(ownId, friend.getUserId());
|
|
|
+ if (updateFriend == null) {
|
|
|
+ friend.setTimeSend( (int) (System.currentTimeMillis() / 1000));
|
|
|
+ FriendDao.getInstance().createFriend(friend);
|
|
|
+ } else {
|
|
|
+ LogUtil.i("updateFriend==elseelseelse");
|
|
|
+ int lastMagSend = updateFriend.getTimeSend();
|
|
|
+ int defTime = ((int) System.currentTimeMillis() / 1000) - lastMagSend;
|
|
|
+ if (defTime < 86400) {
|
|
|
+ FriendDao.getInstance().updateClickNum(ownId, friend.getUserId(), 10);
|
|
|
+ } else {
|
|
|
+ FriendDao.getInstance().updateSendTime(ownId, friend.getUserId(), (int) (System.currentTimeMillis() / 1000));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* 在本地数据库表中出入一条关注记录,额外需要做的操作
|
|
|
*/
|
|
|
@@ -161,6 +191,7 @@ public class FriendHelper {
|
|
|
// 更新Main Ui message 未读数量
|
|
|
MsgBroadcast.broadcastMsgNumUpdate(MyApplication.getInstance(), true, 1);
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 如果关注或加好友某个人,那么就去下载他的商务圈消息
|
|
|
*
|