mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 11:19:04 +01:00
Always check whether context has been destroyed.
This commit is contained in:
@@ -2,35 +2,33 @@ package org.briarproject.android.controller.handler;
|
||||
|
||||
import android.support.annotation.UiThread;
|
||||
|
||||
import org.briarproject.android.DestroyableActivity;
|
||||
import org.briarproject.android.DestroyableContext;
|
||||
|
||||
public abstract class UiResultExceptionHandler<R, E extends Exception>
|
||||
implements ResultExceptionHandler<R, E> {
|
||||
|
||||
private final DestroyableActivity listener;
|
||||
private final DestroyableContext listener;
|
||||
|
||||
protected UiResultExceptionHandler(DestroyableActivity listener) {
|
||||
protected UiResultExceptionHandler(DestroyableContext listener) {
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResult(final R result) {
|
||||
listener.runOnUiThread(new Runnable() {
|
||||
listener.runOnUiThreadUnlessDestroyed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!listener.hasBeenDestroyed())
|
||||
onResultUi(result);
|
||||
onResultUi(result);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onException(final E exception) {
|
||||
listener.runOnUiThread(new Runnable() {
|
||||
listener.runOnUiThreadUnlessDestroyed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!listener.hasBeenDestroyed())
|
||||
onExceptionUi(exception);
|
||||
onExceptionUi(exception);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -2,24 +2,22 @@ package org.briarproject.android.controller.handler;
|
||||
|
||||
import android.support.annotation.UiThread;
|
||||
|
||||
import org.briarproject.android.DestroyableActivity;
|
||||
import org.briarproject.android.fragment.BaseFragment.BaseFragmentListener;
|
||||
import org.briarproject.android.DestroyableContext;
|
||||
|
||||
public abstract class UiResultHandler<R> implements ResultHandler<R> {
|
||||
|
||||
private final DestroyableActivity listener;
|
||||
private final DestroyableContext listener;
|
||||
|
||||
protected UiResultHandler(DestroyableActivity listener) {
|
||||
protected UiResultHandler(DestroyableContext listener) {
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResult(final R result) {
|
||||
listener.runOnUiThread(new Runnable() {
|
||||
listener.runOnUiThreadUnlessDestroyed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!listener.hasBeenDestroyed())
|
||||
onResultUi(result);
|
||||
onResultUi(result);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user