update 优化消息列表检查
This commit is contained in:
@@ -427,7 +427,7 @@ object WeworkGetImpl {
|
||||
for (i in 0 until list.childCount) {
|
||||
val item = list.getChild(i)
|
||||
val tempList = arrayListOf<WeworkMessageBean.ItemMessageBean>()
|
||||
val tvList = AccessibilityUtil.findAllOnceByClazz(item, Views.TextView).mapNotNull { it.text }
|
||||
val tvList = AccessibilityUtil.findAllOnceByClazz(item, Views.TextView).mapNotNull { it.text }.filter { !it.startsWith("@") }
|
||||
tvList.forEach { tempList.add(WeworkMessageBean.ItemMessageBean(null, it.toString())) }
|
||||
listBriefList.add(WeworkMessageBean.SubMessageBean(null, null, tempList, null))
|
||||
//tvList title/time/content
|
||||
|
||||
@@ -238,8 +238,8 @@ object WeworkLoopImpl {
|
||||
} else {
|
||||
lastMessage.itemMessageList.lastOrNull()?.text
|
||||
}
|
||||
SPUtils.getInstance("lastSyncMessage").put(title, lastSyncMessage)
|
||||
LogUtils.v("lastSyncMessage: $lastSyncMessage")
|
||||
SPUtils.getInstance("lastSyncMessage").put(titleList[0], lastSyncMessage)
|
||||
LogUtils.v("lastSyncMessage: ${titleList[0]}: $lastSyncMessage")
|
||||
if (Constant.enableMediaProject && Constant.pushImage) {
|
||||
log("image: ${imageSet.size}")
|
||||
if (imageSet.isNotEmpty()) {
|
||||
@@ -471,15 +471,13 @@ object WeworkLoopImpl {
|
||||
if (stop) {
|
||||
return false
|
||||
}
|
||||
val listview = AccessibilityUtil.findOneByClazz(getRoot(), Views.RecyclerView, Views.ListView, Views.ViewGroup)
|
||||
if (listview != null && listview.childCount >= 2) {
|
||||
if (checkNoTipMessage(listview) != 1) {
|
||||
AccessibilityUtil.scrollToBottom(WeworkController.weworkService, getRoot(), listener = object : AccessibilityUtil.OnScrollListener() {
|
||||
val onScrollListener = object : AccessibilityUtil.OnScrollListener() {
|
||||
override fun onScroll(): Boolean {
|
||||
if (hasNewMessage()) {
|
||||
return true
|
||||
}
|
||||
if (checkNoTipMessage(listview) != 0) {
|
||||
if (checkNoTipMessage(listview) == 1) {
|
||||
return true
|
||||
}
|
||||
if (checkNoSyncMessage(listview) != 0) {
|
||||
@@ -487,7 +485,10 @@ object WeworkLoopImpl {
|
||||
}
|
||||
return false
|
||||
}
|
||||
})
|
||||
}
|
||||
//滚动前先获取一次
|
||||
onScrollListener.onScroll()
|
||||
AccessibilityUtil.scrollToBottom(WeworkController.weworkService, getRoot(), listener = onScrollListener)
|
||||
LogUtils.v("回到消息列表顶部")
|
||||
for (item in list) {
|
||||
val childCount = item.parent?.parent?.parent?.childCount
|
||||
@@ -499,7 +500,6 @@ object WeworkLoopImpl {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -546,7 +546,7 @@ object WeworkLoopImpl {
|
||||
val listBriefList = arrayListOf<List<CharSequence>>()
|
||||
for (i in 0 until list.childCount) {
|
||||
val item = list.getChild(i)
|
||||
val tvList = AccessibilityUtil.findAllOnceByClazz(item, Views.TextView).mapNotNull { it.text?.toString() }
|
||||
val tvList = AccessibilityUtil.findAllOnceByClazz(item, Views.TextView).mapNotNull { it.text?.toString() }.filter { !it.startsWith("@") }
|
||||
listBriefList.add(tvList)
|
||||
//tvList title/time/content
|
||||
if (tvList.size == 3) {
|
||||
@@ -584,15 +584,16 @@ object WeworkLoopImpl {
|
||||
private fun checkNoSyncMessage(list: AccessibilityNodeInfo): Int {
|
||||
list.refresh()
|
||||
val listBriefList = arrayListOf<List<CharSequence>>()
|
||||
val titleSet = hashSetOf<String>()
|
||||
for (i in 0 until list.childCount) {
|
||||
val item = list.getChild(i)
|
||||
val tvList = AccessibilityUtil.findAllOnceByClazz(item, Views.TextView).mapNotNull { it.text?.toString() }
|
||||
val tvList = AccessibilityUtil.findAllOnceByClazz(item, Views.TextView).mapNotNull { it.text?.toString() }.filter { !it.startsWith("@") }
|
||||
listBriefList.add(tvList)
|
||||
//tvList title/time/content
|
||||
if (tvList.size == 3) {
|
||||
//只查看最近一周内的消息
|
||||
val title = tvList[0]
|
||||
if (title == "群聊") {
|
||||
if (title == "群聊" || !titleSet.add(title)) {
|
||||
continue
|
||||
}
|
||||
if (tvList[1].isBlank() || tvList[1].contains("(刚刚)|(分钟前)|(上午)|(下午)|(昨天)|(星期)|(日程)|(会议)|(:)".toRegex())) {
|
||||
|
||||
Reference in New Issue
Block a user