diff --git a/src/main/java/com/thankjava/wqq/core/action/GetInfoAction.java b/src/main/java/com/thankjava/wqq/core/action/GetInfoAction.java index e90798c..8e9536a 100644 --- a/src/main/java/com/thankjava/wqq/core/action/GetInfoAction.java +++ b/src/main/java/com/thankjava/wqq/core/action/GetInfoAction.java @@ -45,7 +45,6 @@ public class GetInfoAction { * @date 2016年12月22日 下午1:34:35 * @version 1.0 */ - @Deprecated public FriendsList getFriendsList() { AsyncResponse response = null; @@ -111,7 +110,6 @@ public void onListener(ActionListener actionListener) { * @date 2017年6月14日 下午2:46:17 * @version 1.0 */ - @Deprecated public FriendsList getOnlineStatus() { FriendsList friendsList = session.getFriendsList(); @@ -136,6 +134,7 @@ public FriendsList getOnlineStatus() { return null; } + public void getOnlineStatus(final CallBackListener callBackListener, final Integer... tryTimes) { final int tryTime = tryTimes == null || tryTimes.length == 0 ? 1 : tryTimes[0] + 1; @@ -198,6 +197,40 @@ public DiscusList getDiscusList() { return null; } + /** + * 异步获取讨论组信息 + * @param callBackListener + * @param tryTimes + */ + public void getDiscusList(final CallBackListener callBackListener, final Integer... tryTimes) { + final int tryTime = tryTimes == null || tryTimes.length == 0 ? 1 : tryTimes[0] + 1; + + if (tryTime >= ConfigParams.EXCEPTION_RETRY_MAX_TIME) { + logger.error("getGroupNameListMask2 失败 (已尝试重试)"); + callBackListener.onListener(new ActionListener(null)); + return; + } + + getDiscusList.doRequest(new CallBackListener() { + @Override + public void onListener(ActionListener actionListener) { + if (actionListener.getData() != null) { + AsyncResponse asyncResponse = (AsyncResponse) actionListener.getData(); + DiscusList discusList = JSON2Entity.getDiscusList(asyncResponse.getDataString()); + if (discusList != null) { + session.setDiscusList(discusList); + callBackListener.onListener(new ActionListener(discusList)); + } else { + getDiscusList(callBackListener, tryTime); + } + } else { + getDiscusList(callBackListener, tryTime); + } + } + + }); + } + /** * 获取群列表 *

Function: getGroupsList

@@ -226,6 +259,11 @@ public GroupsList getGroupsList() { return null; } + /** + * 异步获取群组列表 + * @param callBackListener + * @param tryTimes + */ public void getGroupsList(final CallBackListener callBackListener, final Integer... tryTimes) { final int tryTime = tryTimes == null || tryTimes.length == 0 ? 1 : tryTimes[0] + 1; @@ -246,10 +284,10 @@ public void onListener(ActionListener actionListener) { session.setGroupsList(groupList); callBackListener.onListener(new ActionListener(groupList)); } else { - getOnlineStatus(callBackListener, tryTime); + getGroupsList(callBackListener, tryTime); } } else { - getOnlineStatus(callBackListener, tryTime); + getGroupsList(callBackListener, tryTime); } } @@ -284,10 +322,48 @@ public DetailedInfo getSelfInfo() { return null; } + + /** + * 异步获取个人信息 + * @param callBackListener + * @param tryTimes + */ public void getSelfInfo(final CallBackListener callBackListener, final Integer... tryTimes) { + + final int tryTime = tryTimes == null || tryTimes.length == 0 ? 1 : tryTimes[0] + 1; + + if (tryTime >= ConfigParams.EXCEPTION_RETRY_MAX_TIME) { + logger.error("getSelfInfo2 失败 (已尝试重试)"); + callBackListener.onListener(new ActionListener(null)); + return; + } + + getSelfInfo2.doRequest(new CallBackListener() { + + @Override + public void onListener(ActionListener actionListener) { + if (actionListener.getData() != null) { + AsyncResponse asyncResponse = (AsyncResponse) actionListener.getData(); + DetailedInfo detailedInfo = JSON2Entity.getSelfInfo(asyncResponse.getDataString()); + if (detailedInfo != null) { + session.setSelfInfo(detailedInfo); + callBackListener.onListener(new ActionListener(detailedInfo)); + } else { + getSelfInfo(callBackListener, tryTime); + } + } else { + getSelfInfo(callBackListener, tryTime); + } + } + + }); } + /** + * 获取最近联系的好友,没有实际意义未实现 + */ + @Deprecated void getRecentList() { getRecentList2.doRequest(null).isEmptyDataString(); } -} +} \ No newline at end of file diff --git a/src/main/java/com/thankjava/wqq/core/action/LoginAction.java b/src/main/java/com/thankjava/wqq/core/action/LoginAction.java index fa9ad5c..d218089 100644 --- a/src/main/java/com/thankjava/wqq/core/action/LoginAction.java +++ b/src/main/java/com/thankjava/wqq/core/action/LoginAction.java @@ -202,7 +202,7 @@ public void onListener(ActionListener actionListener) { if (actionListener.getData() == null) { logger.error("查询好友状态失败"); } else { - logger.error("查询好友状态失败"); + logger.debug("查询好友状态成功"); } } }); @@ -215,6 +215,31 @@ public void onListener(ActionListener actionListener) { public void onListener(ActionListener actionListener) { if (actionListener.getData() != null) { logger.debug("获取群列表成功"); + }else { + logger.error("获取群列表失败"); + } + } + }); + + getInfo.getSelfInfo(new CallBackListener() { + @Override + public void onListener(ActionListener actionListener) { + if (actionListener.getData() != null) { + logger.debug("获取个人信息成功"); + }else { + logger.error("获取个人信息失败"); + } + } + }); + + getInfo.getDiscusList(new CallBackListener() { + @Override + public void onListener(ActionListener actionListener) { + if (actionListener.getData() != null) { + logger.debug("获取讨论组列表成功"); + } else { + logger.error("获取讨论组列表失败"); + } } }); @@ -230,8 +255,8 @@ public void onListener(ActionListener actionListener) { // } // getInfo.getGroupsList(); // getInfo.getDiscusList(); - getInfo.getSelfInfo(); - getInfo.getRecentList(); +// getInfo.getSelfInfo(); +// getInfo.getRecentList();