Jump to the oldest unread message after loading a draft.

This commit is contained in:
Greyson Parrelli
2018-07-25 11:30:48 -04:00
parent d5a9efa96a
commit 67190774cc
6 changed files with 185 additions and 42 deletions

View File

@@ -16,6 +16,13 @@ public class SettableFuture<T> implements ListenableFuture<T> {
private volatile T result;
private volatile Throwable exception;
public SettableFuture() { }
public SettableFuture(T value) {
this.result = value;
this.completed = true;
}
@Override
public synchronized boolean cancel(boolean mayInterruptIfRunning) {
if (!completed && !canceled) {
@@ -64,6 +71,20 @@ public class SettableFuture<T> implements ListenableFuture<T> {
return true;
}
public void deferTo(ListenableFuture<T> other) {
other.addListener(new Listener<T>() {
@Override
public void onSuccess(T result) {
SettableFuture.this.set(result);
}
@Override
public void onFailure(ExecutionException e) {
SettableFuture.this.setException(e.getCause());
}
});
}
@Override
public synchronized T get() throws InterruptedException, ExecutionException {
while (!completed) wait();