refactor: 移除添加好友后获取详细信息的冗余逻辑
移除 `getFriendDetailInfo` 方法及相关调用,因为添加好友成功后不再需要立即进入详情页抓取信息。这简化了添加好友的流程,避免了不必要的页面跳转和潜在的稳定性问题。
This commit is contained in:
@@ -455,12 +455,6 @@ object WeworkLoopImpl {
|
||||
if (textNode?.text?.toString() == "添加请求已过期,添加失败") {
|
||||
LogUtils.d("添加好友失败")
|
||||
} else {
|
||||
// 获取完整的好友信息
|
||||
val friendInfo = getFriendDetailInfo(friendName)
|
||||
val weworkMessageBean = WeworkMessageBean()
|
||||
weworkMessageBean.type = WeworkMessageBean.GET_FRIEND_INFO
|
||||
weworkMessageBean.friend = friendInfo
|
||||
WeworkController.weworkService.webSocketManager.send(weworkMessageBean)
|
||||
nameList.add(friendName)
|
||||
}
|
||||
//回到上一页
|
||||
@@ -476,66 +470,6 @@ object WeworkLoopImpl {
|
||||
return nameList
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取好友详细信息
|
||||
* 通过好友后进入详情页抓取完整信息
|
||||
*/
|
||||
private fun getFriendDetailInfo(friendName: String): WeworkMessageBean.Friend {
|
||||
val friend = WeworkMessageBean.Friend().apply {
|
||||
name = friendName
|
||||
newFriend = true
|
||||
}
|
||||
try {
|
||||
// 点击发消息进入聊天页面
|
||||
val sendMsgNode = AccessibilityUtil.findOneByText(getRoot(), "发消息", exact = true)
|
||||
if (sendMsgNode != null) {
|
||||
AccessibilityUtil.performClick(sendMsgNode)
|
||||
sleep(Constant.CHANGE_PAGE_INTERVAL)
|
||||
}
|
||||
|
||||
// 进入好友详情页
|
||||
if (WeworkRoomUtil.intoFriendDetail()) {
|
||||
sleep(Constant.CHANGE_PAGE_INTERVAL)
|
||||
// 解析详情页信息
|
||||
val listView = AccessibilityUtil.findOneByClazz(getRoot(), Views.ListView)
|
||||
if (listView != null) {
|
||||
// 遍历列表获取各字段信息
|
||||
for (i in 0 until listView.childCount) {
|
||||
val item = listView.getChild(i) ?: continue
|
||||
val textViews = AccessibilityUtil.findAllOnceByClazz(item, Views.TextView)
|
||||
if (textViews.size >= 2) {
|
||||
val label = textViews[0].text?.toString() ?: ""
|
||||
val value = textViews[1].text?.toString() ?: ""
|
||||
when {
|
||||
label.contains("微信号") || label.contains("微信ID") -> friend.wechatId = value
|
||||
label.contains("手机") -> friend.phone = value
|
||||
label.contains("企业") -> friend.corpName = value
|
||||
label.contains("部门") -> friend.department = value
|
||||
label.contains("职位") || label.contains("职务") -> friend.position = value
|
||||
label.contains("邮箱") -> friend.email = value
|
||||
label.contains("备注") -> friend.markName = value
|
||||
}
|
||||
LogUtils.d("好友详情 - $label: $value")
|
||||
}
|
||||
}
|
||||
}
|
||||
// 尝试获取头像(如果有)
|
||||
val avatarView = AccessibilityUtil.findOneByClazz(getRoot(), Views.ImageView)
|
||||
if (avatarView != null) {
|
||||
// 头像通常没有直接URL,这里留空或可通过其他方式获取
|
||||
// friend.avatarUrl = ""
|
||||
}
|
||||
// 返回聊天页面
|
||||
backPress()
|
||||
sleep(Constant.POP_WINDOW_INTERVAL)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
LogUtils.e("获取好友详情失败: ${e.message}")
|
||||
}
|
||||
LogUtils.d("好友信息: $friend")
|
||||
return friend
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单聊联系人详细信息
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user