android: model: Make some methods static

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
This commit is contained in:
Harsh Shandilya 2018-06-27 23:10:37 +05:30 committed by Jason A. Donenfeld
parent e985452f3b
commit 363d0b9126
2 changed files with 5 additions and 5 deletions

View File

@ -80,21 +80,21 @@ public class Tunnel extends BaseObservable implements Keyed<String> {
} }
public CompletionStage<State> getStateAsync() { public CompletionStage<State> getStateAsync() {
return manager.getTunnelState(this); return TunnelManager.getTunnelState(this);
} }
@Bindable @Bindable
public Statistics getStatistics() { public Statistics getStatistics() {
// FIXME: Check age of statistics. // FIXME: Check age of statistics.
if (statistics == null) if (statistics == null)
manager.getTunnelStatistics(this).whenComplete(ExceptionLoggers.E); TunnelManager.getTunnelStatistics(this).whenComplete(ExceptionLoggers.E);
return statistics; return statistics;
} }
public CompletionStage<Statistics> getStatisticsAsync() { public CompletionStage<Statistics> getStatisticsAsync() {
// FIXME: Check age of statistics. // FIXME: Check age of statistics.
if (statistics == null) if (statistics == null)
return manager.getTunnelStatistics(this); return TunnelManager.getTunnelStatistics(this);
return CompletableFuture.completedFuture(statistics); return CompletableFuture.completedFuture(statistics);
} }

View File

@ -112,12 +112,12 @@ public final class TunnelManager extends BaseObservable {
.thenApply(tunnel::onConfigChanged); .thenApply(tunnel::onConfigChanged);
} }
CompletionStage<State> getTunnelState(final Tunnel tunnel) { static CompletionStage<State> getTunnelState(final Tunnel tunnel) {
return Application.getAsyncWorker().supplyAsync(() -> Application.getBackend().getState(tunnel)) return Application.getAsyncWorker().supplyAsync(() -> Application.getBackend().getState(tunnel))
.thenApply(tunnel::onStateChanged); .thenApply(tunnel::onStateChanged);
} }
CompletionStage<Statistics> getTunnelStatistics(final Tunnel tunnel) { static CompletionStage<Statistics> getTunnelStatistics(final Tunnel tunnel) {
return Application.getAsyncWorker().supplyAsync(() -> Application.getBackend().getStatistics(tunnel)) return Application.getAsyncWorker().supplyAsync(() -> Application.getBackend().getStatistics(tunnel))
.thenApply(tunnel::onStatisticsChanged); .thenApply(tunnel::onStatisticsChanged);
} }