|
@@ -32,6 +32,7 @@ import com.xzjmyk.pm.activity.ui.erp.util.auto.HttpHandler;
|
|
|
import com.xzjmyk.pm.activity.ui.message.ChatActivity;
|
|
import com.xzjmyk.pm.activity.ui.message.ChatActivity;
|
|
|
import com.xzjmyk.pm.activity.ui.message.MucChatActivity;
|
|
import com.xzjmyk.pm.activity.ui.message.MucChatActivity;
|
|
|
import com.xzjmyk.pm.activity.ui.message.NewFriendActivity;
|
|
import com.xzjmyk.pm.activity.ui.message.NewFriendActivity;
|
|
|
|
|
+import com.xzjmyk.pm.activity.ui.tool.ThreadUtil;
|
|
|
import com.xzjmyk.pm.activity.util.PreferenceUtils;
|
|
import com.xzjmyk.pm.activity.util.PreferenceUtils;
|
|
|
import com.xzjmyk.pm.activity.util.StringUtils;
|
|
import com.xzjmyk.pm.activity.util.StringUtils;
|
|
|
import com.xzjmyk.pm.activity.util.TimeUtils;
|
|
import com.xzjmyk.pm.activity.util.TimeUtils;
|
|
@@ -48,7 +49,8 @@ import java.util.Map;
|
|
|
*/
|
|
*/
|
|
|
|
|
|
|
|
public class MessagePresenter implements HttpHandler.OnResultListener {
|
|
public class MessagePresenter implements HttpHandler.OnResultListener {
|
|
|
- private static final int LOAD_TASK = 0x14;
|
|
|
|
|
|
|
+ private final int LOAD_TASK = 0x14;
|
|
|
|
|
+ private final int LOAD_EMNEWS_DETAILS = 0x15;
|
|
|
private final int LOAD_EMNEWS = 0x11;
|
|
private final int LOAD_EMNEWS = 0x11;
|
|
|
private final int LOAD_SUBS = 0x12;
|
|
private final int LOAD_SUBS = 0x12;
|
|
|
private final int LOAD_PROCESS = 0x13;
|
|
private final int LOAD_PROCESS = 0x13;
|
|
@@ -160,6 +162,22 @@ public class MessagePresenter implements HttpHandler.OnResultListener {
|
|
|
HttpHandler.getInstance().loadERPByNet(LOAD_PROCESS, "common/desktop/process/toDo.action", param, null, this, "get");
|
|
HttpHandler.getInstance().loadERPByNet(LOAD_PROCESS, "common/desktop/process/toDo.action", param, null, this, "get");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 获取消息详细信息接口
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param type 消息类型
|
|
|
|
|
+ * @param isReaded 是否是阅读全部,如果不是就是删除全部
|
|
|
|
|
+ */
|
|
|
|
|
+ private void loadEmNewsDetails(String type, boolean isReaded) {
|
|
|
|
|
+ Map<String, Object> param = new HashMap<>();
|
|
|
|
|
+ param.put("emcode", CommonUtil.getSharedPreferences(ct, "erp_username"));
|
|
|
|
|
+ param.put("type", type);
|
|
|
|
|
+ Bundle bundle = new Bundle();
|
|
|
|
|
+ bundle.putString("type", type);
|
|
|
|
|
+ bundle.putBoolean("isReaded", isReaded);
|
|
|
|
|
+ HttpHandler.getInstance().loadERPByNet(LOAD_EMNEWS_DETAILS, "mobile/queryEmNewsDetails.action", param, bundle, this, "get");
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public void result(int what, boolean isJSON, String message, Bundle bundle) {
|
|
public void result(int what, boolean isJSON, String message, Bundle bundle) {
|
|
@@ -185,6 +203,15 @@ public class MessagePresenter implements HttpHandler.OnResultListener {
|
|
|
case LOAD_TASK://获取任务接口
|
|
case LOAD_TASK://获取任务接口
|
|
|
handlerTask(object);
|
|
handlerTask(object);
|
|
|
break;
|
|
break;
|
|
|
|
|
+ case LOAD_EMNEWS_DETAILS:
|
|
|
|
|
+ String type = bundle.getString("type");
|
|
|
|
|
+ boolean isReaded = bundle.getBoolean("isReaded");
|
|
|
|
|
+ JSONArray msgsArray = object.getJSONArray("listdata");
|
|
|
|
|
+ if (!ListUtils.isEmpty(msgsArray)) {
|
|
|
|
|
+ handleMsgsArray(type, msgsArray);
|
|
|
|
|
+ }
|
|
|
|
|
+ handlerEndOfReadOrDelete(type, isReaded);
|
|
|
|
|
+ break;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -193,6 +220,40 @@ public class MessagePresenter implements HttpHandler.OnResultListener {
|
|
|
public void error(int what, int statuCode, String message, Bundle bundle) {
|
|
public void error(int what, int statuCode, String message, Bundle bundle) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 处理获取网络获取到的数据,先更新本地数据库,再加载本地数据库
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param msgsArray
|
|
|
|
|
+ */
|
|
|
|
|
+ private void handleMsgsArray(String type, JSONArray msgsArray) {
|
|
|
|
|
+ JSONObject object = null;
|
|
|
|
|
+ final List<MessageModel> models = new ArrayList<>();
|
|
|
|
|
+ MessageModel model = null;
|
|
|
|
|
+ for (int i = 0; i < msgsArray.size(); i++) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ object = msgsArray.getJSONObject(i);
|
|
|
|
|
+ model = new MessageModel();
|
|
|
|
|
+ model.setId(object.getInteger("id"));
|
|
|
|
|
+ model.setTitle(object.getString("title"));
|
|
|
|
|
+ model.setSubTitle(object.getString("subTitle"));
|
|
|
|
|
+ model.setTime(object.getString("createTime"));
|
|
|
|
|
+ model.setHierarchy(1);
|
|
|
|
|
+ model.setType(type);
|
|
|
|
|
+ model.setCount(1);
|
|
|
|
|
+ models.add(model);
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ ThreadUtil.getInstance().addTask(new Runnable() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void run() {
|
|
|
|
|
+ MessageDao.getInstance().createOrinstart(models);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 处理任务相关数据
|
|
* 处理任务相关数据
|
|
|
*
|
|
*
|
|
@@ -450,8 +511,9 @@ public class MessagePresenter implements HttpHandler.OnResultListener {
|
|
|
if (ListUtils.isEmpty(mFriendList) || mFriendList.size() < position) return;
|
|
if (ListUtils.isEmpty(mFriendList) || mFriendList.size() < position) return;
|
|
|
Friend friend = mFriendList.get(position).getBean();
|
|
Friend friend = mFriendList.get(position).getBean();
|
|
|
if (friend.getType() == XmppMessage.TYPE_ERP) {
|
|
if (friend.getType() == XmppMessage.TYPE_ERP) {
|
|
|
- MessageDao.getInstance().deleteBytype(friend.getDescription());
|
|
|
|
|
- loadData();
|
|
|
|
|
|
|
+ loadEmNewsDetails(friend.getDescription(), false);
|
|
|
|
|
+// MessageDao.getInstance().deleteBytype(friend.getDescription());
|
|
|
|
|
+// loadData();
|
|
|
} else {
|
|
} else {
|
|
|
deleteByIm(friend, position);
|
|
deleteByIm(friend, position);
|
|
|
}
|
|
}
|
|
@@ -466,8 +528,9 @@ public class MessagePresenter implements HttpHandler.OnResultListener {
|
|
|
if (ListUtils.isEmpty(mFriendList) || mFriendList.size() < position) return;
|
|
if (ListUtils.isEmpty(mFriendList) || mFriendList.size() < position) return;
|
|
|
Friend friend = mFriendList.get(position).getBean();
|
|
Friend friend = mFriendList.get(position).getBean();
|
|
|
if (friend.getType() == XmppMessage.TYPE_ERP) {
|
|
if (friend.getType() == XmppMessage.TYPE_ERP) {
|
|
|
- MessageDao.getInstance().upStatusByType(friend.getDescription(), true);
|
|
|
|
|
- loadData();
|
|
|
|
|
|
|
+ loadEmNewsDetails(friend.getDescription(), true);
|
|
|
|
|
+// MessageDao.getInstance().upStatusByType(friend.getDescription(), true);
|
|
|
|
|
+// loadData();
|
|
|
} else {
|
|
} else {
|
|
|
if (friend.getUnReadNum() > 0) {
|
|
if (friend.getUnReadNum() > 0) {
|
|
|
MsgBroadcast.broadcastMsgNumUpdate(ct, false, friend.getUnReadNum());
|
|
MsgBroadcast.broadcastMsgNumUpdate(ct, false, friend.getUnReadNum());
|
|
@@ -477,6 +540,15 @@ public class MessagePresenter implements HttpHandler.OnResultListener {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private void handlerEndOfReadOrDelete(String type, boolean isReaded) {
|
|
|
|
|
+ if (isReaded) {
|
|
|
|
|
+ MessageDao.getInstance().upStatusByType(type, true);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ MessageDao.getInstance().deleteBytype(type);
|
|
|
|
|
+ }
|
|
|
|
|
+ loadData();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 计算搜索显示新的内容
|
|
* 计算搜索显示新的内容
|
|
|
*
|
|
*
|