Add refresh event for server

pull/178/head
FongMi 2 years ago
parent 2b9dc6cff4
commit 5d9bca3d2b
  1. 6
      app/src/leanback/java/com/fongmi/android/tv/ui/activity/VideoActivity.java
  2. 10
      app/src/main/java/com/fongmi/android/tv/event/RefreshEvent.java
  3. 14
      app/src/main/java/com/fongmi/android/tv/server/process/Action.java
  4. 6
      app/src/mobile/java/com/fongmi/android/tv/ui/activity/VideoActivity.java

@ -1135,6 +1135,12 @@ public class VideoActivity extends BaseActivity implements CustomKeyDownVod.List
if (mPlayers.isExo()) mPlayers.setSub(Sub.from(Path.local(event.getText())));
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void onRefreshEvent(RefreshEvent event) {
if (event.getType() == RefreshEvent.Type.DETAIL) getDetail();
if (event.getType() == RefreshEvent.Type.PLAYER) onRefresh();
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void onPlayerEvent(PlayerEvent event) {
switch (event.getState()) {

@ -38,6 +38,14 @@ public class RefreshEvent {
EventBus.getDefault().post(new RefreshEvent(Type.WALL));
}
public static void detail() {
EventBus.getDefault().post(new RefreshEvent(Type.DETAIL));
}
public static void player() {
EventBus.getDefault().post(new RefreshEvent(Type.PLAYER));
}
private RefreshEvent(Type type) {
this.type = type;
}
@ -47,6 +55,6 @@ public class RefreshEvent {
}
public enum Type {
EMPTY, CONFIG, IMAGE, VIDEO, HISTORY, KEEP, SIZE, WALL
EMPTY, CONFIG, IMAGE, VIDEO, HISTORY, KEEP, SIZE, WALL, DETAIL, PLAYER
}
}

@ -30,7 +30,7 @@ public class Action implements Process {
@Override
public boolean isRequest(NanoHTTPD.IHTTPSession session, String path) {
return session.getMethod() == NanoHTTPD.Method.POST && path.equals("/action");
return path.equals("/action");
}
@Override
@ -46,6 +46,9 @@ public class Action implements Process {
case "api":
onApi(params);
break;
case "refresh":
onRefresh(params);
break;
case "cast":
onCast(params);
break;
@ -72,6 +75,15 @@ public class Action implements Process {
else if (url.length() > 0) ServerEvent.api(url);
}
private void onRefresh(Map<String, String> params) {
String type = params.get("type");
if ("detail".equals(type)) {
RefreshEvent.detail();
} else if ("player".equals(type)) {
RefreshEvent.player();
}
}
private void onCast(Map<String, String> params) {
Config config = Config.find(params.get("url"), 0);
Device device = Device.objectFrom(params.get("device"));

@ -1162,6 +1162,12 @@ public class VideoActivity extends BaseActivity implements Clock.Callback, Custo
}
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void onRefreshEvent(RefreshEvent event) {
if (event.getType() == RefreshEvent.Type.DETAIL) getDetail();
if (event.getType() == RefreshEvent.Type.PLAYER) onRefresh();
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void onPlayerEvent(PlayerEvent event) {
switch (event.getState()) {

Loading…
Cancel
Save