pull/123/head
FongMi 3 years ago
parent 9dad52aacc
commit 08f66206dc
  1. 11
      app/src/main/java/com/fongmi/android/tv/model/LiveViewModel.java
  2. 7
      app/src/main/java/com/fongmi/android/tv/model/SiteViewModel.java

@ -58,13 +58,14 @@ public class LiveViewModel extends ViewModel {
executor = Executors.newFixedThreadPool(2);
executor.execute(() -> {
try {
if (!Thread.interrupted() && type == LIVE) live.postValue((Live) executor.submit(callable).get(Constant.TIMEOUT_HTTP, TimeUnit.MILLISECONDS));
if (!Thread.interrupted() && type == CHANNEL) channel.postValue((Channel) executor.submit(callable).get(Constant.TIMEOUT_LIVE, TimeUnit.MILLISECONDS));
if (Thread.interrupted()) return;
if (type == LIVE) live.postValue((Live) executor.submit(callable).get(Constant.TIMEOUT_HTTP, TimeUnit.MILLISECONDS));
if (type == CHANNEL) channel.postValue((Channel) executor.submit(callable).get(Constant.TIMEOUT_LIVE, TimeUnit.MILLISECONDS));
} catch (Throwable e) {
if (e instanceof InterruptedException || Thread.interrupted()) return;
if (type == LIVE) live.postValue(new Live());
if (type == CHANNEL) channel.postValue(new Channel());
e.printStackTrace();
if (e instanceof InterruptedException) return;
if (!Thread.interrupted() && type == LIVE) live.postValue(new Live());
if (!Thread.interrupted() && type == CHANNEL) channel.postValue(new Channel());
}
});
}

@ -195,11 +195,12 @@ public class SiteViewModel extends ViewModel {
executor = Executors.newFixedThreadPool(2);
executor.execute(() -> {
try {
if (!Thread.interrupted()) result.postValue(executor.submit(callable).get(Constant.TIMEOUT_VOD, TimeUnit.MILLISECONDS));
if (Thread.interrupted()) return;
result.postValue(executor.submit(callable).get(Constant.TIMEOUT_VOD, TimeUnit.MILLISECONDS));
} catch (Throwable e) {
if (e instanceof InterruptedException || Thread.interrupted()) return;
result.postValue(Result.empty());
e.printStackTrace();
if (e instanceof InterruptedException) return;
if (!Thread.interrupted()) result.postValue(Result.empty());
}
});
}

Loading…
Cancel
Save