update 优化图片识别
This commit is contained in:
@@ -4,6 +4,7 @@ import java.io.File;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Stack;
|
import java.util.Stack;
|
||||||
|
|
||||||
@@ -13,8 +14,9 @@ import android.util.Log;
|
|||||||
public class MultiFileObserver extends FileObserver {
|
public class MultiFileObserver extends FileObserver {
|
||||||
|
|
||||||
public HashMap<String, Long> map = new HashMap<>();
|
public HashMap<String, Long> map = new HashMap<>();
|
||||||
public static HashSet<String> createSet = new HashSet<>();
|
public static HashSet<String> createSet = new LinkedHashSet<>();
|
||||||
public static HashSet<String> finishSet = new HashSet<>();
|
public static HashSet<String> finishSet = new LinkedHashSet<>();
|
||||||
|
public static HashSet<String> saveSet = new LinkedHashSet<>();
|
||||||
|
|
||||||
/** Only modification events */
|
/** Only modification events */
|
||||||
public static int CHANGES_ONLY = CREATE | MODIFY | DELETE | CLOSE_WRITE
|
public static int CHANGES_ONLY = CREATE | MODIFY | DELETE | CLOSE_WRITE
|
||||||
|
|||||||
@@ -163,6 +163,25 @@ object WeworkLoopImpl {
|
|||||||
}
|
}
|
||||||
} while (messageList != messageList2)
|
} while (messageList != messageList2)
|
||||||
if (messageList.isNotEmpty()) {
|
if (messageList.isNotEmpty()) {
|
||||||
|
val lastMessage = messageList.last()
|
||||||
|
val lastSyncMessage = if (lastMessage.textType == WeworkMessageBean.TEXT_TYPE_IMAGE) {
|
||||||
|
"[图片]"
|
||||||
|
} else {
|
||||||
|
lastMessage.itemMessageList.lastOrNull()?.text
|
||||||
|
}
|
||||||
|
SPUtils.getInstance("lastSyncMessage").put(title, lastSyncMessage)
|
||||||
|
if (Constant.pushImage && MultiFileObserver.saveSet.isNotEmpty()) {
|
||||||
|
val imageMessageList = messageList.filter { it.textType == WeworkMessageBean.TEXT_TYPE_IMAGE }.reversed()
|
||||||
|
MultiFileObserver.saveSet.reversed().forEachIndexed { index, targetPath ->
|
||||||
|
if (imageMessageList.size > index) {
|
||||||
|
val message = imageMessageList[index]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
MultiFileObserver.saveSet.clear()
|
||||||
|
}
|
||||||
|
if (Constant.pushImage) {
|
||||||
|
messageList.removeIf { it.textType == WeworkMessageBean.TEXT_TYPE_IMAGE }
|
||||||
|
}
|
||||||
WeworkController.weworkService.webSocketManager.send(
|
WeworkController.weworkService.webSocketManager.send(
|
||||||
WeworkMessageBean(
|
WeworkMessageBean(
|
||||||
null, null,
|
null, null,
|
||||||
@@ -173,13 +192,6 @@ object WeworkLoopImpl {
|
|||||||
null
|
null
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
val lastMessage = messageList.last()
|
|
||||||
val lastSyncMessage = if (lastMessage.textType == WeworkMessageBean.TEXT_TYPE_IMAGE) {
|
|
||||||
"[图片]"
|
|
||||||
} else {
|
|
||||||
lastMessage.itemMessageList.lastOrNull()?.text
|
|
||||||
}
|
|
||||||
SPUtils.getInstance("lastSyncMessage").put(title, lastSyncMessage)
|
|
||||||
//推测是否回复并在房间等待指令
|
//推测是否回复并在房间等待指令
|
||||||
if (needInfer) {
|
if (needInfer) {
|
||||||
val lastMessage = messageList.lastOrNull()
|
val lastMessage = messageList.lastOrNull()
|
||||||
@@ -557,6 +569,7 @@ object WeworkLoopImpl {
|
|||||||
if (imageCheck && Constant.pushImage && textType == WeworkMessageBean.TEXT_TYPE_IMAGE) {
|
if (imageCheck && Constant.pushImage && textType == WeworkMessageBean.TEXT_TYPE_IMAGE) {
|
||||||
MultiFileObserver.createSet.clear()
|
MultiFileObserver.createSet.clear()
|
||||||
MultiFileObserver.finishSet.clear()
|
MultiFileObserver.finishSet.clear()
|
||||||
|
MultiFileObserver.saveSet.clear()
|
||||||
LogUtils.v("点击图片类型")
|
LogUtils.v("点击图片类型")
|
||||||
AccessibilityUtil.performClickWithSon(relativeLayoutContent)
|
AccessibilityUtil.performClickWithSon(relativeLayoutContent)
|
||||||
AccessibilityExtraUtil.loadingPage("ShowImageController", Constant.CHANGE_PAGE_INTERVAL)
|
AccessibilityExtraUtil.loadingPage("ShowImageController", Constant.CHANGE_PAGE_INTERVAL)
|
||||||
@@ -580,6 +593,7 @@ object WeworkLoopImpl {
|
|||||||
if (FileUtils.copy(path, targetPath)) {
|
if (FileUtils.copy(path, targetPath)) {
|
||||||
LogUtils.d("复制图片完成: $targetPath " + ImageDepthSizeUtil.checkRawImage(targetPath))
|
LogUtils.d("复制图片完成: $targetPath " + ImageDepthSizeUtil.checkRawImage(targetPath))
|
||||||
log("复制图片完成: $targetPath")
|
log("复制图片完成: $targetPath")
|
||||||
|
MultiFileObserver.saveSet.add(targetPath)
|
||||||
} else {
|
} else {
|
||||||
LogUtils.e("复制图片失败 请检查权限: $targetPath")
|
LogUtils.e("复制图片失败 请检查权限: $targetPath")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user