Skip to content

Commit

Permalink
增加巡逻保护地切换新地图
Browse files Browse the repository at this point in the history
  • Loading branch information
constanline committed Sep 22, 2023
1 parent e166df7 commit e27de7c
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
22 changes: 22 additions & 0 deletions app/src/main/java/pansong291/xposed/quickenergy/AntForest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1443,6 +1443,28 @@ private static void queryUserPatrol() {
try {
JSONObject jo = new JSONObject(AntForestRpcCall.queryUserPatrol());
if ("SUCCESS".equals(jo.getString("resultCode"))) {
JSONObject resData = new JSONObject(AntForestRpcCall.queryMyPatrolRecord());
if (resData.optBoolean("canSwitch")) {
JSONArray records = resData.getJSONArray("records");
for (int i = 0; i < records.length(); i++) {
JSONObject record = records.getJSONObject(i);
JSONObject userPatrol = record.getJSONObject("userPatrol");
if (userPatrol.getInt("unreachedNodeCount") > 0) {
if ("silent".equals(userPatrol.getString("mode"))) {
JSONObject patrolConfig = record.getJSONObject("patrolConfig");
String patrolId = patrolConfig.getString("patrolId");
resData = new JSONObject(AntForestRpcCall.switchUserPatrol(patrolId));
if ("SUCCESS".equals(resData.getString("resultCode"))) {
Log.forest("巡逻⚖️-切换地图至" + patrolId);
}
queryUserPatrol();
return;
}
break;
}
}
}

JSONObject userPatrol = jo.getJSONObject("userPatrol");
int currentNode = userPatrol.getInt("currentNode");
String currentStatus = userPatrol.getString("currentStatus");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,14 @@ public static String queryUserPatrol() {
return RpcUtil.request("alipay.antforest.forest.h5.queryUserPatrol",
"[{\"source\":\"ant_forest\",\"timezoneId\":\"Asia/Shanghai\"}]");
}
public static String queryMyPatrolRecord() {
return RpcUtil.request("alipay.antforest.forest.h5.queryMyPatrolRecord",
"[{\"source\":\"ant_forest\",\"timezoneId\":\"Asia/Shanghai\"}]");
}
public static String switchUserPatrol(String targetPatrolId) {
return RpcUtil.request("alipay.antforest.forest.h5.switchUserPatrol",
"[{\"source\":\"ant_forest\",\"targetPatrolId\":" + targetPatrolId + ",\"timezoneId\":\"Asia/Shanghai\"}]");
}

public static String patrolGo(int nodeIndex, int patrolId) {
return RpcUtil.request("alipay.antforest.forest.h5.patrolGo",
Expand Down

0 comments on commit e27de7c

Please sign in to comment.