pull/137/head
FongMi 3 years ago
parent 4d943d9df0
commit 0079082f80
  1. 25
      app/src/main/java/com/fongmi/android/tv/server/process/ActionRequestProcess.java

@ -36,13 +36,13 @@ public class ActionRequestProcess implements RequestProcess {
Map<String, String> params = session.getParms();
switch (Objects.requireNonNullElse(params.get("do"), "")) {
case "search":
onSearch(params.get("word").trim());
onSearch(params);
break;
case "push":
onPush(params.get("url").trim());
onPush(params);
break;
case "api":
onApi(params.get("url").trim());
onApi(params);
break;
case "cast":
onCast(params);
@ -54,15 +54,18 @@ public class ActionRequestProcess implements RequestProcess {
return Nano.createSuccessResponse();
}
public void onSearch(String word) {
public void onSearch(Map<String, String> params) {
String word = Objects.requireNonNullElse(params.get("word"), "");
if (word.length() > 0) ServerEvent.search(word);
}
public void onPush(String url) {
public void onPush(Map<String, String> params) {
String url = Objects.requireNonNullElse(params.get("url"), "");
if (url.length() > 0) ServerEvent.push(url);
}
public void onApi(String url) {
public void onApi(Map<String, String> params) {
String url = Objects.requireNonNullElse(params.get("url"), "");
if (url.length() > 0) ServerEvent.api(url);
}
@ -74,9 +77,9 @@ public class ActionRequestProcess implements RequestProcess {
}
public void onSync(Map<String, String> params) {
boolean sync = params.get("mode").equals("0");
boolean keep = params.get("type").equals("keep");
boolean history = params.get("type").equals("history");
boolean sync = Objects.equals(params.get("mode"), "0");
boolean keep = Objects.equals(params.get("type"), "keep");
boolean history = Objects.equals(params.get("type"), "history");
Device device = Device.objectFrom(params.get("device"));
if (params.get("device") != null && sync) {
if (history) sendHistory(device, params);
@ -116,7 +119,7 @@ public class ActionRequestProcess implements RequestProcess {
String url = params.get("url");
if (TextUtils.isEmpty(url)) return;
Config config = Config.find(url, 0);
boolean replace = params.get("mode").equals("1");
boolean replace = Objects.equals(params.get("mode"), "1");
List<History> targets = History.arrayFrom(params.get("targets"));
if (ApiConfig.get().getConfig().equals(config)) {
if (replace) History.delete(config.getId());
@ -145,7 +148,7 @@ public class ActionRequestProcess implements RequestProcess {
public void syncKeep(Map<String, String> params) {
List<Config> configs = Config.arrayFrom(params.get("configs"));
List<Keep> targets = Keep.arrayFrom(params.get("targets"));
boolean replace = params.get("mode").equals("1");
boolean replace = Objects.equals(params.get("mode"), "1");
if (ApiConfig.getUrl() == null && configs.size() > 0) {
ApiConfig.load(Config.find(configs.get(0), 0), getCallback(configs, targets));
} else {

Loading…
Cancel
Save